Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #148

Merged
merged 3 commits into from
Oct 14, 2022
Merged

Fixes #148

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/contexts/oci/repositories/artefactset/artefactset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
25 changes: 22 additions & 3 deletions pkg/contexts/oci/repositories/artefactset/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/contexts/ocm/accessmethods/github/method_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/contexts/ocm/accessmethods/s3/method_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/contexts/ocm/utils/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down