From 203c9eea74c318435dd4021b5fe0d0f5143b2e9c Mon Sep 17 00:00:00 2001 From: Uwe Krueger Date: Tue, 28 Nov 2023 16:33:34 +0100 Subject: [PATCH] rename base to proxy --- pkg/contexts/ocm/cpi/repocpi/backend.go | 34 +++--- pkg/contexts/ocm/cpi/repocpi/doc.go | 6 +- .../ocm/cpi/repocpi/{base_c.go => proxy_c.go} | 76 ++++++------ .../cpi/repocpi/{base_cv.go => proxy_cv.go} | 110 ++++++++---------- .../ocm/cpi/repocpi/{base_r.go => proxy_r.go} | 40 +++---- pkg/contexts/ocm/cpi/repocpi/view_c.go | 40 +++---- pkg/contexts/ocm/cpi/repocpi/view_cv.go | 82 ++++++------- pkg/contexts/ocm/cpi/repocpi/view_r.go | 42 +++---- .../repositories/comparch/componentarchive.go | 6 +- .../ocm/repositories/comparch/repository.go | 16 +-- .../repositories/genericocireg/component.go | 6 +- .../genericocireg/componentversion.go | 6 +- .../repositories/genericocireg/repository.go | 4 +- .../ocm/repositories/virtual/component.go | 6 +- .../repositories/virtual/componentversion.go | 6 +- .../ocm/repositories/virtual/repository.go | 4 +- 16 files changed, 240 insertions(+), 244 deletions(-) rename pkg/contexts/ocm/cpi/repocpi/{base_c.go => proxy_c.go} (58%) rename pkg/contexts/ocm/cpi/repocpi/{base_cv.go => proxy_cv.go} (73%) rename pkg/contexts/ocm/cpi/repocpi/{base_r.go => proxy_r.go} (59%) diff --git a/pkg/contexts/ocm/cpi/repocpi/backend.go b/pkg/contexts/ocm/cpi/repocpi/backend.go index f342e9adce..de54b51aac 100644 --- a/pkg/contexts/ocm/cpi/repocpi/backend.go +++ b/pkg/contexts/ocm/cpi/repocpi/backend.go @@ -21,7 +21,7 @@ import ( // and component version objects, which are generically implemented // based on the methods of this interface. // -// A repositotry interface based on this implementation interface can be +// A repository interface based on this implementation interface can be // created using the function NewStorageBackend. type StorageBackendImpl interface { // repository related methods. @@ -52,7 +52,7 @@ type StorageBackendImpl interface { } type storageBackendRepository struct { - base RepositoryBase + proxy RepositoryProxy closed atomic.Bool noref cpi.Repository kind string @@ -78,9 +78,9 @@ func NewStorageBackend(kind string, impl StorageBackendImpl) cpi.Repository { return NewRepository(backend, kind) } -func (s *storageBackendRepository) SetBase(base RepositoryBase) { - s.base = base - s.noref = NewNoneRefRepositoryView(base) +func (s *storageBackendRepository) SetProxy(proxy RepositoryProxy) { + s.proxy = proxy + s.noref = NewNoneRefRepositoryView(proxy) } func (s *storageBackendRepository) Close() error { @@ -124,19 +124,19 @@ func (s *storageBackendRepository) LookupComponent(name string) (*ComponentAcces //////////////////////////////////////////////////////////////////////////////// type storageBackendComponent struct { - base ComponentAccessBase - repo *storageBackendRepository - name string + proxy ComponentAccessProxy + repo *storageBackendRepository + name string } var _ ComponentAccessImpl = (*storageBackendComponent)(nil) -func (s *storageBackendComponent) SetBase(base ComponentAccessBase) { - s.base = base +func (s *storageBackendComponent) SetProxy(proxy ComponentAccessProxy) { + s.proxy = proxy } -func (s *storageBackendComponent) GetParentBase() RepositoryViewManager { - return s.repo.base +func (s *storageBackendComponent) GetParentProxy() RepositoryViewManager { + return s.repo.proxy } func (s *storageBackendComponent) Close() error { @@ -213,7 +213,7 @@ func (s *storageBackendComponent) NewVersion(version string, overwrite ...bool) //////////////////////////////////////////////////////////////////////////////// type storageBackendComponentVersion struct { - base ComponentVersionAccessBase + proxy ComponentVersionAccessProxy comp *storageBackendComponent name common.NameVersion descriptor *compdesc.ComponentDescriptor @@ -229,12 +229,12 @@ func (s *storageBackendComponentVersion) GetContext() cpi.Context { return s.comp.repo.impl.GetContext() } -func (s *storageBackendComponentVersion) SetBase(base ComponentVersionAccessBase) { - s.base = base +func (s *storageBackendComponentVersion) SetProxy(proxy ComponentVersionAccessProxy) { + s.proxy = proxy } -func (s *storageBackendComponentVersion) GetParentBase() ComponentAccessBase { - return s.comp.base +func (s *storageBackendComponentVersion) GetParentProxy() ComponentAccessProxy { + return s.comp.proxy } func (s *storageBackendComponentVersion) Repository() cpi.Repository { diff --git a/pkg/contexts/ocm/cpi/repocpi/doc.go b/pkg/contexts/ocm/cpi/repocpi/doc.go index e72f369079..4b7f92a21f 100644 --- a/pkg/contexts/ocm/cpi/repocpi/doc.go +++ b/pkg/contexts/ocm/cpi/repocpi/doc.go @@ -13,11 +13,15 @@ // in package [github.com/open-component-model/ocm/pkg/contexts/ocm]. // // - on layer 2 (this package) there is a backend agnostic -// implementation od standard functionality based on layer 3. +// implementation of standard functionality based on layer 3. // This is divided into two parts // // a) the view objects provided by the Dup() calls of the layer 1 API. // All dups are internally based on a single base object. +// These objects are called proxy. They act as base object +// for the views and as wrapper for the implementation objects +// providing generic implementations potentially based on +// the implementation functionality. // // b) the base object for all dup views is used to implement some // common functionality like the view management. The base object diff --git a/pkg/contexts/ocm/cpi/repocpi/base_c.go b/pkg/contexts/ocm/cpi/repocpi/proxy_c.go similarity index 58% rename from pkg/contexts/ocm/cpi/repocpi/base_c.go rename to pkg/contexts/ocm/cpi/repocpi/proxy_c.go index 2ae2f964c4..3e300a7ec8 100644 --- a/pkg/contexts/ocm/cpi/repocpi/base_c.go +++ b/pkg/contexts/ocm/cpi/repocpi/proxy_c.go @@ -27,8 +27,8 @@ type ComponentVersionAccessInfo struct { // ComponentAccessImpl is the provider implementation // interface for component versions. type ComponentAccessImpl interface { - SetBase(base ComponentAccessBase) - GetParentBase() RepositoryViewManager + SetProxy(proxy ComponentAccessProxy) + GetParentProxy() RepositoryViewManager GetContext() cpi.Context GetName() string @@ -42,67 +42,67 @@ type ComponentAccessImpl interface { io.Closer } -type _componentAccessImplBase = resource.ResourceImplBase[cpi.ComponentAccess] +type _componentAccessProxyBase = resource.ResourceImplBase[cpi.ComponentAccess] -type componentAccessBase struct { - *_componentAccessImplBase +type componentAccessProxy struct { + *_componentAccessProxyBase ctx cpi.Context name string impl ComponentAccessImpl } -func newComponentAccessImplBase(impl ComponentAccessImpl, closer ...io.Closer) (ComponentAccessBase, error) { - base, err := resource.NewResourceImplBase[cpi.ComponentAccess, cpi.Repository](impl.GetParentBase(), closer...) +func newComponentAccessProxy(impl ComponentAccessImpl, closer ...io.Closer) (ComponentAccessProxy, error) { + base, err := resource.NewResourceImplBase[cpi.ComponentAccess, cpi.Repository](impl.GetParentProxy(), closer...) if err != nil { return nil, err } - b := &componentAccessBase{ - _componentAccessImplBase: base, - ctx: impl.GetContext(), - name: impl.GetName(), - impl: impl, + b := &componentAccessProxy{ + _componentAccessProxyBase: base, + ctx: impl.GetContext(), + name: impl.GetName(), + impl: impl, } - impl.SetBase(b) + impl.SetProxy(b) return b, nil } -func (b *componentAccessBase) Close() error { +func (b *componentAccessProxy) Close() error { list := errors.ErrListf("closing component %s", b.name) - refmgmt.AllocLog.Trace("closing component base", "name", b.name) + refmgmt.AllocLog.Trace("closing component proxy", "name", b.name) list.Add(b.impl.Close()) - list.Add(b._componentAccessImplBase.Close()) - refmgmt.AllocLog.Trace("closed component base", "name", b.name) + list.Add(b._componentAccessProxyBase.Close()) + refmgmt.AllocLog.Trace("closed component proxy", "name", b.name) return list.Result() } -func (b *componentAccessBase) GetContext() cpi.Context { +func (b *componentAccessProxy) GetContext() cpi.Context { return b.ctx } -func (b *componentAccessBase) GetName() string { +func (b *componentAccessProxy) GetName() string { return b.name } -func (b *componentAccessBase) IsReadOnly() bool { +func (b *componentAccessProxy) IsReadOnly() bool { return b.impl.IsReadOnly() } -func (c *componentAccessBase) IsOwned(cv cpi.ComponentVersionAccess) bool { - base, err := GetComponentVersionAccessBase(cv) +func (c *componentAccessProxy) IsOwned(cv cpi.ComponentVersionAccess) bool { + proxy, err := GetComponentVersionAccessProxy(cv) if err != nil { return false } - impl := base.(*componentVersionAccessBase).impl - cvcompmgr := impl.GetParentBase() + impl := proxy.(*componentVersionAccessProxy).impl + cvcompmgr := impl.GetParentProxy() return c == cvcompmgr } -func (b *componentAccessBase) ListVersions() ([]string, error) { +func (b *componentAccessProxy) ListVersions() ([]string, error) { return b.impl.ListVersions() } -func (b *componentAccessBase) LookupVersion(version string) (cpi.ComponentVersionAccess, error) { +func (b *componentAccessProxy) LookupVersion(version string) (cpi.ComponentVersionAccess, error) { i, err := b.impl.LookupVersion(version) if err != nil { return nil, err @@ -113,11 +113,11 @@ func (b *componentAccessBase) LookupVersion(version string) (cpi.ComponentVersio return NewComponentVersionAccess(b.GetName(), version, i.Impl, i.Lazy, i.Persistent, !compositionmodeattr.Get(b.GetContext())) } -func (b *componentAccessBase) HasVersion(vers string) (bool, error) { +func (b *componentAccessProxy) HasVersion(vers string) (bool, error) { return b.impl.HasVersion(vers) } -func (b *componentAccessBase) NewVersion(version string, overrides ...bool) (cpi.ComponentVersionAccess, error) { +func (b *componentAccessProxy) NewVersion(version string, overrides ...bool) (cpi.ComponentVersionAccess, error) { i, err := b.impl.NewVersion(version, overrides...) if err != nil { return nil, err @@ -128,11 +128,11 @@ func (b *componentAccessBase) NewVersion(version string, overrides ...bool) (cpi return NewComponentVersionAccess(b.GetName(), version, i.Impl, i.Lazy, false, !compositionmodeattr.Get(b.GetContext())) } -func (c *componentAccessBase) AddVersion(cv cpi.ComponentVersionAccess, opts *cpi.AddVersionOptions) (ferr error) { +func (c *componentAccessProxy) AddVersion(cv cpi.ComponentVersionAccess, opts *cpi.AddVersionOptions) (ferr error) { var finalize finalizer.Finalizer defer finalize.FinalizeWithErrorPropagation(&ferr) - cvbase, err := GetComponentVersionAccessBase(cv) + cvproxy, err := GetComponentVersionAccessProxy(cv) if err != nil { return err } @@ -146,7 +146,7 @@ func (c *componentAccessBase) AddVersion(cv cpi.ComponentVersionAccess, opts *cp finalize.With(func() error { return eff.Close() }) - cvbase, err = GetComponentVersionAccessBase(eff) + cvproxy, err = GetComponentVersionAccessProxy(eff) if err != nil { return err } @@ -154,20 +154,20 @@ func (c *componentAccessBase) AddVersion(cv cpi.ComponentVersionAccess, opts *cp d := eff.GetDescriptor() *d = *cv.GetDescriptor().Copy() - err = c.setupLocalBlobs("resource", cv, cvbase, d.Resources, &opts.BlobUploadOptions) + err = c.setupLocalBlobs("resource", cv, cvproxy, d.Resources, &opts.BlobUploadOptions) if err == nil { - err = c.setupLocalBlobs("source", cv, cvbase, d.Sources, &opts.BlobUploadOptions) + err = c.setupLocalBlobs("source", cv, cvproxy, d.Sources, &opts.BlobUploadOptions) } if err != nil { return err } } - cvbase.EnablePersistence() - err = cvbase.Update(!cvbase.UseDirectAccess()) + cvproxy.EnablePersistence() + err = cvproxy.Update(!cvproxy.UseDirectAccess()) return err } -func (c *componentAccessBase) setupLocalBlobs(kind string, src cpi.ComponentVersionAccess, tgtbase ComponentVersionAccessBase, it compdesc.ArtifactAccessor, opts *cpi.BlobUploadOptions) (ferr error) { +func (c *componentAccessProxy) setupLocalBlobs(kind string, src cpi.ComponentVersionAccess, tgtproxy ComponentVersionAccessProxy, it compdesc.ArtifactAccessor, opts *cpi.BlobUploadOptions) (ferr error) { ctx := src.GetContext() // transfer all local blobs prov := func(spec cpi.AccessSpec) (blob blobaccess.BlobAccess, ref string, global cpi.AccessSpec, err error) { @@ -176,10 +176,10 @@ func (c *componentAccessBase) setupLocalBlobs(kind string, src cpi.ComponentVers if err != nil { return nil, "", nil, err } - return m.AsBlobAccess(), cpi.ReferenceHint(spec, src), cpi.GlobalAccess(spec, tgtbase.GetContext()), nil + return m.AsBlobAccess(), cpi.ReferenceHint(spec, src), cpi.GlobalAccess(spec, tgtproxy.GetContext()), nil } return nil, "", nil, nil } - return tgtbase.(*componentVersionAccessBase).setupLocalBlobs(kind, prov, it, false, opts) + return tgtproxy.(*componentVersionAccessProxy).setupLocalBlobs(kind, prov, it, false, opts) } diff --git a/pkg/contexts/ocm/cpi/repocpi/base_cv.go b/pkg/contexts/ocm/cpi/repocpi/proxy_cv.go similarity index 73% rename from pkg/contexts/ocm/cpi/repocpi/base_cv.go rename to pkg/contexts/ocm/cpi/repocpi/proxy_cv.go index 0064d5f2bb..ea2d56d03a 100644 --- a/pkg/contexts/ocm/cpi/repocpi/base_cv.go +++ b/pkg/contexts/ocm/cpi/repocpi/proxy_cv.go @@ -35,8 +35,8 @@ import ( // interface for component versions. type ComponentVersionAccessImpl interface { GetContext() cpi.Context - SetBase(base ComponentVersionAccessBase) - GetParentBase() ComponentAccessBase + SetProxy(proxy ComponentVersionAccessProxy) + GetParentProxy() ComponentAccessProxy Repository() cpi.Repository @@ -52,25 +52,17 @@ type ComponentVersionAccessImpl interface { io.Closer } -type ComponentVersionAccessImplSupport struct { - Base ComponentVersionAccessBase -} - -func (b *ComponentVersionAccessImplSupport) SetBase(base ComponentVersionAccessBase) { - b.Base = base -} - -type _componentVersionAccessImplBase = resource.ResourceImplBase[cpi.ComponentVersionAccess] +type _componentVersionAccessProxyBase = resource.ResourceImplBase[cpi.ComponentVersionAccess] -// componentVersionAccessBase is the counterpart to views, all views +// componentVersionAccessProxy is the counterpart to views, all views // created by Dup calls use this base object to work on. // Besides some functionality covered by view objects these base objects // implement provider-agnostic parts of the ComponentVersionAccess API. -type componentVersionAccessBase struct { +type componentVersionAccessProxy struct { lock sync.Mutex id finalizer.ObjectIdentity - *_componentVersionAccessImplBase + *_componentVersionAccessProxyBase ctx cpi.Context name string version string @@ -86,37 +78,37 @@ type componentVersionAccessBase struct { impl ComponentVersionAccessImpl } -var _ ComponentVersionAccessBase = (*componentVersionAccessBase)(nil) +var _ ComponentVersionAccessProxy = (*componentVersionAccessProxy)(nil) -func newComponentVersionAccessBase(name, version string, impl ComponentVersionAccessImpl, lazy, persistent, direct bool, closer ...io.Closer) (ComponentVersionAccessBase, error) { - base, err := resource.NewResourceImplBase[cpi.ComponentVersionAccess, cpi.ComponentAccess](impl.GetParentBase(), closer...) +func newComponentVersionAccessProxy(name, version string, impl ComponentVersionAccessImpl, lazy, persistent, direct bool, closer ...io.Closer) (ComponentVersionAccessProxy, error) { + base, err := resource.NewResourceImplBase[cpi.ComponentVersionAccess, cpi.ComponentAccess](impl.GetParentProxy(), closer...) if err != nil { return nil, err } - b := &componentVersionAccessBase{ - _componentVersionAccessImplBase: base, - id: finalizer.NewObjectIdentity(fmt.Sprintf("%s:%s", name, version)), - ctx: impl.GetContext(), - name: name, - version: version, - blobcache: NewBlobCache(), - lazy: lazy, - persistent: persistent, - directAccess: direct, - impl: impl, - } - impl.SetBase(b) + b := &componentVersionAccessProxy{ + _componentVersionAccessProxyBase: base, + id: finalizer.NewObjectIdentity(fmt.Sprintf("%s:%s", name, version)), + ctx: impl.GetContext(), + name: name, + version: version, + blobcache: NewBlobCache(), + lazy: lazy, + persistent: persistent, + directAccess: direct, + impl: impl, + } + impl.SetProxy(b) return b, nil } func GetComponentVersionImpl[T ComponentVersionAccessImpl](cv cpi.ComponentVersionAccess) (T, error) { var _nil T - impl, err := GetComponentVersionAccessBase(cv) + impl, err := GetComponentVersionAccessProxy(cv) if err != nil { return _nil, err } - if mine, ok := impl.(*componentVersionAccessBase); ok { + if mine, ok := impl.(*componentVersionAccessProxy); ok { cont, ok := mine.impl.(T) if ok { return cont, nil @@ -126,7 +118,7 @@ func GetComponentVersionImpl[T ComponentVersionAccessImpl](cv cpi.ComponentVersi return _nil, errors.Newf("non-matching component version implementation %T", impl) } -func (b *componentVersionAccessBase) Close() error { +func (b *componentVersionAccessProxy) Close() error { list := errors.ErrListf("closing component version %s", common.VersionedElementKey(b)) refmgmt.AllocLog.Trace("closing component version base", "name", common.VersionedElementKey(b)) // prepare artifact access for final close in @@ -135,33 +127,33 @@ func (b *componentVersionAccessBase) Close() error { list.Add(b.update(true)) } list.Add(b.impl.Close()) - list.Add(b._componentVersionAccessImplBase.Close()) + list.Add(b._componentVersionAccessProxyBase.Close()) list.Add(b.blobcache.Clear()) refmgmt.AllocLog.Trace("closed component version base", "name", common.VersionedElementKey(b)) return list.Result() } -func (b *componentVersionAccessBase) GetContext() cpi.Context { +func (b *componentVersionAccessProxy) GetContext() cpi.Context { return b.ctx } -func (b *componentVersionAccessBase) GetName() string { +func (b *componentVersionAccessProxy) GetName() string { return b.name } -func (b *componentVersionAccessBase) GetVersion() string { +func (b *componentVersionAccessProxy) GetVersion() string { return b.version } -func (b *componentVersionAccessBase) GetImplementation() ComponentVersionAccessImpl { +func (b *componentVersionAccessProxy) GetImplementation() ComponentVersionAccessImpl { return b.impl } -func (b *componentVersionAccessBase) GetBlobCache() BlobCache { +func (b *componentVersionAccessProxy) GetBlobCache() BlobCache { return b.blobcache } -func (b *componentVersionAccessBase) EnablePersistence() bool { +func (b *componentVersionAccessProxy) EnablePersistence() bool { if b.discardChanges { return false } @@ -170,30 +162,30 @@ func (b *componentVersionAccessBase) EnablePersistence() bool { return true } -func (b *componentVersionAccessBase) IsPersistent() bool { +func (b *componentVersionAccessProxy) IsPersistent() bool { return b.persistent } -func (b *componentVersionAccessBase) UseDirectAccess() bool { +func (b *componentVersionAccessProxy) UseDirectAccess() bool { return b.directAccess } -func (b *componentVersionAccessBase) DiscardChanges() { +func (b *componentVersionAccessProxy) DiscardChanges() { b.discardChanges = true } -func (b *componentVersionAccessBase) Repository() cpi.Repository { +func (b *componentVersionAccessProxy) Repository() cpi.Repository { return b.impl.Repository() } -func (b *componentVersionAccessBase) IsReadOnly() bool { +func (b *componentVersionAccessProxy) IsReadOnly() bool { return b.impl.IsReadOnly() } //////////////////////////////////////////////////////////////////////////////// // with access to actual view -func (b *componentVersionAccessBase) AccessMethod(spec cpi.AccessSpec, cv refmgmt.ExtendedAllocatable) (meth cpi.AccessMethod, err error) { +func (b *componentVersionAccessProxy) AccessMethod(spec cpi.AccessSpec, cv refmgmt.ExtendedAllocatable) (meth cpi.AccessMethod, err error) { switch { case compose.Is(spec): cspec, ok := spec.(*compose.AccessSpec) @@ -216,36 +208,36 @@ func (b *componentVersionAccessBase) AccessMethod(spec cpi.AccessSpec, cv refmgm return meth, err } -func (b *componentVersionAccessBase) GetInexpensiveContentVersionIdentity(acc cpi.AccessSpec, cv refmgmt.ExtendedAllocatable) string { +func (b *componentVersionAccessProxy) GetInexpensiveContentVersionIdentity(acc cpi.AccessSpec, cv refmgmt.ExtendedAllocatable) string { return b.impl.GetInexpensiveContentVersionIdentity(acc, cv) } -func (b *componentVersionAccessBase) GetDescriptor() *compdesc.ComponentDescriptor { +func (b *componentVersionAccessProxy) GetDescriptor() *compdesc.ComponentDescriptor { b.lock.Lock() defer b.lock.Unlock() return b.getDescriptor() } -func (b *componentVersionAccessBase) getDescriptor() *compdesc.ComponentDescriptor { +func (b *componentVersionAccessProxy) getDescriptor() *compdesc.ComponentDescriptor { if b.descriptor == nil { b.descriptor = b.impl.GetDescriptor() } return b.descriptor } -func (b *componentVersionAccessBase) GetStorageContext() cpi.StorageContext { +func (b *componentVersionAccessProxy) GetStorageContext() cpi.StorageContext { return b.impl.GetStorageContext() } -func (b *componentVersionAccessBase) ShouldUpdate(final bool) bool { +func (b *componentVersionAccessProxy) ShouldUpdate(final bool) bool { b.lock.Lock() defer b.lock.Unlock() return b.shouldUpdate(final) } -func (b *componentVersionAccessBase) shouldUpdate(final bool) bool { +func (b *componentVersionAccessProxy) shouldUpdate(final bool) bool { if b.discardChanges { return false } @@ -255,14 +247,14 @@ func (b *componentVersionAccessBase) shouldUpdate(final bool) bool { return !b.lazy && b.directAccess && b.persistent } -func (b *componentVersionAccessBase) Update(final bool) error { +func (b *componentVersionAccessProxy) Update(final bool) error { b.lock.Lock() defer b.lock.Unlock() return b.update(final) } -func (b *componentVersionAccessBase) update(final bool) error { +func (b *componentVersionAccessProxy) update(final bool) error { if !b.shouldUpdate(final) { return nil } @@ -288,7 +280,7 @@ func (b *componentVersionAccessBase) update(final bool) error { return err } -func (b *componentVersionAccessBase) getLocalBlob(acc cpi.AccessSpec) cpi.BlobAccess { +func (b *componentVersionAccessProxy) getLocalBlob(acc cpi.AccessSpec) cpi.BlobAccess { key, err := json.Marshal(acc) if err != nil { return nil @@ -296,7 +288,7 @@ func (b *componentVersionAccessBase) getLocalBlob(acc cpi.AccessSpec) cpi.BlobAc return b.blobcache.GetBlobFor(string(key)) } -func (b *componentVersionAccessBase) AddBlob(blob cpi.BlobAccess, artType, refName string, global cpi.AccessSpec, final bool, opts *cpi.BlobUploadOptions) (cpi.AccessSpec, error) { +func (b *componentVersionAccessProxy) AddBlob(blob cpi.BlobAccess, artType, refName string, global cpi.AccessSpec, final bool, opts *cpi.BlobUploadOptions) (cpi.AccessSpec, error) { if blob == nil { return nil, errors.New("a resource has to be defined") } @@ -357,7 +349,7 @@ func (b *componentVersionAccessBase) AddBlob(blob cpi.BlobAccess, artType, refNa return b.cacheLocalBlob(acc, blob) } -func (b *componentVersionAccessBase) cacheLocalBlob(acc cpi.AccessSpec, blob cpi.BlobAccess) (cpi.AccessSpec, error) { +func (b *componentVersionAccessProxy) cacheLocalBlob(acc cpi.AccessSpec, blob cpi.BlobAccess) (cpi.AccessSpec, error) { key, err := json.Marshal(acc) if err != nil { return nil, errors.Wrapf(err, "cannot marshal access spec") @@ -385,7 +377,7 @@ func (b *componentVersionAccessBase) cacheLocalBlob(acc cpi.AccessSpec, blob cpi //////////////////////////////////////////////////////////////////////////////// -func (b *componentVersionAccessBase) composeAccess(spec cpi.AccessSpec) (blobaccess.BlobAccess, string, cpi.AccessSpec, error) { +func (b *componentVersionAccessProxy) composeAccess(spec cpi.AccessSpec) (blobaccess.BlobAccess, string, cpi.AccessSpec, error) { if !compose.Is(spec) { return nil, "", nil, nil } @@ -405,7 +397,7 @@ func (b *componentVersionAccessBase) composeAccess(spec cpi.AccessSpec) (blobacc return blob, cspec.ReferenceName, cspec.GlobalAccess.Get(), nil } -func (b *componentVersionAccessBase) setupLocalBlobs(kind string, accprov func(cpi.AccessSpec) (blobaccess.BlobAccess, string, cpi.AccessSpec, error), it compdesc.ArtifactAccessor, final bool, opts *cpi.BlobUploadOptions) (ferr error) { +func (b *componentVersionAccessProxy) setupLocalBlobs(kind string, accprov func(cpi.AccessSpec) (blobaccess.BlobAccess, string, cpi.AccessSpec, error), it compdesc.ArtifactAccessor, final bool, opts *cpi.BlobUploadOptions) (ferr error) { var finalize finalizer.Finalizer defer finalize.FinalizeWithErrorPropagation(&ferr) diff --git a/pkg/contexts/ocm/cpi/repocpi/base_r.go b/pkg/contexts/ocm/cpi/repocpi/proxy_r.go similarity index 59% rename from pkg/contexts/ocm/cpi/repocpi/base_r.go rename to pkg/contexts/ocm/cpi/repocpi/proxy_r.go index e2eb5687d4..1adae9295b 100644 --- a/pkg/contexts/ocm/cpi/repocpi/base_r.go +++ b/pkg/contexts/ocm/cpi/repocpi/proxy_r.go @@ -20,7 +20,7 @@ type ComponentAccessInfo struct { } type RepositoryImpl interface { - SetBase(base RepositoryBase) + SetProxy(proxy RepositoryProxy) GetContext() cpi.Context @@ -33,52 +33,52 @@ type RepositoryImpl interface { io.Closer } -type _repositoryImplBase = resource.ResourceImplBase[cpi.Repository] +type _repositoryProxyBase = resource.ResourceImplBase[cpi.Repository] -type repositoryBase struct { - *_repositoryImplBase +type repositoryProxy struct { + *_repositoryProxyBase ctx cpi.Context kind string impl RepositoryImpl } -func newRepositoryImplBase(impl RepositoryImpl, kind string, closer ...io.Closer) RepositoryBase { +func newRepositoryProxy(impl RepositoryImpl, kind string, closer ...io.Closer) RepositoryProxy { base := resource.NewSimpleResourceImplBase[cpi.Repository](closer...) - b := &repositoryBase{ - _repositoryImplBase: base, - ctx: impl.GetContext(), - impl: impl, + b := &repositoryProxy{ + _repositoryProxyBase: base, + ctx: impl.GetContext(), + impl: impl, } - impl.SetBase(b) + impl.SetProxy(b) return b } -func (b *repositoryBase) Close() error { +func (b *repositoryProxy) Close() error { list := errors.ErrListf("closing %s", b.kind) - refmgmt.AllocLog.Trace("closing repository base", "kind", b.kind) + refmgmt.AllocLog.Trace("closing repository proxy", "kind", b.kind) list.Add(b.impl.Close()) - list.Add(b._repositoryImplBase.Close()) - refmgmt.AllocLog.Trace("closed repository base", "kind", b.kind) + list.Add(b._repositoryProxyBase.Close()) + refmgmt.AllocLog.Trace("closed repository proxy", "kind", b.kind) return list.Result() } -func (b *repositoryBase) GetContext() cpi.Context { +func (b *repositoryProxy) GetContext() cpi.Context { return b.ctx } -func (b *repositoryBase) GetSpecification() cpi.RepositorySpec { +func (b *repositoryProxy) GetSpecification() cpi.RepositorySpec { return b.impl.GetSpecification() } -func (b *repositoryBase) ComponentLister() cpi.ComponentLister { +func (b *repositoryProxy) ComponentLister() cpi.ComponentLister { return b.impl.ComponentLister() } -func (b *repositoryBase) ExistsComponentVersion(name string, version string) (bool, error) { +func (b *repositoryProxy) ExistsComponentVersion(name string, version string) (bool, error) { return b.impl.ExistsComponentVersion(name, version) } -func (b *repositoryBase) LookupComponentVersion(name string, version string) (cv cpi.ComponentVersionAccess, rerr error) { +func (b *repositoryProxy) LookupComponentVersion(name string, version string) (cv cpi.ComponentVersionAccess, rerr error) { c, err := b.LookupComponent(name) if err != nil { return nil, err @@ -88,7 +88,7 @@ func (b *repositoryBase) LookupComponentVersion(name string, version string) (cv return c.LookupVersion(version) } -func (b *repositoryBase) LookupComponent(name string) (cpi.ComponentAccess, error) { +func (b *repositoryProxy) LookupComponent(name string) (cpi.ComponentAccess, error) { i, err := b.impl.LookupComponent(name) if err != nil { return nil, err diff --git a/pkg/contexts/ocm/cpi/repocpi/view_c.go b/pkg/contexts/ocm/cpi/repocpi/view_c.go index 883b7fc748..f393faa827 100644 --- a/pkg/contexts/ocm/cpi/repocpi/view_c.go +++ b/pkg/contexts/ocm/cpi/repocpi/view_c.go @@ -21,7 +21,7 @@ type _componentAccessView interface { type ComponentAccessViewManager = resource.ViewManager[cpi.ComponentAccess] // here you have to use an alias -type ComponentAccessBase interface { +type ComponentAccessProxy interface { resource.ResourceImplementation[cpi.ComponentAccess] GetContext() cpi.Context @@ -41,7 +41,7 @@ type ComponentAccessBase interface { type componentAccessView struct { _componentAccessView - base ComponentAccessBase + proxy ComponentAccessProxy } var ( @@ -49,57 +49,57 @@ var ( _ utils.Unwrappable = (*componentAccessView)(nil) ) -func GetComponentAccessBase(n cpi.ComponentAccess) (ComponentAccessBase, error) { +func GetComponentAccessProxy(n cpi.ComponentAccess) (ComponentAccessProxy, error) { if v, ok := n.(*componentAccessView); ok { - return v.base, nil + return v.proxy, nil } return nil, errors.ErrNotSupported("component base type", fmt.Sprintf("%T", n)) } func GetComponentAccessImplementation(n cpi.ComponentAccess) (ComponentAccessImpl, error) { if v, ok := n.(*componentAccessView); ok { - if b, ok := v.base.(*componentAccessBase); ok { + if b, ok := v.proxy.(*componentAccessProxy); ok { return b.impl, nil } - return nil, errors.ErrNotSupported("component base type", fmt.Sprintf("%T", v.base)) + return nil, errors.ErrNotSupported("component base type", fmt.Sprintf("%T", v.proxy)) } return nil, errors.ErrNotSupported("component implementation type", fmt.Sprintf("%T", n)) } -func componentAccessViewCreator(i ComponentAccessBase, v resource.CloserView, d ComponentAccessViewManager) cpi.ComponentAccess { +func componentAccessViewCreator(i ComponentAccessProxy, v resource.CloserView, d ComponentAccessViewManager) cpi.ComponentAccess { return &componentAccessView{ _componentAccessView: resource.NewView[cpi.ComponentAccess](v, d), - base: i, + proxy: i, } } func NewComponentAccess(impl ComponentAccessImpl, kind string, main bool, closer ...io.Closer) (cpi.ComponentAccess, error) { - base, err := newComponentAccessImplBase(impl, closer...) + proxy, err := newComponentAccessProxy(impl, closer...) if err != nil { return nil, errors.Join(err, impl.Close()) } if kind == "" { kind = "component" } - cv := resource.NewResource[cpi.ComponentAccess](base, componentAccessViewCreator, fmt.Sprintf("%s %s", kind, impl.GetName()), main) + cv := resource.NewResource[cpi.ComponentAccess](proxy, componentAccessViewCreator, fmt.Sprintf("%s %s", kind, impl.GetName()), main) return cv, nil } func (c *componentAccessView) Unwrap() interface{} { - return c.base + return c.proxy } func (c *componentAccessView) GetContext() cpi.Context { - return c.base.GetContext() + return c.proxy.GetContext() } func (c *componentAccessView) GetName() string { - return c.base.GetName() + return c.proxy.GetName() } func (c *componentAccessView) ListVersions() (list []string, err error) { err = c.Execute(func() error { - list, err = c.base.ListVersions() + list, err = c.proxy.ListVersions() return err }) return list, err @@ -107,7 +107,7 @@ func (c *componentAccessView) ListVersions() (list []string, err error) { func (c *componentAccessView) LookupVersion(version string) (acc cpi.ComponentVersionAccess, err error) { err = c.Execute(func() error { - acc, err = c.base.LookupVersion(version) + acc, err = c.proxy.LookupVersion(version) return err }) return acc, err @@ -119,7 +119,7 @@ func (c *componentAccessView) AddVersion(acc cpi.ComponentVersionAccess, overwri } return c.Execute(func() error { - return c.base.AddVersion(acc, cpi.NewAddVersionOptions(cpi.Overwrite(utils.Optional(overwrite...)))) + return c.proxy.AddVersion(acc, cpi.NewAddVersionOptions(cpi.Overwrite(utils.Optional(overwrite...)))) }) } @@ -128,16 +128,16 @@ func (c *componentAccessView) AddVersionOpt(acc cpi.ComponentVersionAccess, opts return errors.ErrInvalid("component name", acc.GetName()) } return c.Execute(func() error { - return c.base.AddVersion(acc, cpi.NewAddVersionOptions(opts...)) + return c.proxy.AddVersion(acc, cpi.NewAddVersionOptions(opts...)) }) } func (c *componentAccessView) NewVersion(version string, overrides ...bool) (acc cpi.ComponentVersionAccess, err error) { err = c.Execute(func() error { - if c.base.IsReadOnly() { + if c.proxy.IsReadOnly() { return accessio.ErrReadOnly } - acc, err = c.base.NewVersion(version, overrides...) + acc, err = c.proxy.NewVersion(version, overrides...) return err }) return acc, err @@ -145,7 +145,7 @@ func (c *componentAccessView) NewVersion(version string, overrides ...bool) (acc func (c *componentAccessView) HasVersion(vers string) (ok bool, err error) { err = c.Execute(func() error { - ok, err = c.base.HasVersion(vers) + ok, err = c.proxy.HasVersion(vers) return err }) return ok, err diff --git a/pkg/contexts/ocm/cpi/repocpi/view_cv.go b/pkg/contexts/ocm/cpi/repocpi/view_cv.go index 6f4df0e845..d196b97885 100644 --- a/pkg/contexts/ocm/cpi/repocpi/view_cv.go +++ b/pkg/contexts/ocm/cpi/repocpi/view_cv.go @@ -41,7 +41,7 @@ type _componentVersionAccessView interface { type ComponentVersionAccessViewManager = resource.ViewManager[cpi.ComponentVersionAccess] -type ComponentVersionAccessBase interface { +type ComponentVersionAccessProxy interface { resource.ResourceImplementation[cpi.ComponentVersionAccess] common.VersionedElement io.Closer @@ -96,8 +96,8 @@ type ComponentVersionAccessBase interface { type componentVersionAccessView struct { _componentVersionAccessView - base ComponentVersionAccessBase - err error + proxy ComponentVersionAccessProxy + err error } var ( @@ -105,41 +105,41 @@ var ( _ utils.Unwrappable = (*componentVersionAccessView)(nil) ) -func GetComponentVersionAccessBase(n cpi.ComponentVersionAccess) (ComponentVersionAccessBase, error) { +func GetComponentVersionAccessProxy(n cpi.ComponentVersionAccess) (ComponentVersionAccessProxy, error) { if v, ok := n.(*componentVersionAccessView); ok { - return v.base, nil + return v.proxy, nil } - return nil, errors.ErrNotSupported("component version base type", fmt.Sprintf("%T", n)) + return nil, errors.ErrNotSupported("component version proxy type", fmt.Sprintf("%T", n)) } func GetComponentVersionAccessImplementation(n cpi.ComponentVersionAccess) (ComponentVersionAccessImpl, error) { if v, ok := n.(*componentVersionAccessView); ok { - if b, ok := v.base.(*componentVersionAccessBase); ok { + if b, ok := v.proxy.(*componentVersionAccessProxy); ok { return b.impl, nil } - return nil, errors.ErrNotSupported("component version base type", fmt.Sprintf("%T", v.base)) + return nil, errors.ErrNotSupported("component version proxy type", fmt.Sprintf("%T", v.proxy)) } return nil, errors.ErrNotSupported("component version implementation type", fmt.Sprintf("%T", n)) } -func artifactAccessViewCreator(i ComponentVersionAccessBase, v resource.CloserView, d resource.ViewManager[cpi.ComponentVersionAccess]) cpi.ComponentVersionAccess { +func artifactAccessViewCreator(i ComponentVersionAccessProxy, v resource.CloserView, d resource.ViewManager[cpi.ComponentVersionAccess]) cpi.ComponentVersionAccess { cv := &componentVersionAccessView{ _componentVersionAccessView: resource.NewView[cpi.ComponentVersionAccess](v, d), - base: i, + proxy: i, } return cv } func NewComponentVersionAccess(name, version string, impl ComponentVersionAccessImpl, lazy, persistent, direct bool, closer ...io.Closer) (cpi.ComponentVersionAccess, error) { - base, err := newComponentVersionAccessBase(name, version, impl, lazy, persistent, direct, closer...) + proxy, err := newComponentVersionAccessProxy(name, version, impl, lazy, persistent, direct, closer...) if err != nil { return nil, errors.Join(err, impl.Close()) } - return resource.NewResource[cpi.ComponentVersionAccess](base, artifactAccessViewCreator, fmt.Sprintf("component version %s/%s", name, version), true), nil + return resource.NewResource[cpi.ComponentVersionAccess](proxy, artifactAccessViewCreator, fmt.Sprintf("component version %s/%s", name, version), true), nil } func (c *componentVersionAccessView) Unwrap() interface{} { - return c.base + return c.proxy } func (c *componentVersionAccessView) Close() error { @@ -149,23 +149,23 @@ func (c *componentVersionAccessView) Close() error { } func (c *componentVersionAccessView) Repository() cpi.Repository { - return c.base.Repository() + return c.proxy.Repository() } func (c *componentVersionAccessView) GetContext() internal.Context { - return c.base.GetContext() + return c.proxy.GetContext() } func (c *componentVersionAccessView) GetName() string { - return c.base.GetName() + return c.proxy.GetName() } func (c *componentVersionAccessView) GetVersion() string { - return c.base.GetVersion() + return c.proxy.GetVersion() } func (c *componentVersionAccessView) GetDescriptor() *compdesc.ComponentDescriptor { - return c.base.GetDescriptor() + return c.proxy.GetDescriptor() } func (c *componentVersionAccessView) GetProvider() *compdesc.Provider { @@ -195,7 +195,7 @@ func (c *componentVersionAccessView) AccessMethod(spec cpi.AccessSpec) (meth cpi func (c *componentVersionAccessView) accessMethod(spec cpi.AccessSpec) (meth cpi.AccessMethod, err error) { switch { case spec.IsLocal(c.GetContext()): - return c.base.AccessMethod(spec, c.Allocatable()) + return c.proxy.AccessMethod(spec, c.Allocatable()) default: return spec.AccessMethod(c) } @@ -225,16 +225,16 @@ func (c *componentVersionAccessView) getInexpensiveContentVersionIdentity(spec c // fall back to original version return spec.GetInexpensiveContentVersionIdentity(c) default: - return c.base.GetInexpensiveContentVersionIdentity(spec, c.Allocatable()) + return c.proxy.GetInexpensiveContentVersionIdentity(spec, c.Allocatable()) } } func (c *componentVersionAccessView) Update() error { return c.Execute(func() error { - if !c.base.IsPersistent() { + if !c.proxy.IsPersistent() { return ErrTempVersion } - return c.base.Update(true) + return c.proxy.Update(true) }) } @@ -243,7 +243,7 @@ func (c *componentVersionAccessView) AddBlob(blob cpi.BlobAccess, artType, refNa eff := cpi.NewBlobUploadOptions(opts...) err := c.Execute(func() error { var err error - spec, err = c.base.AddBlob(blob, artType, refName, global, false, eff) + spec, err = c.proxy.AddBlob(blob, artType, refName, global, false, eff) return err }) @@ -306,7 +306,7 @@ func setAccess[T any, A internal.ArtifactAccess[T]](c *componentVersionAccessVie set func(*T, compdesc.AccessSpec) error, setblob func(*T, cpi.BlobAccess, string, cpi.AccessSpec) error, ) error { - if c.base.IsReadOnly() { + if c.proxy.IsReadOnly() { return accessio.ErrReadOnly } meta := art.Meta() @@ -366,7 +366,7 @@ func (c *componentVersionAccessView) SetResourceAccess(art cpi.ResourceAccess, m } func (c *componentVersionAccessView) SetResource(meta *internal.ResourceMeta, acc compdesc.AccessSpec, modopts ...cpi.ModificationOption) error { - if c.base.IsReadOnly() { + if c.proxy.IsReadOnly() { return accessio.ErrReadOnly } @@ -375,11 +375,11 @@ func (c *componentVersionAccessView) SetResource(meta *internal.ResourceMeta, ac Access: acc, } - ctx := c.base.GetContext() + ctx := c.proxy.GetContext() opts := internal.NewModificationOptions(modopts...) cpi.CompleteModificationOptions(ctx, opts) - spec, err := c.base.GetContext().AccessSpecForSpec(acc) + spec, err := c.proxy.GetContext().AccessSpecForSpec(acc) if err != nil { return err } @@ -403,14 +403,14 @@ func (c *componentVersionAccessView) SetResource(meta *internal.ResourceMeta, ac } } - cd := c.base.GetDescriptor() + cd := c.proxy.GetDescriptor() idx := cd.GetResourceIndex(&res.ResourceMeta) if idx >= 0 { old = &cd.Resources[idx] } if old == nil { - if !opts.IsModifyResource() && c.base.IsPersistent() { + if !opts.IsModifyResource() && c.proxy.IsPersistent() { return fmt.Errorf("new resource would invalidate signature") } } @@ -456,7 +456,7 @@ func (c *componentVersionAccessView) SetResource(meta *internal.ResourceMeta, ac if old != nil { eq := res.Equivalent(old) - if !eq.IsLocalHashEqual() && c.base.IsPersistent() { + if !eq.IsLocalHashEqual() && c.proxy.IsPersistent() { if !opts.IsModifyResource() { return fmt.Errorf("resource would invalidate signature") } @@ -469,7 +469,7 @@ func (c *componentVersionAccessView) SetResource(meta *internal.ResourceMeta, ac } else { cd.Resources[idx] = *res } - return c.base.Update(false) + return c.proxy.Update(false) }) } @@ -500,7 +500,7 @@ func (c *componentVersionAccessView) evaluateResourceDigest(res, old *compdesc.R if !old.Digest.IsNone() { digester.HashAlgorithm = old.Digest.HashAlgorithm digester.NormalizationAlgorithm = old.Digest.NormalisationAlgorithm - if opts.IsAcceptExistentDigests() && !opts.IsModifyResource() && c.base.IsPersistent() { + if opts.IsAcceptExistentDigests() && !opts.IsModifyResource() && c.proxy.IsPersistent() { res.Digest = old.Digest value = old.Digest.Value } @@ -515,7 +515,7 @@ func (c *componentVersionAccessView) SetSourceByAccess(art cpi.SourceAccess) err } func (c *componentVersionAccessView) SetSource(meta *cpi.SourceMeta, acc compdesc.AccessSpec) error { - if c.base.IsReadOnly() { + if c.proxy.IsReadOnly() { return accessio.ErrReadOnly } @@ -525,40 +525,40 @@ func (c *componentVersionAccessView) SetSource(meta *cpi.SourceMeta, acc compdes } return c.Execute(func() error { if res.Version == "" { - res.Version = c.base.GetVersion() + res.Version = c.proxy.GetVersion() } - cd := c.base.GetDescriptor() + cd := c.proxy.GetDescriptor() if idx := cd.GetSourceIndex(&res.SourceMeta); idx == -1 { cd.Sources = append(cd.Sources, *res) } else { cd.Sources[idx] = *res } - return c.base.Update(false) + return c.proxy.Update(false) }) } func (c *componentVersionAccessView) SetReference(ref *cpi.ComponentReference) error { return c.Execute(func() error { - cd := c.base.GetDescriptor() + cd := c.proxy.GetDescriptor() if idx := cd.GetComponentReferenceIndex(*ref); idx == -1 { cd.References = append(cd.References, *ref) } else { cd.References[idx] = *ref } - return c.base.Update(false) + return c.proxy.Update(false) }) } func (c *componentVersionAccessView) DiscardChanges() { - c.base.DiscardChanges() + c.proxy.DiscardChanges() } func (c *componentVersionAccessView) IsPersistent() bool { - return c.base.IsPersistent() + return c.proxy.IsPersistent() } func (c *componentVersionAccessView) UseDirectAccess() bool { - return c.base.UseDirectAccess() + return c.proxy.UseDirectAccess() } //////////////////////////////////////////////////////////////////////////////// diff --git a/pkg/contexts/ocm/cpi/repocpi/view_r.go b/pkg/contexts/ocm/cpi/repocpi/view_r.go index 440fde63a5..f7073a3925 100644 --- a/pkg/contexts/ocm/cpi/repocpi/view_r.go +++ b/pkg/contexts/ocm/cpi/repocpi/view_r.go @@ -30,7 +30,7 @@ type _repositoryView interface { type RepositoryViewManager = resource.ViewManager[cpi.Repository] // here you have to use an alias -type RepositoryBase interface { +type RepositoryProxy interface { resource.ResourceImplementation[cpi.Repository] GetContext() cpi.Context @@ -47,7 +47,7 @@ type RepositoryBase interface { type repositoryView struct { _repositoryView - base RepositoryBase + proxy RepositoryProxy } var ( @@ -56,74 +56,74 @@ var ( _ utils.Unwrappable = (*repositoryView)(nil) ) -func GetRepositoryBase(n cpi.Repository) (RepositoryBase, error) { +func GetRepositoryProxy(n cpi.Repository) (RepositoryProxy, error) { if v, ok := n.(*repositoryView); ok { - return v.base, nil + return v.proxy, nil } return nil, errors.ErrNotSupported("repository implementation type", fmt.Sprintf("%T", n)) } func GetRepositoryImplementation(n cpi.Repository) (RepositoryImpl, error) { if v, ok := n.(*repositoryView); ok { - if b, ok := v.base.(*repositoryBase); ok { + if b, ok := v.proxy.(*repositoryProxy); ok { return b.impl, nil } - return nil, errors.ErrNotSupported("repository base type", fmt.Sprintf("%T", v.base)) + return nil, errors.ErrNotSupported("repository base type", fmt.Sprintf("%T", v.proxy)) } return nil, errors.ErrNotSupported("repository implementation type", fmt.Sprintf("%T", n)) } -func repositoryViewCreator(i RepositoryBase, v resource.CloserView, d RepositoryViewManager) cpi.Repository { +func repositoryViewCreator(i RepositoryProxy, v resource.CloserView, d RepositoryViewManager) cpi.Repository { return &repositoryView{ _repositoryView: resource.NewView[cpi.Repository](v, d), - base: i, + proxy: i, } } // NewNoneRefRepositoryView provides a repository reflecting the state of the // view manager without holding an additional reference. -func NewNoneRefRepositoryView(i RepositoryBase) cpi.Repository { +func NewNoneRefRepositoryView(i RepositoryProxy) cpi.Repository { return &repositoryView{ _repositoryView: resource.NewView[cpi.Repository](resource.NewNonRefView[cpi.Repository](i), i), - base: i, + proxy: i, } } func NewRepository(impl RepositoryImpl, kind string, closer ...io.Closer) cpi.Repository { - base := newRepositoryImplBase(impl, kind, closer...) + proxy := newRepositoryProxy(impl, kind, closer...) if kind == "" { kind = "OCM repository" } - return resource.NewResource[cpi.Repository](base, repositoryViewCreator, kind, true) + return resource.NewResource[cpi.Repository](proxy, repositoryViewCreator, kind, true) } func (r *repositoryView) Unwrap() interface{} { - return r.base + return r.proxy } func (r *repositoryView) GetConsumerId(uctx ...credentials.UsageContext) credentials.ConsumerIdentity { - return credentials.GetProvidedConsumerId(r.base, uctx...) + return credentials.GetProvidedConsumerId(r.proxy, uctx...) } func (r *repositoryView) GetIdentityMatcher() string { - return credentials.GetProvidedIdentityMatcher(r.base) + return credentials.GetProvidedIdentityMatcher(r.proxy) } func (r *repositoryView) GetSpecification() cpi.RepositorySpec { - return r.base.GetSpecification() + return r.proxy.GetSpecification() } func (r *repositoryView) GetContext() cpi.Context { - return r.base.GetContext() + return r.proxy.GetContext() } func (r *repositoryView) ComponentLister() cpi.ComponentLister { - return r.base.ComponentLister() + return r.proxy.ComponentLister() } func (r *repositoryView) ExistsComponentVersion(name string, version string) (ok bool, err error) { err = r.Execute(func() error { - ok, err = r.base.ExistsComponentVersion(name, version) + ok, err = r.proxy.ExistsComponentVersion(name, version) return err }) return ok, err @@ -131,7 +131,7 @@ func (r *repositoryView) ExistsComponentVersion(name string, version string) (ok func (r *repositoryView) LookupComponentVersion(name string, version string) (acc cpi.ComponentVersionAccess, err error) { err = r.Execute(func() error { - acc, err = r.base.LookupComponentVersion(name, version) + acc, err = r.proxy.LookupComponentVersion(name, version) return err }) return acc, err @@ -139,7 +139,7 @@ func (r *repositoryView) LookupComponentVersion(name string, version string) (ac func (r *repositoryView) LookupComponent(name string) (acc cpi.ComponentAccess, err error) { err = r.Execute(func() error { - acc, err = r.base.LookupComponent(name) + acc, err = r.proxy.LookupComponent(name) return err }) return acc, err diff --git a/pkg/contexts/ocm/repositories/comparch/componentarchive.go b/pkg/contexts/ocm/repositories/comparch/componentarchive.go index e2bdad11e6..37b01a1f5c 100644 --- a/pkg/contexts/ocm/repositories/comparch/componentarchive.go +++ b/pkg/contexts/ocm/repositories/comparch/componentarchive.go @@ -103,7 +103,7 @@ func (c *ComponentArchive) SetVersion(v string) { type componentArchiveContainer struct { ctx cpi.Context - base repocpi.ComponentVersionAccessBase + base repocpi.ComponentVersionAccessProxy fsacc *accessobj.FileSystemBlobAccess spec *RepositorySpec repo cpi.Repository @@ -111,11 +111,11 @@ type componentArchiveContainer struct { var _ repocpi.ComponentVersionAccessImpl = (*componentArchiveContainer)(nil) -func (c *componentArchiveContainer) SetBase(base repocpi.ComponentVersionAccessBase) { +func (c *componentArchiveContainer) SetProxy(base repocpi.ComponentVersionAccessProxy) { c.base = base } -func (c *componentArchiveContainer) GetParentBase() repocpi.ComponentAccessBase { +func (c *componentArchiveContainer) GetParentProxy() repocpi.ComponentAccessProxy { return nil } diff --git a/pkg/contexts/ocm/repositories/comparch/repository.go b/pkg/contexts/ocm/repositories/comparch/repository.go index 7240aefbde..c2c81fd957 100644 --- a/pkg/contexts/ocm/repositories/comparch/repository.go +++ b/pkg/contexts/ocm/repositories/comparch/repository.go @@ -26,7 +26,7 @@ import ( type RepositoryImpl struct { lock sync.RWMutex - base repocpi.RepositoryBase + base repocpi.RepositoryProxy arch *ComponentArchive nonref cpi.Repository } @@ -57,7 +57,7 @@ func (r *RepositoryImpl) Close() error { return r.arch.container.Close() } -func (r *RepositoryImpl) SetBase(base repocpi.RepositoryBase) { +func (r *RepositoryImpl) SetProxy(base repocpi.RepositoryProxy) { r.base = base r.nonref = repocpi.NewNoneRefRepositoryView(base) } @@ -143,7 +143,7 @@ func (r *RepositoryImpl) LookupComponent(name string) (*repocpi.ComponentAccessI //////////////////////////////////////////////////////////////////////////////// type ComponentAccessImpl struct { - base repocpi.ComponentAccessBase + base repocpi.ComponentAccessProxy repo *RepositoryImpl } @@ -160,11 +160,11 @@ func (c *ComponentAccessImpl) Close() error { return nil } -func (c *ComponentAccessImpl) SetBase(base repocpi.ComponentAccessBase) { +func (c *ComponentAccessImpl) SetProxy(base repocpi.ComponentAccessProxy) { c.base = base } -func (c *ComponentAccessImpl) GetParentBase() repocpi.RepositoryViewManager { +func (c *ComponentAccessImpl) GetParentProxy() repocpi.RepositoryViewManager { return c.repo.base } @@ -208,7 +208,7 @@ func (c *ComponentAccessImpl) NewVersion(version string, overrides ...bool) (*re //////////////////////////////////////////////////////////////////////////////// type ComponentVersionContainer struct { - impl repocpi.ComponentVersionAccessBase + impl repocpi.ComponentVersionAccessProxy comp *ComponentAccessImpl @@ -232,11 +232,11 @@ func newComponentVersionContainer(comp *ComponentAccessImpl) (*ComponentVersionC }, nil } -func (c *ComponentVersionContainer) SetBase(impl repocpi.ComponentVersionAccessBase) { +func (c *ComponentVersionContainer) SetProxy(impl repocpi.ComponentVersionAccessProxy) { c.impl = impl } -func (c *ComponentVersionContainer) GetParentBase() repocpi.ComponentAccessBase { +func (c *ComponentVersionContainer) GetParentProxy() repocpi.ComponentAccessProxy { return c.comp.base } diff --git a/pkg/contexts/ocm/repositories/genericocireg/component.go b/pkg/contexts/ocm/repositories/genericocireg/component.go index 22a57457da..acc87cf4ff 100644 --- a/pkg/contexts/ocm/repositories/genericocireg/component.go +++ b/pkg/contexts/ocm/repositories/genericocireg/component.go @@ -24,7 +24,7 @@ const META_SEPARATOR = ".build-" //////////////////////////////////////////////////////////////////////////////// type componentAccessImpl struct { - base repocpi.ComponentAccessBase + base repocpi.ComponentAccessProxy repo *RepositoryImpl name string namespace oci.NamespaceAccess @@ -54,11 +54,11 @@ func (c *componentAccessImpl) Close() error { return err } -func (c *componentAccessImpl) SetBase(base repocpi.ComponentAccessBase) { +func (c *componentAccessImpl) SetProxy(base repocpi.ComponentAccessProxy) { c.base = base } -func (c *componentAccessImpl) GetParentBase() repocpi.RepositoryViewManager { +func (c *componentAccessImpl) GetParentProxy() repocpi.RepositoryViewManager { return c.repo.base } diff --git a/pkg/contexts/ocm/repositories/genericocireg/componentversion.go b/pkg/contexts/ocm/repositories/genericocireg/componentversion.go index 725a1173e7..8657f65775 100644 --- a/pkg/contexts/ocm/repositories/genericocireg/componentversion.go +++ b/pkg/contexts/ocm/repositories/genericocireg/componentversion.go @@ -44,7 +44,7 @@ func newComponentVersionAccess(mode accessobj.AccessMode, comp *componentAccessI // ////////////////////////////////////////////////////////////////////////////// type ComponentVersionContainer struct { - impl repocpi.ComponentVersionAccessBase + impl repocpi.ComponentVersionAccessProxy comp *componentAccessImpl version string @@ -75,11 +75,11 @@ func newComponentVersionContainer(mode accessobj.AccessMode, comp *componentAcce }, nil } -func (c *ComponentVersionContainer) SetBase(impl repocpi.ComponentVersionAccessBase) { +func (c *ComponentVersionContainer) SetProxy(impl repocpi.ComponentVersionAccessProxy) { c.impl = impl } -func (c *ComponentVersionContainer) GetParentBase() repocpi.ComponentAccessBase { +func (c *ComponentVersionContainer) GetParentProxy() repocpi.ComponentAccessProxy { return c.comp.base } diff --git a/pkg/contexts/ocm/repositories/genericocireg/repository.go b/pkg/contexts/ocm/repositories/genericocireg/repository.go index 641ccb857b..9040e72e4a 100644 --- a/pkg/contexts/ocm/repositories/genericocireg/repository.go +++ b/pkg/contexts/ocm/repositories/genericocireg/repository.go @@ -40,7 +40,7 @@ func GetOCIRepository(r cpi.Repository) ocicpi.Repository { } type RepositoryImpl struct { - base repocpi.RepositoryBase + base repocpi.RepositoryProxy ctx cpi.Context meta ComponentRepositoryMeta nonref cpi.Repository @@ -65,7 +65,7 @@ func (r *RepositoryImpl) Close() error { return r.ocirepo.Close() } -func (r *RepositoryImpl) SetBase(base repocpi.RepositoryBase) { +func (r *RepositoryImpl) SetProxy(base repocpi.RepositoryProxy) { r.base = base r.nonref = repocpi.NewNoneRefRepositoryView(base) } diff --git a/pkg/contexts/ocm/repositories/virtual/component.go b/pkg/contexts/ocm/repositories/virtual/component.go index 5c434667a9..a930ba51f1 100644 --- a/pkg/contexts/ocm/repositories/virtual/component.go +++ b/pkg/contexts/ocm/repositories/virtual/component.go @@ -12,7 +12,7 @@ import ( ) type componentAccessImpl struct { - base repocpi.ComponentAccessBase + base repocpi.ComponentAccessProxy repo *RepositoryImpl name string @@ -32,11 +32,11 @@ func (c *componentAccessImpl) Close() error { return nil } -func (c *componentAccessImpl) SetBase(base repocpi.ComponentAccessBase) { +func (c *componentAccessImpl) SetProxy(base repocpi.ComponentAccessProxy) { c.base = base } -func (c *componentAccessImpl) GetParentBase() repocpi.RepositoryViewManager { +func (c *componentAccessImpl) GetParentProxy() repocpi.RepositoryViewManager { return c.repo.base } diff --git a/pkg/contexts/ocm/repositories/virtual/componentversion.go b/pkg/contexts/ocm/repositories/virtual/componentversion.go index f4ce58f882..0c9aa4fdd7 100644 --- a/pkg/contexts/ocm/repositories/virtual/componentversion.go +++ b/pkg/contexts/ocm/repositories/virtual/componentversion.go @@ -33,7 +33,7 @@ func newComponentVersionAccess(comp *componentAccessImpl, version string, persis // ////////////////////////////////////////////////////////////////////////////// type ComponentVersionContainer struct { - base repocpi.ComponentVersionAccessBase + base repocpi.ComponentVersionAccessProxy comp *componentAccessImpl version string @@ -50,11 +50,11 @@ func newComponentVersionContainer(comp *componentAccessImpl, version string, acc }, nil } -func (c *ComponentVersionContainer) SetBase(base repocpi.ComponentVersionAccessBase) { +func (c *ComponentVersionContainer) SetProxy(base repocpi.ComponentVersionAccessProxy) { c.base = base } -func (c *ComponentVersionContainer) GetParentBase() repocpi.ComponentAccessBase { +func (c *ComponentVersionContainer) GetParentProxy() repocpi.ComponentAccessProxy { return c.comp.base } diff --git a/pkg/contexts/ocm/repositories/virtual/repository.go b/pkg/contexts/ocm/repositories/virtual/repository.go index b9a79174ac..3071faffe2 100644 --- a/pkg/contexts/ocm/repositories/virtual/repository.go +++ b/pkg/contexts/ocm/repositories/virtual/repository.go @@ -10,7 +10,7 @@ import ( ) type RepositoryImpl struct { - base repocpi.RepositoryBase + base repocpi.RepositoryProxy ctx cpi.Context access Access nonref cpi.Repository @@ -30,7 +30,7 @@ func (r *RepositoryImpl) Close() error { return r.access.Close() } -func (r *RepositoryImpl) SetBase(base repocpi.RepositoryBase) { +func (r *RepositoryImpl) SetProxy(base repocpi.RepositoryProxy) { r.base = base r.nonref = repocpi.NewNoneRefRepositoryView(base) }