diff --git a/pkg/contexts/oci/repositories/artefactset/artefactset_test.go b/pkg/contexts/oci/repositories/artefactset/artefactset_test.go index ca0815df5..9911eb43a 100644 --- a/pkg/contexts/oci/repositories/artefactset/artefactset_test.go +++ b/pkg/contexts/oci/repositories/artefactset/artefactset_test.go @@ -56,6 +56,20 @@ var _ = Describe("artefact management", func() { vfs.Cleanup(tempfs) }) + It("creates with default format", func() { + a, err := artefactset.FormatDirectory.Create("test", opts, 0700) + Expect(err).To(Succeed()) + Expect(vfs.DirExists(tempfs, "test/"+artefactset.BlobsDirectoryName)).To(BeTrue()) + + defaultManifestFill(a) + + Expect(a.Close()).To(Succeed()) + + desc := artefactset.DescriptorFileName("") + Expect(vfs.FileExists(tempfs, "test/"+desc)).To(BeTrue()) + Expect(vfs.FileExists(tempfs, "test/"+artefactset.OCILayouFileName)).To(Equal(desc == artefactset.OCIArtefactSetDescriptorFileName)) + }) + TestForAllFormats("instantiate filesystem artefact", func(format string) { opts, err := accessio.AccessOptions(&artefactset.Options{}, opts, artefactset.StructureFormat(format)) Expect(err).To(Succeed()) diff --git a/pkg/contexts/oci/repositories/artefactset/format.go b/pkg/contexts/oci/repositories/artefactset/format.go index 9c7ef8286..310513457 100644 --- a/pkg/contexts/oci/repositories/artefactset/format.go +++ b/pkg/contexts/oci/repositories/artefactset/format.go @@ -117,15 +117,34 @@ func (a *accessObjectInfo) SetupFileSystem(fs vfs.FileSystem, mode vfs.FileMode) } func (a *accessObjectInfo) SetupFor(fs vfs.FileSystem) error { - ok, err := vfs.FileExists(fs, OCILayouFileName) + ok, err := vfs.FileExists(fs, OCIArtefactSetDescriptorFileName) if err != nil { return err } if ok { a.setOCI() - } else { //nolint: staticcheck // keep comment for else - // keep configured format + return nil } + + ok, err = vfs.FileExists(fs, ArtefactSetDescriptorFileName) + if err != nil { + return err + } + if ok { + a.setOCM() + return nil + } + + ok, err = vfs.FileExists(fs, OCILayouFileName) + if err != nil { + return err + } + if ok { + a.setOCI() + return nil + } + + // keep configured format return nil } diff --git a/pkg/contexts/ocm/accessmethods/github/method_test.go b/pkg/contexts/ocm/accessmethods/github/method_test.go index e2d5df886..59c7e9cfd 100644 --- a/pkg/contexts/ocm/accessmethods/github/method_test.go +++ b/pkg/contexts/ocm/accessmethods/github/method_test.go @@ -33,7 +33,6 @@ import ( "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/contexts/credentials" - "github.com/open-component-model/ocm/pkg/contexts/credentials/core" "github.com/open-component-model/ocm/pkg/contexts/datacontext" "github.com/open-component-model/ocm/pkg/contexts/datacontext/attrs/tmpcache" "github.com/open-component-model/ocm/pkg/contexts/datacontext/attrs/vfsattr" @@ -319,7 +318,7 @@ type mockCredentials struct { value func() string } -func (m *mockCredentials) Credentials(context core.Context, source ...core.CredentialsSource) (core.Credentials, error) { +func (m *mockCredentials) Credentials(context credentials.Context, source ...credentials.CredentialsSource) (credentials.Credentials, error) { panic("implement me") } diff --git a/pkg/contexts/ocm/accessmethods/s3/method_test.go b/pkg/contexts/ocm/accessmethods/s3/method_test.go index f48d6b9fb..3b4612990 100644 --- a/pkg/contexts/ocm/accessmethods/s3/method_test.go +++ b/pkg/contexts/ocm/accessmethods/s3/method_test.go @@ -32,7 +32,6 @@ import ( "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/common/accessio/downloader" "github.com/open-component-model/ocm/pkg/contexts/credentials" - "github.com/open-component-model/ocm/pkg/contexts/credentials/core" "github.com/open-component-model/ocm/pkg/contexts/datacontext" "github.com/open-component-model/ocm/pkg/contexts/datacontext/attrs/tmpcache" "github.com/open-component-model/ocm/pkg/contexts/datacontext/attrs/vfsattr" @@ -171,7 +170,7 @@ type mockCredentials struct { value map[string]string } -func (m *mockCredentials) Credentials(context core.Context, source ...core.CredentialsSource) (core.Credentials, error) { +func (m *mockCredentials) Credentials(context credentials.Context, source ...credentials.CredentialsSource) (credentials.Credentials, error) { panic("implement me") } diff --git a/pkg/contexts/ocm/utils/configure.go b/pkg/contexts/ocm/utils/configure.go index 0f58250c3..d9d5dee0f 100644 --- a/pkg/contexts/ocm/utils/configure.go +++ b/pkg/contexts/ocm/utils/configure.go @@ -93,11 +93,11 @@ func ConfigureByData(ctx ocm.Context, data []byte, info string) error { if err != nil { return errors.Wrapf(err, "processing ocm config %q", info) } - cfg, err := config.DefaultContext().GetConfigForData(data, nil) + cfg, err := ctx.ConfigContext().GetConfigForData(data, nil) if err != nil { return errors.Wrapf(err, "invalid ocm config file %q", info) } - err = config.DefaultContext().ApplyConfig(cfg, info) + err = ctx.ConfigContext().ApplyConfig(cfg, info) if err != nil { return errors.Wrapf(err, "cannot apply ocm config %q", info) }