diff --git a/.golangci.yaml b/.golangci.yaml index 0d3a603ef4..d4bf47be4f 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,13 +1,9 @@ run: - go: "1.21" timeout: 10m tests: false allow-parallel-runners: true issues-exit-code: 2 - skip-dirs: - - "hack" - # External code from containerd/containerd - - "pkg/docker" + linters: enable-all: true @@ -33,14 +29,13 @@ linters: - stylecheck # Too many issues. # No snake_case in Go. # convert_ComponentReferences_from should be convertComponentReferencesFrom - - nosnakecase - prealloc # Performance. - exportloopref - nilerr # There a few places where we don't return with an error # in an 'if err != nil {}' block. If it's intentional, # we should add a '//nolint: nilerr // Reason why...' - nlreturn # Use empty line at least before return/break/continue. - - goerr113 # Do not define dynamic errors with Errorf. + - err113 # Do not define dynamic errors with Errorf. - varnamelen # m, d, p < These are not so meaningful variables. - testpackage # Blackbox testing is preferred. - funlen # Break long functions. @@ -70,6 +65,9 @@ linters: - tagliatelle - wsl - interfacebloat + - inamedparam + - mnd + - perfsprint # Disabled with reason @@ -79,8 +77,10 @@ linters: - dogsled - exhaustruct # Doesn't really make sense. - exhaustive # Doesn't really make sense. - - logrlint # Doesn't really make sense. + - loggercheck # Doesn't really make sense. - goimports # acts weirdly, dci handles imports anyway + - intrange # Confusing, since manipulating a range variable in a loop does not change the number of + # iterations. Thus, an integer range is constant. # Disabled because of generics in go 1.18 - contextcheck @@ -88,17 +88,6 @@ linters: - sqlclosecheck - wastedassign - # Deprecated - - deadcode - - exhaustivestruct - - golint - - ifshort - - interfacer - - maligned - - scopelint - - structcheck - - varcheck - linters-settings: gci: sections: @@ -108,10 +97,6 @@ linters-settings: - default - prefix(github.com/open-component-model/ocm) custom-order: true - staticcheck: - go: "1.21" - stylecheck: - go: "1.21" funlen: lines: 110 statements: 60 @@ -119,7 +104,6 @@ linters-settings: max-complexity: 15 skip-tests: true nolintlint: - allow-leading-space: false allow-unused: false require-explanation: true require-specific: false @@ -128,8 +112,6 @@ linters-settings: - err - wg - id - govet: - check-shadowing: true lll: line-length: 120 gosec: @@ -139,6 +121,12 @@ linters-settings: - elseif issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-dirs: + - "hack" + # External code from containerd/containerd + - "pkg/docker" exclude: - composites exclude-rules: @@ -159,7 +147,7 @@ issues: - govet - path: _test\.go linters: - - goerr113 + - err113 - gocyclo - errcheck - gosec @@ -179,3 +167,4 @@ issues: - path: ignore/.*\.go linters: - dupword + diff --git a/Makefile b/Makefile index 2eca311ca6..4779168d14 100644 --- a/Makefile +++ b/Makefile @@ -46,31 +46,37 @@ install-requirements: .PHONY: prepare prepare: generate format generate-deepcopy build test check +EFFECTIVE_DIRECTORIES := $(REPO_ROOT)/cmds/ocm/... $(REPO_ROOT)/cmds/helminstaller/... $(REPO_ROOT)/cmds/ecrplugin/... $(REPO_ROOT)/cmds/demoplugin/... $(REPO_ROOT)/examples/... $(REPO_ROOT)/pkg/... + .PHONY: format format: - @$(REPO_ROOT)/hack/format.sh $(REPO_ROOT)/pkg $(REPO_ROOT)/cmds/ocm $(REPO_ROOT)/cmds/helminstaller $(REPO_ROOT)/cmds/ecrplugin $(REPO_ROOT)/cmds/demoplugin + @$(REPO_ROOT)/hack/format.sh $(EFFECTIVE_DIRECTORIES) .PHONY: check check: - @$(REPO_ROOT)/hack/check.sh --golangci-lint-config=./.golangci.yaml $(REPO_ROOT)/cmds/ocm $(REPO_ROOT)/cmds/helminstaller/... $(REPO_ROOT)/cmds/ecrplugin/... $(REPO_ROOT)/cmds/demoplugin/... $(REPO_ROOT)/pkg/... + @$(REPO_ROOT)/hack/check.sh --golangci-lint-config=./.golangci.yaml $(EFFECTIVE_DIRECTORIES) + +.PHONY: check-and-fix +check-and-fix: + @$(REPO_ROOT)/hack/check.sh --fix --golangci-lint-config=./.golangci.yaml $(EFFECTIVE_DIRECTORIES) .PHONY: force-test force-test: - @go test -parallel=1 --count=1 $(REPO_ROOT)/cmds/ocm $(REPO_ROOT)/cmds/helminstaller $(REPO_ROOT)/cmds/ocm/... $(REPO_ROOT)/cmds/ecrplugin/... $(REPO_ROOT)/cmds/demoplugin/... $(REPO_ROOT)/pkg/... + @go test --count=1 $(EFFECTIVE_DIRECTORIES) .PHONY: test test: - @echo "> Run Unit Tests" - @go test ./examples/lib/... $(REPO_ROOT)/cmds/ocm/... $(REPO_ROOT)/cmds/demoplugin/... $(REPO_ROOT)/pkg/... + @echo "> Run Tests" + @go test --tags=integration $(EFFECTIVE_DIRECTORIES) -.PHONY: test-all -test-all: install-requirements - @echo "> Run All Tests" - @go test --tags=integration ./examples/lib/... $(REPO_ROOT)/cmds/ocm/... $(REPO_ROOT)/cmds/demoplugin/... $(REPO_ROOT)/pkg/... +.PHONY: unit-test +unit-test: + @echo "> Run Unit Tests" + @go test $(EFFECTIVE_DIRECTORIES) .PHONY: generate generate: - @$(REPO_ROOT)/hack/generate.sh $(REPO_ROOT)/pkg/... $(REPO_ROOT)/cmds/ocm/... $(REPO_ROOT)/cmds/helminstaller/... $(REPO_ROOT)/examples/... + @$(REPO_ROOT)/hack/generate.sh $(EFFECTIVE_DIRECTORIES) .PHONY: generate-deepcopy generate-deepcopy: controller-gen diff --git a/cmds/demoplugin/valuesets/check_test.go b/cmds/demoplugin/valuesets/check_test.go index d3ba9389a8..9b76d00843 100644 --- a/cmds/demoplugin/valuesets/check_test.go +++ b/cmds/demoplugin/valuesets/check_test.go @@ -20,10 +20,12 @@ import ( "github.com/open-component-model/ocm/pkg/signing/handlers/rsa" ) -const ARCH = "/tmp/ctf" -const COMP = "acme.org/test" -const VERS = "1.0.0" -const PROV = "acme.org" +const ( + ARCH = "/tmp/ctf" + COMP = "acme.org/test" + VERS = "1.0.0" + PROV = "acme.org" +) var _ = Describe("demoplugin", func() { /* diff --git a/cmds/ocm/app/app.go b/cmds/ocm/app/app.go index 35a15c8d05..93358c7cb1 100644 --- a/cmds/ocm/app/app.go +++ b/cmds/ocm/app/app.go @@ -451,7 +451,7 @@ func NewVersionCommand(ctx clictx.Context) *cobra.Command { Run: func(_ *cobra.Command, _ []string) { v := version.Get() s := fmt.Sprintf("%#v", v) - out.Outf(ctx, "%s\n", prepare(s[strings.Index(s, "{"):])) + out.Outf(ctx, "%s\n", prepare(s[strings.Index(s, "{"):])) //nolint:gocritic // yes }, } } diff --git a/cmds/ocm/app/app_test.go b/cmds/ocm/app/app_test.go index 8781a7e125..16ada9f5f1 100644 --- a/cmds/ocm/app/app_test.go +++ b/cmds/ocm/app/app_test.go @@ -148,5 +148,4 @@ ERROR ctxerror realm ocm realm test attr = mapocirepoattr.Get(env.Context) Expect(attr.Mode).To(Equal(mapocirepoattr.ShortHashMode)) }) - }) diff --git a/cmds/ocm/commands/cachecmds/clean/cmd.go b/cmds/ocm/commands/cachecmds/clean/cmd.go index 25326ef9bc..6fefebc668 100644 --- a/cmds/ocm/commands/cachecmds/clean/cmd.go +++ b/cmds/ocm/commands/cachecmds/clean/cmd.go @@ -91,9 +91,7 @@ func (o *Command) Complete(args []string) error { } func (o *Command) Run() error { - cnt, ncnt, fcnt, size, nsize, fsize, err := o.cache.Cleanup(common.NewPrinter(o.Context.StdErr()), &o.before, o.dryrun) - if err != nil { return err } diff --git a/cmds/ocm/commands/common/options/failonerroroption/option.go b/cmds/ocm/commands/common/options/failonerroroption/option.go index bb41ee603d..5b322ada83 100644 --- a/cmds/ocm/commands/common/options/failonerroroption/option.go +++ b/cmds/ocm/commands/common/options/failonerroroption/option.go @@ -31,6 +31,7 @@ var _ options.Options = (*Option)(nil) func (o *Option) GetError() error { return o.err } + func (o *Option) SetError(err error) { o.err = err } @@ -42,7 +43,7 @@ func (o *Option) AddError(err error) { if o.err == nil { o.err = errors.ErrList().Add(err) } else { - if l, ok := o.err.(*errors.ErrorList); ok { + if l, ok := o.err.(*errors.ErrorList); ok { //nolint:errorlint // has to be of type ErrorList to call its method l.Add(err) } else { o.err = errors.ErrList().Add(o.err, err) diff --git a/cmds/ocm/commands/controllercmds/names/names.go b/cmds/ocm/commands/controllercmds/names/names.go index 94eca559a2..3b55313007 100644 --- a/cmds/ocm/commands/controllercmds/names/names.go +++ b/cmds/ocm/commands/controllercmds/names/names.go @@ -1,5 +1,3 @@ package names -var ( - Controller = []string{"controller"} -) +var Controller = []string{"controller"} diff --git a/cmds/ocm/commands/misccmds/hash/sign/cmd.go b/cmds/ocm/commands/misccmds/hash/sign/cmd.go index 9980ed83da..d2ee64f48c 100644 --- a/cmds/ocm/commands/misccmds/hash/sign/cmd.go +++ b/cmds/ocm/commands/misccmds/hash/sign/cmd.go @@ -72,7 +72,6 @@ func (o *Command) AddFlags(set *pflag.FlagSet) { set.StringVarP(&o.pubFile, "publicKey", "", "", "public key certificate file") set.StringVarP(&o.rootFile, "rootCerts", "", "", "root certificates file (deprecated)") set.StringArrayVarP(&o.rootCAs, "ca-cert", "", nil, "additional root certificate authorities (for signing certificates)") - } func (o *Command) Complete(args []string) error { diff --git a/cmds/ocm/commands/misccmds/hash/sign/cmd_test.go b/cmds/ocm/commands/misccmds/hash/sign/cmd_test.go index b35a326fbb..07ece2ede5 100644 --- a/cmds/ocm/commands/misccmds/hash/sign/cmd_test.go +++ b/cmds/ocm/commands/misccmds/hash/sign/cmd_test.go @@ -7,6 +7,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/open-component-model/ocm/cmds/ocm/testhelper" + "github.com/open-component-model/ocm/pkg/contexts/ocm/signing/signingtest" ) diff --git a/cmds/ocm/commands/misccmds/rsakeypair/cmd_test.go b/cmds/ocm/commands/misccmds/rsakeypair/cmd_test.go index 9bd4b02aaa..abd3e64d3e 100644 --- a/cmds/ocm/commands/misccmds/rsakeypair/cmd_test.go +++ b/cmds/ocm/commands/misccmds/rsakeypair/cmd_test.go @@ -38,7 +38,6 @@ var _ = Describe("Test Environment", func() { }) It("create key pair", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("create", "rsakeypair", "key.priv")).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext(` @@ -67,7 +66,6 @@ created rsa key pair key.priv[key.pub] }) It("create self-signed key pair", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("create", "rsakeypair", "key.priv", "CN=mandelsoft")).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext(` diff --git a/cmds/ocm/commands/ocicmds/artifacts/download/cmd.go b/cmds/ocm/commands/ocicmds/artifacts/download/cmd.go index 86fcd685d5..d7e44c667f 100644 --- a/cmds/ocm/commands/ocicmds/artifacts/download/cmd.go +++ b/cmds/ocm/commands/ocicmds/artifacts/download/cmd.go @@ -149,7 +149,8 @@ func (d *download) Save(o *artifacthdlr.Object, f string) error { return err } - if len(opts.Layers) > 0 { + switch { + case len(opts.Layers) > 0: var finalize finalizer.Finalizer defer finalize.Finalize() @@ -176,7 +177,7 @@ func (d *download) Save(o *artifacthdlr.Object, f string) error { if len(opts.Layers) > 1 { name = fmt.Sprintf("%s-%d", f, l) } - file, err := dest.PathFilesystem.OpenFile(name, vfs.O_CREATE|vfs.O_TRUNC|vfs.O_WRONLY, 0640) + file, err := dest.PathFilesystem.OpenFile(name, vfs.O_CREATE|vfs.O_TRUNC|vfs.O_WRONLY, 0o640) if err != nil { return errors.Wrapf(err, "cannot create target file %s for layer %d", name, l) } @@ -188,7 +189,7 @@ func (d *download) Save(o *artifacthdlr.Object, f string) error { out.Outf(d.opts.Context, "%s: layer %d: %d byte(s) downloaded\n", name, l, n) nested.Finalize() } - } else if opts.DirTree { + case opts.DirTree: format := formatoption.From(d.opts) if !art.IsManifest() { @@ -232,7 +233,7 @@ func (d *download) Save(o *artifacthdlr.Object, f string) error { } else { return accessio.CopyFileSystem(format.Format, fs, "/", dest.PathFilesystem, f, 0o640) } - } else { + default: blob, err := art.Blob() if err != nil { return err diff --git a/cmds/ocm/commands/ocicmds/artifacts/download/cmd_test.go b/cmds/ocm/commands/ocicmds/artifacts/download/cmd_test.go index 0049c64947..79c110c2dc 100644 --- a/cmds/ocm/commands/ocicmds/artifacts/download/cmd_test.go +++ b/cmds/ocm/commands/ocicmds/artifacts/download/cmd_test.go @@ -14,10 +14,12 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ctf" -const VERSION = "v1" -const NS = "mandelsoft/test" -const OUT = "/tmp/res" +const ( + ARCH = "/tmp/ctf" + VERSION = "v1" + NS = "mandelsoft/test" + OUT = "/tmp/res" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocicmds/artifacts/get/cmd_test.go b/cmds/ocm/commands/ocicmds/artifacts/get/cmd_test.go index 128dcbac7b..cc8216f4b5 100644 --- a/cmds/ocm/commands/ocicmds/artifacts/get/cmd_test.go +++ b/cmds/ocm/commands/ocicmds/artifacts/get/cmd_test.go @@ -14,11 +14,13 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ctf" -const VERSION1 = "v1" -const VERSION2 = "v2" -const NS1 = "mandelsoft/test" -const NS2 = "mandelsoft/index" +const ( + ARCH = "/tmp/ctf" + VERSION1 = "v1" + VERSION2 = "v2" + NS1 = "mandelsoft/test" + NS2 = "mandelsoft/index" +) var _ = Describe("Test Environment", func() { var env *TestEnv @@ -82,7 +84,6 @@ var _ = Describe("Test Environment", func() { }) It("get single artifacts", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("get", "artifact", ARCH+"//"+NS1+":"+VERSION1)).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext( @@ -92,7 +93,6 @@ REGISTRY REPOSITORY KIND TAG DIGEST `)) }) It("get all artifacts in namespace", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("get", "artifact", ARCH+"//"+NS1)).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext( @@ -263,6 +263,5 @@ NESTING REGISTRY REPOSITORY KIND TAG └─ /tmp/ctf mandelsoft/index manifest - sha256:60b245b3de64c43b18489e9c3cf177402f9bd18ab62f8cc6653e2fc2e3a5fc39 `)) }) - }) }) diff --git a/cmds/ocm/commands/ocicmds/artifacts/transfer/cmd_test.go b/cmds/ocm/commands/ocicmds/artifacts/transfer/cmd_test.go index b4c4555b75..ce2547755e 100644 --- a/cmds/ocm/commands/ocicmds/artifacts/transfer/cmd_test.go +++ b/cmds/ocm/commands/ocicmds/artifacts/transfer/cmd_test.go @@ -13,10 +13,12 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ctf" -const VERSION = "v1" -const NS = "mandelsoft/test" -const OUT = "/tmp/res" +const ( + ARCH = "/tmp/ctf" + VERSION = "v1" + NS = "mandelsoft/test" + OUT = "/tmp/res" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocicmds/ctf/create/cmd_test.go b/cmds/ocm/commands/ocicmds/ctf/create/cmd_test.go index da85ae1808..b99e6ad5a4 100644 --- a/cmds/ocm/commands/ocicmds/ctf/create/cmd_test.go +++ b/cmds/ocm/commands/ocicmds/ctf/create/cmd_test.go @@ -22,7 +22,6 @@ var _ = Describe("Test Environment", func() { }) It("creates common transport archive", func() { - Expect(env.Execute("create", "ctf", "-ft", "directory", ARCH)).To(Succeed()) Expect(env.DirExists(ARCH)).To(BeTrue()) Expect(env.ReadTextFile(env.Join(ARCH, ctf.ArtifactIndexFileName))).To(Equal("{\"schemaVersion\":1,\"artifacts\":null}")) diff --git a/cmds/ocm/commands/ocicmds/tags/show/cmd_test.go b/cmds/ocm/commands/ocicmds/tags/show/cmd_test.go index 9c42374265..b641b4f817 100644 --- a/cmds/ocm/commands/ocicmds/tags/show/cmd_test.go +++ b/cmds/ocm/commands/ocicmds/tags/show/cmd_test.go @@ -12,15 +12,17 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ctf" -const NAMESAPCE = "mandelsoft/test" -const V13 = "v1.3" -const V131 = "v1.3.1" -const V132 = "v1.3.2" -const V132x = "v1.3.2-beta.1" -const V14 = "v1.4" -const V2 = "v2.0" -const OTHERVERS = "sometag" +const ( + ARCH = "/tmp/ctf" + NAMESAPCE = "mandelsoft/test" + V13 = "v1.3" + V131 = "v1.3.1" + V132 = "v1.3.2" + V132x = "v1.3.2-beta.1" + V14 = "v1.4" + V2 = "v2.0" + OTHERVERS = "sometag" +) var _ = Describe("Show OCI Tags", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/cli/download/cmd_test.go b/cmds/ocm/commands/ocmcmds/cli/download/cmd_test.go index 6e9e4c402a..df4218ffd1 100644 --- a/cmds/ocm/commands/ocmcmds/cli/download/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/cli/download/cmd_test.go @@ -20,8 +20,10 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const CTF = "/tmp/ctf" -const OCM = "/testdata/bin/ocm" + download.EXECUTABLE_SUFFIX +const ( + CTF = "/tmp/ctf" + OCM = "/testdata/bin/ocm" + download.EXECUTABLE_SUFFIX +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/cli/download/const.go b/cmds/ocm/commands/ocmcmds/cli/download/const.go index eea3474fd9..92ebf68e0b 100644 --- a/cmds/ocm/commands/ocmcmds/cli/download/const.go +++ b/cmds/ocm/commands/ocmcmds/cli/download/const.go @@ -1,4 +1,6 @@ package download -const COMPONENT = "ocm.software/ocmcli" -const RESOURCE = "ocmcli" +const ( + COMPONENT = "ocm.software/ocmcli" + RESOURCE = "ocmcli" +) diff --git a/cmds/ocm/commands/ocmcmds/common/addhdlrs/srcs/elements.go b/cmds/ocm/commands/ocmcmds/common/addhdlrs/srcs/elements.go index b2d815b79d..976c168924 100644 --- a/cmds/ocm/commands/ocmcmds/common/addhdlrs/srcs/elements.go +++ b/cmds/ocm/commands/ocmcmds/common/addhdlrs/srcs/elements.go @@ -93,7 +93,7 @@ func (r *ResourceSpec) Validate(ctx clictx.Context, input *addhdlrs.ResourceInpu if err != nil { raw, _ := r.Access.GetRaw() allErrs = append(allErrs, field.Invalid(fldPath.Child("access"), string(raw), err.Error())) - } else if acc.(ocm.AccessSpec).IsLocal(ctx.OCMContext()) { + } else if acc.IsLocal(ctx.OCMContext()) { kind := runtime.GetKind(r.Access) allErrs = append(allErrs, field.Invalid(fldPath.Child("access", "type"), kind, "local access no possible")) } diff --git a/cmds/ocm/commands/ocmcmds/common/addhdlrs/utils.go b/cmds/ocm/commands/ocmcmds/common/addhdlrs/utils.go index 53743e4521..7833a3a073 100644 --- a/cmds/ocm/commands/ocmcmds/common/addhdlrs/utils.go +++ b/cmds/ocm/commands/ocmcmds/common/addhdlrs/utils.go @@ -12,14 +12,12 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/inputs" - "github.com/open-component-model/ocm/cmds/ocm/pkg/utils" + cliutils "github.com/open-component-model/ocm/cmds/ocm/pkg/utils" common2 "github.com/open-component-model/ocm/pkg/common" - "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/contexts/clictx" - "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/errkind" "github.com/open-component-model/ocm/pkg/runtime" - utils2 "github.com/open-component-model/ocm/pkg/utils" + "github.com/open-component-model/ocm/pkg/utils" "github.com/open-component-model/ocm/pkg/utils/template" ) @@ -38,7 +36,7 @@ func ProcessDescriptions(ctx clictx.Context, printer common2.Printer, templ temp if err != nil { return nil, nil, err } - ictx.Printf("found %d %s\n", len(elems), utils.Plural(h.Key(), len(elems))) + ictx.Printf("found %d %s\n", len(elems), cliutils.Plural(h.Key(), len(elems))) return elems, ictx, nil } @@ -76,10 +74,10 @@ func DetermineElementsForSource(ctx clictx.Context, ictx inputs.Context, templ t ictx := ictx.Section("processing document %d...", i) var list []json.RawMessage - listkey := utils.Plural(h.Key(), 0) + listkey := cliutils.Plural(h.Key(), 0) if reslist, ok := tmp[listkey]; ok { if len(tmp) != 1 { - return nil, errors.Newf("invalid %s spec %d: either a list or a single spec possible for %s (found keys %s)", h.Key(), i, listkey, utils2.StringMapKeys(tmp)) + return nil, errors.Newf("invalid %s spec %d: either a list or a single spec possible for %s (found keys %s)", h.Key(), i, listkey, utils.StringMapKeys(tmp)) } l, ok := reslist.([]interface{}) if !ok { @@ -97,7 +95,7 @@ func DetermineElementsForSource(ctx clictx.Context, ictx inputs.Context, templ t if entry, ok := tmp[h.Key()]; ok { if m, ok := entry.(map[string]interface{}); ok { if len(tmp) != 1 { - return nil, errors.Newf("invalid %s spec %d: either a list or a single spec possible for %s (found keys %s)", h.Key(), i, listkey, utils2.StringMapKeys(tmp)) + return nil, errors.Newf("invalid %s spec %d: either a list or a single spec possible for %s (found keys %s)", h.Key(), i, listkey, utils.StringMapKeys(tmp)) } tmp = m } @@ -196,7 +194,7 @@ func DecodeElement(data []byte, h ElementSpecHandler) (ElementSpec, error) { return nil, err } // delete(plainOrig, "input") - err = utils.CheckForUnknown(nil, plainOrig, plainAccepted).ToAggregate() + err = cliutils.CheckForUnknown(nil, plainOrig, plainAccepted).ToAggregate() return result, err } @@ -240,7 +238,7 @@ func CheckForUnknown(fldPath *field.Path, plainOrig, accepted interface{}) error if err != nil { return err } - return utils.CheckForUnknown(fldPath, plainOrig, plainAccepted).ToAggregate() + return cliutils.CheckForUnknown(fldPath, plainOrig, plainAccepted).ToAggregate() } func Validate(r *ResourceInput, ctx inputs.Context, inputFilePath string) error { @@ -260,12 +258,11 @@ func Validate(r *ResourceInput, ctx inputs.Context, inputFilePath string) error acc, err := r.Access.Evaluate(ctx.OCMContext()) if err != nil { if errors.IsErrUnknown(err) { - //nolint: errorlint // No way I can untagle this. err.(errors.Kinded).SetKind(errkind.KIND_ACCESSMETHOD) } raw, _ := r.Access.GetRaw() allErrs = append(allErrs, field.Invalid(fldPath.Child("access"), string(raw), err.Error())) - } else if acc.(ocm.AccessSpec).IsLocal(ctx.OCMContext()) { + } else if acc.IsLocal(ctx.OCMContext()) { kind := runtime.GetKind(r.Access) allErrs = append(allErrs, field.Invalid(fldPath.Child("access", "type"), kind, "local access no possible")) } @@ -319,7 +316,7 @@ func ValidateElementSpecIdentities(kind string, src string, elems []ElementSpec) func PrintElements(p common2.Printer, elems []Element, outfile string, fss ...vfs.FileSystem) error { if outfile != "" && outfile != "-" { - f, err := accessio.FileSystem(fss...).OpenFile(outfile, vfs.O_TRUNC|vfs.O_CREATE|vfs.O_WRONLY, 0o644) + f, err := utils.FileSystem(fss...).OpenFile(outfile, vfs.O_TRUNC|vfs.O_CREATE|vfs.O_WRONLY, 0o644) if err != nil { return errors.Wrapf(err, "cannot create output file %q", outfile) } diff --git a/cmds/ocm/commands/ocmcmds/common/handlers/comphdlr/typehandler.go b/cmds/ocm/commands/ocmcmds/common/handlers/comphdlr/typehandler.go index 36870c7997..8e11a6ed8a 100644 --- a/cmds/ocm/commands/ocmcmds/common/handlers/comphdlr/typehandler.go +++ b/cmds/ocm/commands/ocmcmds/common/handlers/comphdlr/typehandler.go @@ -135,7 +135,7 @@ func (h *TypeHandler) filterVersions(vers []string) ([]string, error) { } versions, err := semverutils.MatchVersionStrings(vers, h.constraints...) if err != nil { - return nil, fmt.Errorf("invalid constraints: %v", err) + return nil, fmt.Errorf("invalid constraints: %w", err) } if h.latest && len(versions) > 1 { versions = versions[len(versions)-1:] diff --git a/cmds/ocm/commands/ocmcmds/common/handlers/pluginhdlr/typehandler.go b/cmds/ocm/commands/ocmcmds/common/handlers/pluginhdlr/typehandler.go index b24da832ed..60ac67414b 100644 --- a/cmds/ocm/commands/ocmcmds/common/handlers/pluginhdlr/typehandler.go +++ b/cmds/ocm/commands/ocmcmds/common/handlers/pluginhdlr/typehandler.go @@ -76,7 +76,7 @@ func (h *TypeHandler) Get(elemspec utils.ElemSpec) ([]output.Object, error) { func Lookup(prefix string, cache plugins.Set) []output.Object { var objs []output.Object - prefix = prefix + "." + prefix += "." for _, n := range cache.PluginNames() { if strings.HasPrefix(n, prefix) { objs = append(objs, &Object{cache.Get(n)}) diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/inputtype.go b/cmds/ocm/commands/ocmcmds/common/inputs/inputtype.go index c0f9b085c9..1ea9305812 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/inputtype.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/inputtype.go @@ -96,8 +96,7 @@ func (*InputSpecBase) GetInputVersion(ctx Context) string { } type ( - InputSpecDecoder = runtime.TypedObjectDecoder[InputSpec] - _InputSpecDecoder = runtime.TypedObjectDecoder[InputSpec] + InputSpecDecoder = runtime.TypedObjectDecoder[InputSpec] ) type InputType interface { @@ -210,7 +209,7 @@ func (t *inputTypeScheme) GetInputType(name string) InputType { if d == nil { return nil } - return d.(InputType) + return d } func (t *inputTypeScheme) Register(rtype InputType) { @@ -231,7 +230,7 @@ func (t *inputTypeScheme) CreateInputSpec(obj runtime.TypedObject) (InputSpec, e if err != nil { return nil, err } - return r.(InputSpec), nil + return r, nil } if u, ok := obj.(*runtime.UnstructuredTypedObject); ok { raw, err := u.GetRaw() diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/options/standard.go b/cmds/ocm/commands/ocmcmds/common/inputs/options/standard.go index 74a22ddc28..32115ce96d 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/options/standard.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/options/standard.go @@ -22,45 +22,46 @@ var ( ExtensionOption = options.ExtensionOption ) -// string options +// string options. var ( VersionOption = flagsets.NewStringOptionType("inputVersion", "version info for inputs") TextOption = flagsets.NewStringOptionType("inputText", "utf8 text") HelmRepositoryOption = flagsets.NewStringOptionType("inputHelmRepository", "helm repository base URL") ) + var ( VariantsOption = flagsets.NewStringArrayOptionType("inputVariants", "(platform) variants for inputs") PlatformsOption = flagsets.NewStringArrayOptionType("inputPlatforms", "input filter for image platforms ([os]/[architecture])") ) -// path options +// path options. var ( PathOption = flagsets.NewPathOptionType("inputPath", "path field for input") ) + var ( IncludeOption = flagsets.NewPathArrayOptionType("inputIncludes", "includes (path) for inputs") ExcludeOption = flagsets.NewPathArrayOptionType("inputExcludes", "excludes (path) for inputs") LibrariesOption = flagsets.NewPathArrayOptionType("inputLibraries", "library path for inputs") ) -// boolean options +// boolean options. var ( CompressOption = flagsets.NewBoolOptionType("inputCompress", "compress option for input") PreserveDirOption = flagsets.NewBoolOptionType("inputPreserveDir", "preserve directory in archive for inputs") FollowSymlinksOption = flagsets.NewBoolOptionType("inputFollowSymlinks", "follow symbolic links during archive creation for inputs") ) -// data options +// data options. var ( DataOption = flagsets.NewBytesOptionType("inputData", "data (string, !!string or !") ) -// yaml/json options +// yaml/json options. var ( YAMLOption = flagsets.NewYAMLOptionType("inputYaml", "YAML formatted text") JSONOption = flagsets.NewYAMLOptionType("inputJson", "JSON formatted text") FormattedJSONOption = flagsets.NewYAMLOptionType("inputFormattedJson", "JSON formatted text") ) -var ( - ValuesOption = flagsets.NewValueMapYAMLOptionType("inputValues", "YAML based generic values for inputs") -) + +var ValuesOption = flagsets.NewValueMapYAMLOptionType("inputValues", "YAML based generic values for inputs") diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/testutils/testutils.go b/cmds/ocm/commands/ocmcmds/common/inputs/testutils/testutils.go index a0cbdf3b38..da70ac0578 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/testutils/testutils.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/testutils/testutils.go @@ -5,9 +5,9 @@ import ( . "github.com/onsi/gomega" + "github.com/mandelsoft/goutils/testutils" "github.com/spf13/pflag" - "github.com/mandelsoft/goutils/testutils" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/inputs" "github.com/open-component-model/ocm/pkg/cobrautils/flagsets" "github.com/open-component-model/ocm/pkg/runtime" diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/types/directory/inputtype_test.go b/cmds/ocm/commands/ocmcmds/common/inputs/types/directory/inputtype_test.go index 8045da8a6b..2840871e27 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/types/directory/inputtype_test.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/types/directory/inputtype_test.go @@ -11,8 +11,8 @@ import ( var _ = Describe("Input Type", func() { var env *InputTest - var True = true - var False = false + True := true + False := false BeforeEach(func() { env = NewInputTest(TYPE) @@ -40,5 +40,4 @@ var _ = Describe("Input Type", func() { FollowSymlinks: &True, }) }) - }) diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/types/docker/spec.go b/cmds/ocm/commands/ocmcmds/common/inputs/types/docker/spec.go index 78d4cfdee2..75e5c28992 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/types/docker/spec.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/types/docker/spec.go @@ -43,7 +43,7 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) { ctx.Printf("image %s\n", s.Path) - locator, version, err := docker.ParseGenericRef(s.Path) + locator, _, err := docker.ParseGenericRef(s.Path) if err != nil { return nil, "", err } diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/types/dockermulti/spec.go b/cmds/ocm/commands/ocmcmds/common/inputs/types/dockermulti/spec.go index e01530de5e..65186a3de4 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/types/dockermulti/spec.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/types/dockermulti/spec.go @@ -3,16 +3,12 @@ package dockermulti import ( "fmt" - . "github.com/mandelsoft/goutils/finalizer" "k8s.io/apimachinery/pkg/util/validation/field" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/inputs" ociartifact2 "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/inputs/types/ociartifact" "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/blobaccess/dockermulti" - "github.com/open-component-model/ocm/pkg/contexts/clictx" - "github.com/open-component-model/ocm/pkg/contexts/oci" - "github.com/open-component-model/ocm/pkg/contexts/oci/repositories/artifactset" "github.com/open-component-model/ocm/pkg/contexts/oci/repositories/docker" "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact" "github.com/open-component-model/ocm/pkg/runtime" @@ -62,34 +58,6 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s return allErrs } -func (s *Spec) getVariant(ctx clictx.Context, finalize *Finalizer, variant string) (oci.ArtifactAccess, error) { - locator, version, err := docker.ParseGenericRef(variant) - if err != nil { - return nil, err - } - if version == "" { - return nil, fmt.Errorf("artifact version required") - } - spec := docker.NewRepositorySpec() - repo, err := ctx.OCIContext().RepositoryForSpec(spec) - if err != nil { - return nil, err - } - finalize.Close(repo) - ns, err := repo.LookupNamespace(locator) - if err != nil { - return nil, err - } - finalize.Close(ns) - - art, err := ns.GetArtifact(version) - if err != nil { - return nil, artifactset.GetArtifactError{Original: err, Ref: locator + ":" + version} - } - finalize.Close(art) - return art, nil -} - func (s *Spec) GetBlob(ctx inputs.Context, info inputs.InputResourceInfo) (blobaccess.BlobAccess, string, error) { blob, err := dockermulti.BlobAccess( dockermulti.WithContext(ctx), diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/types/helm/spec.go b/cmds/ocm/commands/ocmcmds/common/inputs/types/helm/spec.go index 77835344d3..82bb855020 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/types/helm/spec.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/types/helm/spec.go @@ -51,11 +51,12 @@ func (s *Spec) Validate(fldPath *field.Path, ctx inputs.Context, inputFilePath s if s.CACertFile != "" { path = fldPath.Child("caCertFile") inputInfo, filePath, err := inputs.FileInfo(ctx, s.CACertFile, inputFilePath) - if err != nil { + switch { + case err != nil: allErrs = append(allErrs, field.Invalid(path, filePath, err.Error())) - } else if !inputInfo.Mode().IsRegular() { + case !inputInfo.Mode().IsRegular(): allErrs = append(allErrs, field.Invalid(path, filePath, "caCertFile is no regular file")) - } else { + default: _, err = LoadCertificateBundle(s.CACertFile, ctx.FileSystem()) if err != nil { allErrs = append(allErrs, field.Invalid(path, s.CACertFile, err.Error())) diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/types/maven/input_test.go b/cmds/ocm/commands/ocmcmds/common/inputs/types/maven/input_test.go index 41d6210a00..98c07166bd 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/types/maven/input_test.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/types/maven/input_test.go @@ -3,8 +3,6 @@ package maven_test import ( "crypto" - "github.com/open-component-model/ocm/pkg/maven/maventest" - . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -13,6 +11,7 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/localblob" "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc" "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/comparch" + "github.com/open-component-model/ocm/pkg/maven/maventest" "github.com/open-component-model/ocm/pkg/mime" "github.com/open-component-model/ocm/pkg/utils/tarutils" ) diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/types/ociartifact/input_test.go b/cmds/ocm/commands/ocmcmds/common/inputs/types/ociartifact/input_test.go index a18e36ed48..65e1f80a72 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/types/ociartifact/input_test.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/types/ociartifact/input_test.go @@ -24,11 +24,13 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ctf" ) -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" -const ARCH = "/tmp/ctf" -const VERSION = "1.0.0" -const COMPONENT = "ocm.software/demo/test" +const ( + OCIPATH = "/tmp/oci" + OCIHOST = "alias" + ARCH = "/tmp/ctf" + VERSION = "1.0.0" + COMPONENT = "ocm.software/demo/test" +) func CheckComponent(env *TestEnv) { repo := Must(ctf.Open(env.OCMContext(), accessobj.ACC_READONLY, ARCH, 0, env)) diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/types/ociartifact/type.go b/cmds/ocm/commands/ocmcmds/common/inputs/types/ociartifact/type.go index 8b9188d5e6..68374686c2 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/types/ociartifact/type.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/types/ociartifact/type.go @@ -4,8 +4,10 @@ import ( "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/inputs" ) -const TYPE = "ociArtifact" -const LEGACY_TYPE = "ociImage" +const ( + TYPE = "ociArtifact" + LEGACY_TYPE = "ociImage" +) func init() { inputs.DefaultInputTypeScheme.Register(inputs.NewInputType(TYPE, &Spec{}, usage, ConfigHandler())) diff --git a/cmds/ocm/commands/ocmcmds/common/inputs/types/spiff/spiff_test.go b/cmds/ocm/commands/ocmcmds/common/inputs/types/spiff/spiff_test.go index f3ef038177..f32af1955d 100644 --- a/cmds/ocm/commands/ocmcmds/common/inputs/types/spiff/spiff_test.go +++ b/cmds/ocm/commands/ocmcmds/common/inputs/types/spiff/spiff_test.go @@ -70,6 +70,5 @@ bob: 26 alice: 24 bob: 26 `)) - }) }) diff --git a/cmds/ocm/commands/ocmcmds/common/options/dryrunoption/option.go b/cmds/ocm/commands/ocmcmds/common/options/dryrunoption/option.go index a0a5c25605..fc90ca9445 100644 --- a/cmds/ocm/commands/ocmcmds/common/options/dryrunoption/option.go +++ b/cmds/ocm/commands/ocmcmds/common/options/dryrunoption/option.go @@ -30,6 +30,7 @@ func New(usage string, out bool) *Option { usage: usage, } } + func (o *Option) AddFlags(fs *pflag.FlagSet) { fs.BoolVarP(&o.DryRun, "dry-run", "", false, o.usage) if o.out { diff --git a/cmds/ocm/commands/ocmcmds/common/options/fileoption/option.go b/cmds/ocm/commands/ocmcmds/common/options/fileoption/option.go index f29f6a3c1b..082ae8cbe0 100644 --- a/cmds/ocm/commands/ocmcmds/common/options/fileoption/option.go +++ b/cmds/ocm/commands/ocmcmds/common/options/fileoption/option.go @@ -9,8 +9,8 @@ import ( "github.com/open-component-model/ocm/cmds/ocm/pkg/options" "github.com/open-component-model/ocm/pkg/cobrautils/flag" - "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/compression" + "github.com/open-component-model/ocm/pkg/utils" ) func From(o options.OptionSetProvider) *Option { @@ -54,7 +54,7 @@ func (o *Option) GetPath(args []string, fss ...vfs.FileSystem) (string, []string return o.Path, args } - fs := accessio.FileSystem(fss...) + fs := utils.FileSystem(fss...) if ok, err := vfs.Exists(fs, args[0]); !ok || err != nil { return o.Path, args } diff --git a/cmds/ocm/commands/ocmcmds/common/options/scriptoption/config.go b/cmds/ocm/commands/ocmcmds/common/options/scriptoption/config.go index b25e56c8c4..b85962310d 100644 --- a/cmds/ocm/commands/ocmcmds/common/options/scriptoption/config.go +++ b/cmds/ocm/commands/ocmcmds/common/options/scriptoption/config.go @@ -6,7 +6,6 @@ import ( "github.com/mandelsoft/goutils/errors" "github.com/mandelsoft/vfs/pkg/vfs" - "github.com/open-component-model/ocm/pkg/common/accessio" cfgcpi "github.com/open-component-model/ocm/pkg/contexts/config/cpi" "github.com/open-component-model/ocm/pkg/runtime" "github.com/open-component-model/ocm/pkg/utils" @@ -79,7 +78,7 @@ func (a *Config) ApplyTo(ctx cfgcpi.Context, target interface{}) error { if spec.Path == "" { return errors.Newf("script or path must be set for entry %q", t.Script) } - data, err := utils.ReadFile(spec.Path, accessio.FileSystem(spec.FileSystem, t.FileSystem)) + data, err := utils.ReadFile(spec.Path, utils.FileSystem(spec.FileSystem, t.FileSystem)) if err != nil { return errors.Wrapf(err, "script file %q", spec.Path) } diff --git a/cmds/ocm/commands/ocmcmds/common/options/skipdigestoption/option.go b/cmds/ocm/commands/ocmcmds/common/options/skipdigestoption/option.go index 94ac9e5531..e6052a34b5 100644 --- a/cmds/ocm/commands/ocmcmds/common/options/skipdigestoption/option.go +++ b/cmds/ocm/commands/ocmcmds/common/options/skipdigestoption/option.go @@ -41,6 +41,6 @@ assure a proper transport behaviour. func (o *Option) ApplyModificationOption(opts *ocm.ModificationOptions) { if o.flag == nil || o.flag.Changed { - ocm.SkipDigest(o.Skip).ApplyModificationOption(opts) + ocm.SkipDigest(o.Skip).ApplyModificationOption(opts) //nolint:staticcheck // skip digest still used for tests } } diff --git a/cmds/ocm/commands/ocmcmds/common/options/skipupdateoption/option.go b/cmds/ocm/commands/ocmcmds/common/options/skipupdateoption/option.go index 23bf3ef97b..39fece1c67 100644 --- a/cmds/ocm/commands/ocmcmds/common/options/skipupdateoption/option.go +++ b/cmds/ocm/commands/ocmcmds/common/options/skipupdateoption/option.go @@ -1,8 +1,6 @@ package skipupdateoption import ( - "fmt" - "github.com/spf13/pflag" "github.com/open-component-model/ocm/cmds/ocm/pkg/options" @@ -42,12 +40,12 @@ func (o *Option) AddFlags(fs *pflag.FlagSet) { } func (o *Option) Usage() string { - return fmt.Sprintf(` + return ` With the option --no-update existing versions in the target repository will not be touched at all. An additional specification of the option --overwrite is ignored. By default, updates of volative (non-signature-relevant) information is enabled, but the modification of non-volatile data is prohibited unless the overwrite option is given. -`) +` } diff --git a/cmds/ocm/commands/ocmcmds/common/options/versionconstraintsoption/option.go b/cmds/ocm/commands/ocmcmds/common/options/versionconstraintsoption/option.go index 8a101cf9f4..183ef82439 100644 --- a/cmds/ocm/commands/ocmcmds/common/options/versionconstraintsoption/option.go +++ b/cmds/ocm/commands/ocmcmds/common/options/versionconstraintsoption/option.go @@ -38,7 +38,6 @@ func (o *Option) SetLatest(latest ...bool) *Option { } func (o *Option) Usage() string { - s := ` If the option --constraints is given, and no version is specified for a component, only versions matching the given version constraints diff --git a/cmds/ocm/commands/ocmcmds/common/resources_test.go b/cmds/ocm/commands/ocmcmds/common/resources_test.go index 9a3fd4bdf6..0151465326 100644 --- a/cmds/ocm/commands/ocmcmds/common/resources_test.go +++ b/cmds/ocm/commands/ocmcmds/common/resources_test.go @@ -8,7 +8,6 @@ import ( ) var _ = Describe("Blob Inputs", func() { - It("missing input", func() { in := ` access: diff --git a/cmds/ocm/commands/ocmcmds/componentarchive/create/cmd_test.go b/cmds/ocm/commands/ocmcmds/componentarchive/create/cmd_test.go index 9f542f7ff6..25e10efb18 100644 --- a/cmds/ocm/commands/ocmcmds/componentarchive/create/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/componentarchive/create/cmd_test.go @@ -49,7 +49,6 @@ var _ = Describe("Test Environment", func() { }) It("creates comp arch", func() { - plabels := metav1.Labels{} plabels.Set("email", "info@mandelsoft.de") Expect(env.Execute("create", "ca", "-ft", "directory", "test.de/x", "v1", "--provider", "mandelsoft", "--file", "/tmp/ca", @@ -76,7 +75,6 @@ var _ = Describe("Test Environment", func() { }) It("creates comp arch with "+compdescv3.VersionName, func() { - plabels := metav1.Labels{} plabels.Set("email", "info@mandelsoft.de") Expect(env.Execute("create", "ca", "-ft", "directory", "test.de/x", "v1", "--provider", "mandelsoft", "--file", "/tmp/ca", diff --git a/cmds/ocm/commands/ocmcmds/components/add/cmd.go b/cmds/ocm/commands/ocmcmds/components/add/cmd.go index ba592a16f5..a09e61f025 100644 --- a/cmds/ocm/commands/ocmcmds/components/add/cmd.go +++ b/cmds/ocm/commands/ocmcmds/components/add/cmd.go @@ -2,7 +2,6 @@ package add import ( "fmt" - "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/options/uploaderoption" "github.com/mandelsoft/goutils/errors" "github.com/mandelsoft/goutils/general" @@ -20,6 +19,7 @@ import ( "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/options/rscbyvalueoption" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/options/schemaoption" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/options/templateroption" + "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/options/uploaderoption" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/names" "github.com/open-component-model/ocm/cmds/ocm/commands/verbs" "github.com/open-component-model/ocm/cmds/ocm/pkg/utils" @@ -58,15 +58,16 @@ type Command struct { } func NewCommand(ctx clictx.Context, names ...string) *cobra.Command { - return utils.SetupCommand(&Command{BaseCommand: utils.NewBaseCommand(ctx, - formatoption.New(ctf.GetFormats()...), - fileoption.New("transport-archive"), - schemaoption.New(compdesc.DefaultSchemeVersion), - templateroption.New(""), - dryrunoption.New("evaluate and print component specifications", true), - lookupoption.New(), - rscbyvalueoption.New(), - uploaderoption.New(ctx.OCMContext())), + return utils.SetupCommand(&Command{ + BaseCommand: utils.NewBaseCommand(ctx, + formatoption.New(ctf.GetFormats()...), + fileoption.New("transport-archive"), + schemaoption.New(compdesc.DefaultSchemeVersion), + templateroption.New(""), + dryrunoption.New("evaluate and print component specifications", true), + lookupoption.New(), + rscbyvalueoption.New(), + uploaderoption.New(ctx.OCMContext())), }, utils.Names(Names, names...)...) } diff --git a/cmds/ocm/commands/ocmcmds/components/add/cmd_test.go b/cmds/ocm/commands/ocmcmds/components/add/cmd_test.go index 761ade29c0..f22681e758 100644 --- a/cmds/ocm/commands/ocmcmds/components/add/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/components/add/cmd_test.go @@ -23,15 +23,17 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" -const ARCH = "/tmp/ctf" -const LOOKUP = "/tmp/lookup" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENT = "github.com/mandelsoft/test" -const COMPONENT2 = "github.com/mandelsoft/test2" -const OUT = "/tmp/res" +const ( + OCIPATH = "/tmp/oci" + OCIHOST = "alias" + ARCH = "/tmp/ctf" + LOOKUP = "/tmp/lookup" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENT = "github.com/mandelsoft/test" + COMPONENT2 = "github.com/mandelsoft/test2" + OUT = "/tmp/res" +) func CheckComponent(env *TestEnv, handler func(ocm.Repository)) { repo := Must(ctf.Open(env.OCMContext(), accessobj.ACC_READONLY, ARCH, 0, env)) diff --git a/cmds/ocm/commands/ocmcmds/components/check/cmd_test.go b/cmds/ocm/commands/ocmcmds/components/check/cmd_test.go index 61b399f871..8de3772eb2 100644 --- a/cmds/ocm/commands/ocmcmds/components/check/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/components/check/cmd_test.go @@ -15,12 +15,14 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/resourcetypes" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const COMP = "test.de/x" -const COMP2 = "test.de/y" -const COMP3 = "test.de/z" -const COMP4 = "test.de/a" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + COMP = "test.de/x" + COMP2 = "test.de/y" + COMP3 = "test.de/z" + COMP4 = "test.de/a" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/components/check/options.go b/cmds/ocm/commands/ocmcmds/components/check/options.go index 18f8b6c1cd..83c6260be4 100644 --- a/cmds/ocm/commands/ocmcmds/components/check/options.go +++ b/cmds/ocm/commands/ocmcmds/components/check/options.go @@ -37,8 +37,8 @@ func (o *Option) AddFlags(fs *pflag.FlagSet) { func (o *Option) Usage() string { s := ` -If the options --local-resources and/or --local-sources are given the -the check additionally assures that all resources or sources are included into the component version. +If the options --local-resources and/or --local-sources are given the +check additionally assures that all resources or sources are included into the component version. This means that they are using local access methods, only. ` return s diff --git a/cmds/ocm/commands/ocmcmds/components/download/cmd_test.go b/cmds/ocm/commands/ocmcmds/components/download/cmd_test.go index d26050532f..6a971168c5 100644 --- a/cmds/ocm/commands/ocmcmds/components/download/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/components/download/cmd_test.go @@ -19,11 +19,13 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ctf" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENT = "github.com/mandelsoft/test" -const OUT = "/tmp/res" +const ( + ARCH = "/tmp/ctf" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENT = "github.com/mandelsoft/test" + OUT = "/tmp/res" +) var _ = Describe("Download Component Version", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/components/get/cmd.go b/cmds/ocm/commands/ocmcmds/components/get/cmd.go index 6f81005db9..09fbed63b7 100644 --- a/cmds/ocm/commands/ocmcmds/components/get/cmd.go +++ b/cmds/ocm/commands/ocmcmds/components/get/cmd.go @@ -133,7 +133,7 @@ func Format(opts *output.Options) processing.ProcessChain { if schema == "" { schema = compdescv2.SchemaVersion } - out, err := compdesc.Convert(desc, compdesc.SchemaVersion(o.Schema)) + out, err := compdesc.Convert(desc, compdesc.SchemaVersion(schema)) if err != nil { return &FailedEntry{ Scheme: desc.SchemaVersion(), diff --git a/cmds/ocm/commands/ocmcmds/components/get/cmd_test.go b/cmds/ocm/commands/ocmcmds/components/get/cmd_test.go index d95e8e1a74..c47627e935 100644 --- a/cmds/ocm/commands/ocmcmds/components/get/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/components/get/cmd_test.go @@ -13,15 +13,17 @@ import ( compdescv3 "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/versions/ocm.software/v3alpha1" ) -const ARCH = "/tmp/ca" -const ARCH2 = "/tmp/ca2" -const VERSION = "v1" -const VERSION11 = "v1.1" -const VERSION2 = "v2" -const COMP = "test.de/x" -const COMP2 = "test.de/y" -const COMP3 = "test.de/z" -const PROVIDER = "mandelsoft" +const ( + ARCH = "/tmp/ca" + ARCH2 = "/tmp/ca2" + VERSION = "v1" + VERSION11 = "v1.1" + VERSION2 = "v2" + COMP = "test.de/x" + COMP2 = "test.de/y" + COMP3 = "test.de/z" + PROVIDER = "mandelsoft" +) var _ = Describe("Test Environment", func() { var env *TestEnv @@ -161,7 +163,6 @@ COMPONENT VERSION PROVIDER test.de/x v1.1 mandelsoft `)) }) - }) Context("ctf", func() { @@ -183,7 +184,6 @@ test.de/x v1.1 mandelsoft }) }) It("lists closure ctf file", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("get", "components", "--lookup", ARCH2, "-r", "--repo", ARCH, COMP2)).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext( @@ -194,7 +194,6 @@ test.de/y:v1 test.de/x v1 mandelsoft "name"="xx" `)) }) It("lists flat ctf file", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("get", "components", "-o", "tree", "--repo", ARCH, COMP2)).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext( @@ -204,7 +203,6 @@ NESTING COMPONENT VERSION PROVIDER `)) }) It("lists flat ctf file with closure", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("get", "components", "-o", "tree", "--lookup", ARCH2, "-r", "--repo", ARCH, COMP2)).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext( @@ -216,7 +214,6 @@ NESTING COMPONENT VERSION PROVIDER IDENTITY }) It("lists converted yaml", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("get", "components", "-S", compdescv3.VersionName, "-o", "yaml", "--repo", ARCH, COMP2)).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext( diff --git a/cmds/ocm/commands/ocmcmds/components/hash/cmd.go b/cmds/ocm/commands/ocmcmds/components/hash/cmd.go index 9c5730639f..902359e76e 100644 --- a/cmds/ocm/commands/ocmcmds/components/hash/cmd.go +++ b/cmds/ocm/commands/ocmcmds/components/hash/cmd.go @@ -179,9 +179,7 @@ func (h *action) Close() error { func (h *action) Out() error { if len(h.norms) > 1 { dir := h.mode.outfile - if strings.HasSuffix(dir, ".ncd") { - dir = dir[:len(dir)-4] - } + dir = strings.TrimSuffix(dir, ".ncd") err := h.ctx.FileSystem().Mkdir(dir, 0o755) if err != nil { return fmt.Errorf("cannot create output dir %s", dir) @@ -249,7 +247,7 @@ func (h *action) _manifester(e interface{}) *Manifest { if p.Descriptor == nil { if p.Error == nil { - m.Error = fmt.Sprintf("") + m.Error = "" } else { m.Error = p.Error.Error() } diff --git a/cmds/ocm/commands/ocmcmds/components/hash/cmd_test.go b/cmds/ocm/commands/ocmcmds/components/hash/cmd_test.go index 4732c481e8..45e037a7eb 100644 --- a/cmds/ocm/commands/ocmcmds/components/hash/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/components/hash/cmd_test.go @@ -15,10 +15,12 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const COMP = "test.de/x" -const PROVIDER = "mandelsoft" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + COMP = "test.de/x" + PROVIDER = "mandelsoft" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/components/list/cmd.go b/cmds/ocm/commands/ocmcmds/components/list/cmd.go index 66d8e45326..3d3b20652c 100644 --- a/cmds/ocm/commands/ocmcmds/components/list/cmd.go +++ b/cmds/ocm/commands/ocmcmds/components/list/cmd.go @@ -6,7 +6,6 @@ import ( "github.com/spf13/cobra" ocmcommon "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common" - "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/handlers/comphdlr" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/handlers/vershdlr" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/options/lookupoption" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/options/repooption" @@ -82,11 +81,6 @@ func (o *Command) Run() error { ///////////////////////////////////////////////////////////////////////////// -func addIdentityField(e interface{}) []string { - p := e.(*comphdlr.Object) - return []string{p.Identity.String()} -} - func TableOutput(opts *output.Options, mapping processing.MappingFunction) *output.TableOutput { return &output.TableOutput{ Headers: output.Fields("COMPONENT", "VERSION", "MESSAGE"), diff --git a/cmds/ocm/commands/ocmcmds/components/list/cmd_test.go b/cmds/ocm/commands/ocmcmds/components/list/cmd_test.go index efb3edb845..09fc293687 100644 --- a/cmds/ocm/commands/ocmcmds/components/list/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/components/list/cmd_test.go @@ -12,15 +12,17 @@ import ( "github.com/open-component-model/ocm/pkg/common/accessio" ) -const ARCH = "/tmp/ca" -const ARCH2 = "/tmp/ca2" -const VERSION = "v1" -const VERSION11 = "v1.1" -const VERSION2 = "v2" -const COMP = "test.de/x" -const COMP2 = "test.de/y" -const COMP3 = "test.de/z" -const PROVIDER = "mandelsoft" +const ( + ARCH = "/tmp/ca" + ARCH2 = "/tmp/ca2" + VERSION = "v1" + VERSION11 = "v1.1" + VERSION2 = "v2" + COMP = "test.de/x" + COMP2 = "test.de/y" + COMP3 = "test.de/z" + PROVIDER = "mandelsoft" +) var _ = Describe("Test Environment", func() { var env *TestEnv @@ -143,7 +145,6 @@ COMPONENT VERSION MESSAGE test.de/x v1.1 `)) }) - }) Context("ctf", func() { diff --git a/cmds/ocm/commands/ocmcmds/components/sign/cmd_test.go b/cmds/ocm/commands/ocmcmds/components/sign/cmd_test.go index 9b311d90b9..e8fdad0b6c 100644 --- a/cmds/ocm/commands/ocmcmds/components/sign/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/components/sign/cmd_test.go @@ -26,25 +26,33 @@ import ( "github.com/open-component-model/ocm/pkg/signing/signutils" ) -const COMPARCH = "/tmp/ca" -const ARCH = "/tmp/ctf" -const ARCH2 = "/tmp/ctf2" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENTA = "github.com/mandelsoft/test" -const COMPONENTB = "github.com/mandelsoft/ref" -const OUT = "/tmp/res" -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" - -const SIGNATURE = "test" -const SIGN_ALGO = rsa.Algorithm - -const PUBKEY = "/tmp/pub" -const PRIVKEY = "/tmp/priv" - -const D_COMPONENTA = "01de99400030e8336020059a435cea4e7fe8f21aad4faf619da882134b85569d" -const D_COMPONENTB = "5f416ec59629d6af91287e2ba13c6360339b6a0acf624af2abd2a810ce4aefce" +const ( + COMPARCH = "/tmp/ca" + ARCH = "/tmp/ctf" + ARCH2 = "/tmp/ctf2" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENTA = "github.com/mandelsoft/test" + COMPONENTB = "github.com/mandelsoft/ref" + OUT = "/tmp/res" + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) + +const ( + SIGNATURE = "test" + SIGN_ALGO = rsa.Algorithm +) + +const ( + PUBKEY = "/tmp/pub" + PRIVKEY = "/tmp/priv" +) + +const ( + D_COMPONENTA = "01de99400030e8336020059a435cea4e7fe8f21aad4faf619da882134b85569d" + D_COMPONENTB = "5f416ec59629d6af91287e2ba13c6360339b6a0acf624af2abd2a810ce4aefce" +) var substitutions = Substitutions{ "test": D_COMPONENTA, @@ -186,7 +194,6 @@ successfully signed github.com/mandelsoft/ref:v1 (digest SHA-256:${ref}) session.AddCloser(cv) Expect(cv.GetDescriptor().Signatures[0].Digest.Value).To(Equal(D_COMPONENTB)) }) - }) Context("incomplete ctf", func() { diff --git a/cmds/ocm/commands/ocmcmds/components/transfer/cmd.go b/cmds/ocm/commands/ocmcmds/components/transfer/cmd.go index f91a39b22d..028ecc177b 100644 --- a/cmds/ocm/commands/ocmcmds/components/transfer/cmd.go +++ b/cmds/ocm/commands/ocmcmds/components/transfer/cmd.go @@ -135,7 +135,6 @@ func (o *Command) Run() error { spiff.ScriptFilesystem(o.FileSystem()), )...) thdlr, err := spiff.New(transferopts) - if err != nil { return err } diff --git a/cmds/ocm/commands/ocmcmds/components/transfer/cmd_test.go b/cmds/ocm/commands/ocmcmds/components/transfer/cmd_test.go index 2f53260231..835f12c976 100644 --- a/cmds/ocm/commands/ocmcmds/components/transfer/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/components/transfer/cmd_test.go @@ -30,15 +30,17 @@ import ( "github.com/open-component-model/ocm/pkg/utils" ) -const ARCH = "/tmp/ctf" -const ARCH2 = "/tmp/ctf2" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENT = "github.com/mandelsoft/test" -const COMPONENT2 = "github.com/mandelsoft/test2" -const OUT = "/tmp/res" -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" +const ( + ARCH = "/tmp/ctf" + ARCH2 = "/tmp/ctf2" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENT = "github.com/mandelsoft/test" + COMPONENT2 = "github.com/mandelsoft/test2" + OUT = "/tmp/res" + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) func CheckComponentInArchive(env *TestEnv, ldesc *artdesc.Descriptor, out string) { tgt, err := ctfocm.Open(env.OCMContext(), accessobj.ACC_READONLY, out, 0, accessio.PathFileSystem(env.FileSystem())) @@ -251,7 +253,6 @@ transferring version "github.com/mandelsoft/test:v1"... }) It("transfers ctf to ctf+tgz with config option", func() { - cfg := handlercfg.NewConfig() cfg.ResourcesByValue = utils.BoolP(true) diff --git a/cmds/ocm/commands/ocmcmds/components/transfer/upload_test.go b/cmds/ocm/commands/ocmcmds/components/transfer/upload_test.go index 9d42ae0e31..53224d6c16 100644 --- a/cmds/ocm/commands/ocmcmds/components/transfer/upload_test.go +++ b/cmds/ocm/commands/ocmcmds/components/transfer/upload_test.go @@ -27,12 +27,14 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const COMP = "github.com/compa" -const VERS = "1.0.0" -const CA = "ca" -const CTF = "ctf" -const COPY = "./ctf.copy" -const TARGET = "/tmp/target" +const ( + COMP = "github.com/compa" + VERS = "1.0.0" + CA = "ca" + CTF = "ctf" + COPY = "./ctf.copy" + TARGET = "/tmp/target" +) const OCISRC = "/tmp/source" @@ -74,7 +76,7 @@ var _ = Describe("upload", func() { oca := accessio.OnceCloser(ca) defer Close(oca) - ctf := Must(ctfocm.Create(env.OCMContext(), accessobj.ACC_CREATE, CTF, 0700, env)) + ctf := Must(ctfocm.Create(env.OCMContext(), accessobj.ACC_CREATE, CTF, 0o700, env)) octf := accessio.OnceCloser(ctf) defer Close(octf) @@ -107,7 +109,7 @@ transferring version "github.com/compa:1.0.0"... `)) - copy := Must(ctfocm.Open(ctx, accessobj.ACC_READONLY, COPY, 0700, env)) + copy := Must(ctfocm.Open(ctx, accessobj.ACC_READONLY, COPY, 0o700, env)) defer Close(copy) // check type diff --git a/cmds/ocm/commands/ocmcmds/components/verify/cmd_test.go b/cmds/ocm/commands/ocmcmds/components/verify/cmd_test.go index 13a8b96c5c..7e483b8a3f 100644 --- a/cmds/ocm/commands/ocmcmds/components/verify/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/components/verify/cmd_test.go @@ -28,20 +28,26 @@ import ( "github.com/open-component-model/ocm/pkg/signing/handlers/rsa" ) -const ARCH = "/tmp/ctf" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENTA = "github.com/mandelsoft/test" -const COMPONENTB = "github.com/mandelsoft/ref" -const OUT = "/tmp/res" -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" - -const SIGNATURE = "test" -const SIGN_ALGO = rsa.Algorithm - -const PUBKEY = "/tmp/pub" -const PRIVKEY = "/tmp/priv" +const ( + ARCH = "/tmp/ctf" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENTA = "github.com/mandelsoft/test" + COMPONENTB = "github.com/mandelsoft/ref" + OUT = "/tmp/res" + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) + +const ( + SIGNATURE = "test" + SIGN_ALGO = rsa.Algorithm +) + +const ( + PUBKEY = "/tmp/pub" + PRIVKEY = "/tmp/priv" +) var _ = Describe("access method", func() { var ( diff --git a/cmds/ocm/commands/ocmcmds/ctf/transfer/cmd_test.go b/cmds/ocm/commands/ocmcmds/ctf/transfer/cmd_test.go index 57572912f9..0075c3b0dd 100644 --- a/cmds/ocm/commands/ocmcmds/ctf/transfer/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/ctf/transfer/cmd_test.go @@ -21,13 +21,15 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ctf" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENT = "github.com/mandelsoft/test" -const OUT = "/tmp/res" -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" +const ( + ARCH = "/tmp/ctf" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENT = "github.com/mandelsoft/test" + OUT = "/tmp/res" + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/plugins/get/cmd_test.go b/cmds/ocm/commands/ocmcmds/plugins/get/cmd_test.go index 88eb54728e..2ae60616f5 100644 --- a/cmds/ocm/commands/ocmcmds/plugins/get/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/plugins/get/cmd_test.go @@ -50,5 +50,4 @@ PLUGIN VERSION SOURCE DESCRIPTION ACCESSMETHODS UPLOADERS DOW test v1 local a test plugin without function test[v1] `)) }) - }) diff --git a/cmds/ocm/commands/ocmcmds/plugins/install/cmd.go b/cmds/ocm/commands/ocmcmds/plugins/install/cmd.go index 2462191b93..d39692ef1b 100644 --- a/cmds/ocm/commands/ocmcmds/plugins/install/cmd.go +++ b/cmds/ocm/commands/ocmcmds/plugins/install/cmd.go @@ -66,6 +66,7 @@ $ ocm install plugin -r demo `, } } + func (o *Command) AddFlags(fs *pflag.FlagSet) { fs.BoolVarP(&o.RemoveMode, "remove", "r", false, "remove plugin") fs.BoolVarP(&o.UpdateMode, "update", "u", false, "update plugin") diff --git a/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/cmd_test.go b/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/cmd_test.go index c9a683c6a9..25339d307d 100644 --- a/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/cmd_test.go @@ -19,8 +19,10 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/comparch" ) -const CA = "/tmp/ca" -const VERSION = "v1" +const ( + CA = "/tmp/ca" + VERSION = "v1" +) var _ = Describe("Add with new access method", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/cmd_test.go b/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/cmd_test.go index 81649d17eb..8f8b72c1f3 100644 --- a/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/cmd_test.go @@ -17,10 +17,12 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ctf" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const COMP = "test.de/x" -const PROVIDER = "acme.org" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + COMP = "test.de/x" + PROVIDER = "acme.org" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/references/add/cmd_test.go b/cmds/ocm/commands/ocmcmds/references/add/cmd_test.go index 0645a46caf..56f1b6117e 100644 --- a/cmds/ocm/commands/ocmcmds/references/add/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/references/add/cmd_test.go @@ -8,14 +8,17 @@ import ( . "github.com/open-component-model/ocm/cmds/ocm/testhelper" "github.com/mandelsoft/goutils/testutils" + "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc" metav1 "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/meta/v1" "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/comparch" ) -const ARCH = "/tmp/ca" -const VERSION = "v1.1.1" -const REF = "github.com/mandelsoft/ref" +const ( + ARCH = "/tmp/ca" + VERSION = "v1.1.1" + REF = "github.com/mandelsoft/ref" +) func CheckReference(env *TestEnv, cd *compdesc.ComponentDescriptor, name string, add ...func(compdesc.ComponentReference)) { rs, _ := cd.GetReferencesByName(name) diff --git a/cmds/ocm/commands/ocmcmds/references/get/cmd_test.go b/cmds/ocm/commands/ocmcmds/references/get/cmd_test.go index 3fbe09be37..873347e847 100644 --- a/cmds/ocm/commands/ocmcmds/references/get/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/references/get/cmd_test.go @@ -11,13 +11,15 @@ import ( "github.com/open-component-model/ocm/pkg/common/accessio" ) -const CA = "/tmp/ca" -const CTF = "/tmp/ctf" -const VERSION = "v1" -const COMP = "test.de/x" -const COMP2 = "test.de/y" -const COMP3 = "test.de/z" -const PROVIDER = "mandelsoft" +const ( + CA = "/tmp/ca" + CTF = "/tmp/ctf" + VERSION = "v1" + COMP = "test.de/x" + COMP2 = "test.de/y" + COMP3 = "test.de/z" + PROVIDER = "mandelsoft" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/resourceconfig/add/cmd_test.go b/cmds/ocm/commands/ocmcmds/resourceconfig/add/cmd_test.go index 42ba893a4d..b3b7b812db 100644 --- a/cmds/ocm/commands/ocmcmds/resourceconfig/add/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/resourceconfig/add/cmd_test.go @@ -8,14 +8,15 @@ import ( "github.com/mandelsoft/goutils/testutils" ) -const SPECFILE = "/tmp/resources.yaml" -const VERSION = "v1" +const ( + SPECFILE = "/tmp/resources.yaml" + VERSION = "v1" +) func CheckSpec(env *TestEnv, spec string) { data, err := env.ReadFile(SPECFILE) ExpectWithOffset(1, err).To(Succeed()) ExpectWithOffset(1, string(data)).To(testutils.StringEqualTrimmedWithContext(spec)) - } var _ = Describe("Add resources", func() { diff --git a/cmds/ocm/commands/ocmcmds/resources/add/cmd_test.go b/cmds/ocm/commands/ocmcmds/resources/add/cmd_test.go index 4bd51a7bef..8ec3b81df4 100644 --- a/cmds/ocm/commands/ocmcmds/resources/add/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/resources/add/cmd_test.go @@ -30,10 +30,12 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const OCIPATH = "/tmp/oci" -const OCIHOST = "ghcr.io" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + OCIPATH = "/tmp/oci" + OCIHOST = "ghcr.io" +) func CheckTextResource(env *TestEnv, cd *compdesc.ComponentDescriptor, name string, ff ...func(r compdesc.Resource)) { rblob := blobaccess.ForFile(mime.MIME_TEXT, "/testdata/testcontent", env) diff --git a/cmds/ocm/commands/ocmcmds/resources/common/typehandler.go b/cmds/ocm/commands/ocmcmds/resources/common/typehandler.go index 0351c34bf8..3e57e12e30 100644 --- a/cmds/ocm/commands/ocmcmds/resources/common/typehandler.go +++ b/cmds/ocm/commands/ocmcmds/resources/common/typehandler.go @@ -13,9 +13,11 @@ func Elem(e interface{}) *compdesc.Resource { return e.(*elemhdlr.Object).Element.(*compdesc.Resource) } -var WithVersionConstraints = elemhdlr.WithVersionConstraints -var LatestOnly = elemhdlr.LatestOnly -var OptionsFor = elemhdlr.OptionsFor +var ( + WithVersionConstraints = elemhdlr.WithVersionConstraints + LatestOnly = elemhdlr.LatestOnly + OptionsFor = elemhdlr.OptionsFor +) type typeFilter struct { types []string diff --git a/cmds/ocm/commands/ocmcmds/resources/download/cmd_test.go b/cmds/ocm/commands/ocmcmds/resources/download/cmd_test.go index f73e75218d..c522a54299 100644 --- a/cmds/ocm/commands/ocmcmds/resources/download/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/resources/download/cmd_test.go @@ -15,12 +15,14 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const COMP = "test.de/x" -const COMP2 = "test.de/y" -const PROVIDER = "mandelsoft" -const OUT = "/tmp/res" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + COMP = "test.de/x" + COMP2 = "test.de/y" + PROVIDER = "mandelsoft" + OUT = "/tmp/res" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/resources/get/cmd_test.go b/cmds/ocm/commands/ocmcmds/resources/get/cmd_test.go index 6729740eb6..cceb039c76 100644 --- a/cmds/ocm/commands/ocmcmds/resources/get/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/resources/get/cmd_test.go @@ -13,12 +13,14 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const COMP = "test.de/x" -const COMP2 = "test.de/y" -const COMP3 = "test.de/z" -const PROVIDER = "mandelsoft" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + COMP = "test.de/x" + COMP2 = "test.de/y" + COMP3 = "test.de/z" + PROVIDER = "mandelsoft" +) var _ = Describe("Test Environment", func() { var env *TestEnv @@ -107,7 +109,6 @@ COMPONENT NAME VERSION IDENTITY TYPE RELATION └─ testdata v1 PlainText local `)) }) - }) Context("ctf", func() { diff --git a/cmds/ocm/commands/ocmcmds/resources/get/deep_test.go b/cmds/ocm/commands/ocmcmds/resources/get/deep_test.go index f6ce0bba9a..5074fbf3ec 100644 --- a/cmds/ocm/commands/ocmcmds/resources/get/deep_test.go +++ b/cmds/ocm/commands/ocmcmds/resources/get/deep_test.go @@ -13,14 +13,18 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const C1 = "github.com/gardener/landscaper" -const C11 = "github.com/gardener/landscaper/container-deployer" -const C12 = "github.com/gardener/landscaper/helm-deployer" -const C13 = "github.com/gardener/landscaper/manifest-deployer" -const C14 = "github.com/gardener/landscaper/mock-deployer" +const ( + C1 = "github.com/gardener/landscaper" + C11 = "github.com/gardener/landscaper/container-deployer" + C12 = "github.com/gardener/landscaper/helm-deployer" + C13 = "github.com/gardener/landscaper/manifest-deployer" + C14 = "github.com/gardener/landscaper/mock-deployer" +) -const CS = "github.com/gardener/landscaper-service" -const CI = "github.com/gardener/landscaper-instance" +const ( + CS = "github.com/gardener/landscaper-service" + CI = "github.com/gardener/landscaper-instance" +) var _ = Describe("Test Environment", func() { var env *TestEnv @@ -102,7 +106,6 @@ var _ = Describe("Test Environment", func() { }) It("lists all components in a deep structure", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("get", "resources", "--recursive", "-o", "tree", "--repo", ARCH, CS+":"+VERSION)).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext( @@ -124,5 +127,4 @@ COMPONENT NAME └─ mock-deployer-blueprint v1 PlainText local `)) }) - }) diff --git a/cmds/ocm/commands/ocmcmds/routingslips/add/cmd.go b/cmds/ocm/commands/ocmcmds/routingslips/add/cmd.go index a3759af129..3ea5aa42c3 100644 --- a/cmds/ocm/commands/ocmcmds/routingslips/add/cmd.go +++ b/cmds/ocm/commands/ocmcmds/routingslips/add/cmd.go @@ -225,5 +225,8 @@ func (a *action) Out() error { } else { _, err = routingslip.AddEntry(cv, a.cmd.Name, a.cmd.Algorithm, a.cmd.Entry, links, digest.Digest(a.cmd.Digest)) } + if err != nil { + return err + } return cv.Update() } diff --git a/cmds/ocm/commands/ocmcmds/routingslips/add/cmd_test.go b/cmds/ocm/commands/ocmcmds/routingslips/add/cmd_test.go index 552dd2159a..4c3e285831 100644 --- a/cmds/ocm/commands/ocmcmds/routingslips/add/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/routingslips/add/cmd_test.go @@ -15,11 +15,13 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ctf" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const COMP = "test.de/x" -const PROVIDER = "acme.org" -const OTHER = "other.org" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + COMP = "test.de/x" + PROVIDER = "acme.org" + OTHER = "other.org" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/routingslips/get/cmd_test.go b/cmds/ocm/commands/ocmcmds/routingslips/get/cmd_test.go index c76486e82f..1c8fecc15f 100644 --- a/cmds/ocm/commands/ocmcmds/routingslips/get/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/routingslips/get/cmd_test.go @@ -19,11 +19,13 @@ import ( "github.com/open-component-model/ocm/pkg/signing/handlers/rsa" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const COMP = "test.de/x" -const PROVIDER = "acme.org" -const OTHER = "a.company.com" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + COMP = "test.de/x" + PROVIDER = "acme.org" + OTHER = "a.company.com" +) var _ = Describe("Test Environment", func() { var env *TestEnv @@ -79,7 +81,6 @@ comment ` + e1a.Timestamp.String() + ` Comment: first entry }) It("gets single entry", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("get", "routingslip", "-v", ARCH)).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext( diff --git a/cmds/ocm/commands/ocmcmds/sourceconfig/add/cmd_test.go b/cmds/ocm/commands/ocmcmds/sourceconfig/add/cmd_test.go index f9dd68afd3..18b3d30888 100644 --- a/cmds/ocm/commands/ocmcmds/sourceconfig/add/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/sourceconfig/add/cmd_test.go @@ -8,14 +8,15 @@ import ( "github.com/mandelsoft/goutils/testutils" ) -const SPECFILE = "/tmp/sources.yaml" -const VERSION = "v1" +const ( + SPECFILE = "/tmp/sources.yaml" + VERSION = "v1" +) func CheckSpec(env *TestEnv, spec string) { data, err := env.ReadFile(SPECFILE) ExpectWithOffset(1, err).To(Succeed()) ExpectWithOffset(1, string(data)).To(testutils.StringEqualTrimmedWithContext(spec)) - } var _ = Describe("Add sources", func() { diff --git a/cmds/ocm/commands/ocmcmds/sources/add/cmd_test.go b/cmds/ocm/commands/ocmcmds/sources/add/cmd_test.go index 9b8635fbfc..fb7befa149 100644 --- a/cmds/ocm/commands/ocmcmds/sources/add/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/sources/add/cmd_test.go @@ -9,8 +9,8 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/open-component-model/ocm/cmds/ocm/testhelper" - "github.com/open-component-model/ocm/pkg/blobaccess" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/localblob" "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc" @@ -19,11 +19,12 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" +) func CheckArchiveSource(env *TestEnv, cd *compdesc.ComponentDescriptor, name string) { - r, err := cd.GetSourceByIdentity(metav1.NewIdentity(name)) Expect(err).To(Succeed()) Expect(r.Version).To(Equal(VERSION)) diff --git a/cmds/ocm/commands/ocmcmds/sources/get/cmd_test.go b/cmds/ocm/commands/ocmcmds/sources/get/cmd_test.go index b55dbf8424..a092ab1fc3 100644 --- a/cmds/ocm/commands/ocmcmds/sources/get/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/sources/get/cmd_test.go @@ -12,11 +12,13 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const COMP = "test.de/x" -const COMP2 = "test.de/y" -const PROVIDER = "mandelsoft" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + COMP = "test.de/x" + COMP2 = "test.de/y" + PROVIDER = "mandelsoft" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/ocmcmds/versions/show/cmd_test.go b/cmds/ocm/commands/ocmcmds/versions/show/cmd_test.go index 493a0204bd..3218e5b6fd 100644 --- a/cmds/ocm/commands/ocmcmds/versions/show/cmd_test.go +++ b/cmds/ocm/commands/ocmcmds/versions/show/cmd_test.go @@ -11,15 +11,17 @@ import ( "github.com/open-component-model/ocm/pkg/common/accessio" ) -const ARCH = "/tmp/ctf" -const PROVIDER = "mandelsoft" -const COMPONENT = "github.com/mandelsoft/test" -const V13 = "v1.3" -const V131 = "v1.3.1" -const V132 = "v1.3.2" -const V132x = "v1.3.2-beta.1" -const V14 = "v1.4" -const V2 = "v2.0" +const ( + ARCH = "/tmp/ctf" + PROVIDER = "mandelsoft" + COMPONENT = "github.com/mandelsoft/test" + V13 = "v1.3" + V131 = "v1.3.1" + V132 = "v1.3.2" + V132x = "v1.3.2-beta.1" + V14 = "v1.4" + V2 = "v2.0" +) var _ = Describe("Test Environment", func() { var env *TestEnv @@ -56,7 +58,6 @@ var _ = Describe("Test Environment", func() { }) It("lists version", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("ocm", "versions", "show", "--repo", ARCH, COMPONENT)).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext(` @@ -81,7 +82,6 @@ v1.4 }) It("lists filtered semantic versions", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("ocm", "versions", "show", "--semantic", "--repo", ARCH, COMPONENT, "1.3", "1.4")).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext(` @@ -93,7 +93,6 @@ v1.4 }) It("lists filters latest", func() { - buf := bytes.NewBuffer(nil) Expect(env.CatchOutput(buf).Execute("ocm", "versions", "show", "--latest", "--repo", ARCH, COMPONENT, "1.3")).To(Succeed()) Expect(buf.String()).To(StringEqualTrimmedWithContext(` diff --git a/cmds/ocm/commands/toicmds/config/bootstrap/cmd.go b/cmds/ocm/commands/toicmds/config/bootstrap/cmd.go index f5b9d6aadc..bd16485335 100644 --- a/cmds/ocm/commands/toicmds/config/bootstrap/cmd.go +++ b/cmds/ocm/commands/toicmds/config/bootstrap/cmd.go @@ -181,13 +181,10 @@ func (a *action) Out() error { return nil } - err = nil if len(spec.Scheme) > 0 && a.cmd.ParameterFile != "" { schemeFile := a.cmd.ParameterFile - if strings.HasSuffix(schemeFile, ".yaml") { - schemeFile = schemeFile[:len(schemeFile)-5] - } - schemeFile = schemeFile + ".jsonscheme" + schemeFile = strings.TrimSuffix(schemeFile, ".yaml") + schemeFile += ".jsonscheme" err = vfs.WriteFile(a.cmd.FileSystem(), schemeFile, spec.Scheme, 0o644) if err != nil { out.Errf(a.cmd.Context, "writing scheme file %s failed: %s\n", schemeFile, err) @@ -223,7 +220,8 @@ func (a *action) handle(kind, path string, cv ocm.ComponentVersionAccess, spec * l = len(c) err = vfs.WriteFile(a.cmd.FileSystem(), path, c, 0o600) default: - data, err := runtime.DefaultYAMLEncoding.Marshal(spec.Content) + var data []byte + data, err = runtime.DefaultYAMLEncoding.Marshal(spec.Content) if err != nil { data = spec.Content } @@ -249,7 +247,7 @@ func (a *action) download(kind, path string, cv ocm.ComponentVersionAccess, spec return errors.Wrapf(err, "%s resource", kind) } out.Outf(a.cmd.Context, "downloading %s...\n", kind) - ok, path, err := download.For(a.cmd.Context).DownloadAsBlob(common.NewPrinter(a.cmd.StdOut()), res, path, a.cmd.FileSystem()) + ok, _, err := download.For(a.cmd.Context).DownloadAsBlob(common.NewPrinter(a.cmd.StdOut()), res, path, a.cmd.FileSystem()) if err != nil { return err } diff --git a/cmds/ocm/commands/toicmds/config/bootstrap/cmd_test.go b/cmds/ocm/commands/toicmds/config/bootstrap/cmd_test.go index 99bd0bc5cc..678ae4c393 100644 --- a/cmds/ocm/commands/toicmds/config/bootstrap/cmd_test.go +++ b/cmds/ocm/commands/toicmds/config/bootstrap/cmd_test.go @@ -17,11 +17,13 @@ import ( "github.com/open-component-model/ocm/pkg/toi" ) -const ARCH = "/tmp/ctf" -const VERSION = "v1" -const COMP1 = "test.de/a" -const COMP2 = "test.de/b" -const PROVIDER = "mandelsoft" +const ( + ARCH = "/tmp/ctf" + VERSION = "v1" + COMP1 = "test.de/a" + COMP2 = "test.de/b" + PROVIDER = "mandelsoft" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/commands/toicmds/names/names.go b/cmds/ocm/commands/toicmds/names/names.go index 7651b222d5..4995b9975b 100644 --- a/cmds/ocm/commands/toicmds/names/names.go +++ b/cmds/ocm/commands/toicmds/names/names.go @@ -4,5 +4,7 @@ import ( "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/names" ) -var Package = []string{"package", "pkg", "componentversion", "cv", "component", "comp", "c"} -var Configuration = names.Configuration +var ( + Package = []string{"package", "pkg", "componentversion", "cv", "component", "comp", "c"} + Configuration = names.Configuration +) diff --git a/cmds/ocm/coretests/maven/cmd_test.go b/cmds/ocm/coretests/maven/cmd_test.go index 07b0105913..2929697d23 100644 --- a/cmds/ocm/coretests/maven/cmd_test.go +++ b/cmds/ocm/coretests/maven/cmd_test.go @@ -1,18 +1,19 @@ package add_test import ( + "strings" + "time" + . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/open-component-model/ocm/cmds/ocm/testhelper" + "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/localblob" mavenacc "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/maven" - "github.com/open-component-model/ocm/pkg/maven" - "strings" - "time" - "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ctf" + "github.com/open-component-model/ocm/pkg/maven" "github.com/open-component-model/ocm/pkg/maven/maventest" ) @@ -24,11 +25,13 @@ const ( MAVEN_VERSION = "1.1" ) -const ARCH = "/tmp/ctf" -const DEST_ARCH = "/tmp/ctf-dest" -const VERSION = "1.0.0" -const COMPONENT = "ocm.software/demo/test" -const OUT = "/tmp/res" +const ( + ARCH = "/tmp/ctf" + DEST_ARCH = "/tmp/ctf-dest" + VERSION = "1.0.0" + COMPONENT = "ocm.software/demo/test" + OUT = "/tmp/res" +) var _ = Describe("Test Environment", func() { var env *TestEnv diff --git a/cmds/ocm/pkg/data/dll_test.go b/cmds/ocm/pkg/data/dll_test.go index 1e3e5a49eb..8ec42dae77 100644 --- a/cmds/ocm/pkg/data/dll_test.go +++ b/cmds/ocm/pkg/data/dll_test.go @@ -6,9 +6,7 @@ import ( ) var _ = Describe("simple data processing", func() { - Context("add", func() { - It("end", func() { root := DLL{} @@ -45,7 +43,6 @@ var _ = Describe("simple data processing", func() { }) }) Context("remove", func() { - It("end", func() { root := DLL{} @@ -80,8 +77,6 @@ var _ = Describe("simple data processing", func() { Expect(d2.Next()).To(BeNil()) Expect(d2.Prev()).To(BeIdenticalTo(&root)) - }) }) - }) diff --git a/cmds/ocm/pkg/data/indexed_test.go b/cmds/ocm/pkg/data/indexed_test.go index 4ff03d50d8..6eb4179005 100644 --- a/cmds/ocm/pkg/data/indexed_test.go +++ b/cmds/ocm/pkg/data/indexed_test.go @@ -6,9 +6,7 @@ import ( ) var _ = Describe("slice", func() { - Context("move", func() { - It("backward move non-overlap", func() { data := IndexedSliceAccess{0, 1, 2, 3, 4, 5, 6, 7, 8} data.Move(5, 7, 1) diff --git a/cmds/ocm/pkg/data/list_test.go b/cmds/ocm/pkg/data/list_test.go index b0c749a957..c1af650fcd 100644 --- a/cmds/ocm/pkg/data/list_test.go +++ b/cmds/ocm/pkg/data/list_test.go @@ -6,9 +6,7 @@ import ( ) var _ = Describe("linked list", func() { - Context("add", func() { - It("end", func() { list := NewLinkedList() diff --git a/cmds/ocm/pkg/options/options_test.go b/cmds/ocm/pkg/options/options_test.go index 24d31ccee2..92914958f5 100644 --- a/cmds/ocm/pkg/options/options_test.go +++ b/cmds/ocm/pkg/options/options_test.go @@ -20,7 +20,6 @@ func (t *TestOption) AddFlags(fs *pflag.FlagSet) { var _ options.Options = (*TestOption)(nil) var _ = Describe("options", func() { - It("skips unknown option", func() { set := options.OptionSet{} diff --git a/cmds/ocm/pkg/output/options.go b/cmds/ocm/pkg/output/options.go index 32b2062ab2..c68e7db678 100644 --- a/cmds/ocm/pkg/output/options.go +++ b/cmds/ocm/pkg/output/options.go @@ -64,7 +64,7 @@ func (o *Options) OptimizeColumns(n int) *Options { } // WithStatusCheck provides the possibility to check every entry to -// influence the final out status +// influence the final out status. func (o *Options) WithStatusCheck(f StatusCheckFunction) *Options { o.StatusCheck = f return o diff --git a/cmds/ocm/pkg/output/sort_test.go b/cmds/ocm/pkg/output/sort_test.go index fdb8afa81b..fb01f8b238 100644 --- a/cmds/ocm/pkg/output/sort_test.go +++ b/cmds/ocm/pkg/output/sort_test.go @@ -8,7 +8,6 @@ import ( ) var _ = Describe("sort", func() { - h1i2a1b3 := []string{"h1", "i2", "a1", "b3"} h2i2a1b3 := []string{"h2", "i2", "a1", "b3"} h1i2a3b2 := []string{"h1", "i2", "a3", "b2"} @@ -70,7 +69,7 @@ var _ = Describe("sort", func() { h2i2a2b1, } slice = data.IndexedSliceAccess(values) - //slice.SortIndexed(compare_fixed_column(1, 2)) + // slice.SortIndexed(compare_fixed_column(1, 2)) sortFixed(1, slice, compareColumn(2)) Expect(slice).To(Equal(data.IndexedSliceAccess{ h1i2a1b3, @@ -81,5 +80,4 @@ var _ = Describe("sort", func() { h2i2a3b2, })) }) - }) diff --git a/cmds/ocm/pkg/output/tableoutput.go b/cmds/ocm/pkg/output/tableoutput.go index 10924953c4..42e0ebf870 100644 --- a/cmds/ocm/pkg/output/tableoutput.go +++ b/cmds/ocm/pkg/output/tableoutput.go @@ -97,7 +97,6 @@ columns: } func (this *TableProcessingOutput) Out() error { - sort := this.opts.Sort slice := data.IndexedSliceAccess(data.Slice(this.Elems)) if len(slice) == 0 { diff --git a/cmds/ocm/pkg/processing/buffer_test.go b/cmds/ocm/pkg/processing/buffer_test.go index b3aea9ea6d..9ae9d131b6 100644 --- a/cmds/ocm/pkg/processing/buffer_test.go +++ b/cmds/ocm/pkg/processing/buffer_test.go @@ -21,7 +21,7 @@ func Gather(i data.Iterable) *Result { r := &Result{} r.wg.Add(1) go func() { - //defer GinkgoRecover() + // defer GinkgoRecover() r.result = data.Slice(i) r.wg.Done() }() @@ -49,7 +49,6 @@ var _ = Describe("processing buffer", func() { }) Context("index array", func() { - It("after empty", func() { i := IndexArray{} Expect(i.After(IndexArray{1, 2, 3})).To(BeFalse()) @@ -64,7 +63,6 @@ var _ = Describe("processing buffer", func() { Expect(i.After(IndexArray{1, 2, 2})).To(BeTrue()) Expect(i.After(IndexArray{1, 1, 3})).To(BeTrue()) Expect(i.After(IndexArray{0, 2, 3})).To(BeTrue()) - }) It("after deeper level", func() { i := IndexArray{1, 2, 3} @@ -151,7 +149,6 @@ var _ = Describe("processing buffer", func() { buf.Close() Expect(promise.Get()).To(Equal([]interface{}{0, 1, 2, 3})) Expect(data.Slice(ValueIterable(buf))).To(Equal([]interface{}{0, 1, 2, 3})) - }) It("add filtered", func() { diff --git a/cmds/ocm/pkg/processing/logging.go b/cmds/ocm/pkg/processing/logging.go index f4abfaec69..efdc63ee25 100644 --- a/cmds/ocm/pkg/processing/logging.go +++ b/cmds/ocm/pkg/processing/logging.go @@ -5,5 +5,3 @@ import ( ) var REALM = ocmlog.DefineSubRealm("output processing chains", "processing") - -var logger = ocmlog.DynamicLogger() diff --git a/cmds/ocm/pkg/processing/processing_test.go b/cmds/ocm/pkg/processing/processing_test.go index 977d31d25a..1b308d9e08 100644 --- a/cmds/ocm/pkg/processing/processing_test.go +++ b/cmds/ocm/pkg/processing/processing_test.go @@ -7,9 +7,9 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/mandelsoft/goutils/testutils" "github.com/mandelsoft/logging" - "github.com/mandelsoft/goutils/testutils" "github.com/open-component-model/ocm/cmds/ocm/pkg/data" ocmlog "github.com/open-component-model/ocm/pkg/logging" ) @@ -114,7 +114,6 @@ V[3] add one to number num 3 Expect(r).To(Equal(data.IndexedSliceAccess([]interface{}{ 2, 4, 3, 6, 4, 8, }))) - }) }) diff --git a/cmds/ocm/pkg/tree/tree_test.go b/cmds/ocm/pkg/tree/tree_test.go index 65707d9c24..f7977f19c4 100644 --- a/cmds/ocm/pkg/tree/tree_test.go +++ b/cmds/ocm/pkg/tree/tree_test.go @@ -93,7 +93,6 @@ func Check(t tree.TreeObjects, result string) { } var _ = Describe("tree", func() { - It("composes flat tree", func() { data := []tree.Object{ E("a"), diff --git a/cmds/ocm/pkg/utils/fileutils.go b/cmds/ocm/pkg/utils/fileutils.go index f5f46da53a..17c85a6057 100644 --- a/cmds/ocm/pkg/utils/fileutils.go +++ b/cmds/ocm/pkg/utils/fileutils.go @@ -5,12 +5,12 @@ import ( "github.com/mandelsoft/vfs/pkg/vfs" - "github.com/open-component-model/ocm/pkg/common/accessio" + "github.com/open-component-model/ocm/pkg/utils" ) // IsExecutable returns true if a given file is executable. func IsExecutable(path string, fss ...vfs.FileSystem) bool { - stat, err := accessio.FileSystem(fss...).Stat(path) + stat, err := utils.FileSystem(fss...).Stat(path) if err != nil { return false } @@ -18,14 +18,14 @@ func IsExecutable(path string, fss ...vfs.FileSystem) bool { if !mode.IsRegular() { return false } - if (mode & 0111) == 0 { + if (mode & 0o111) == 0 { return false } return true } // SplitPathList splits a path list. -// This is based on genSplit from strings/strings.go +// This is based on genSplit from strings/strings.go. func SplitPathList(pathList string) []string { if pathList == "" { return nil diff --git a/cmds/ocm/testhelper/testhelper_test.go b/cmds/ocm/testhelper/testhelper_test.go index dcb6c18dc2..27c5f2cb75 100644 --- a/cmds/ocm/testhelper/testhelper_test.go +++ b/cmds/ocm/testhelper/testhelper_test.go @@ -8,7 +8,6 @@ import ( ) var _ = Describe("Test Environment", func() { - It("loads test environment", func() { h := NewTestEnv(TestData()) defer h.Cleanup() diff --git a/cmds/ocm/topics/oci/refs/topic.go b/cmds/ocm/topics/oci/refs/topic.go index 66cba184c3..10452fc769 100644 --- a/cmds/ocm/topics/oci/refs/topic.go +++ b/cmds/ocm/topics/oci/refs/topic.go @@ -58,7 +58,7 @@ or Notice that this notation optionally also allows a double slash to -seperate <domain>[:<port>] and <repository>. While it is +separate <domain>[:<port>] and <repository>. While it is not necessary for unambiguous parsing here, it is supported for consistency with the other notations. diff --git a/docs/reference/ocm_add_componentversions.md b/docs/reference/ocm_add_componentversions.md index 990c62f5c4..aff2d31a93 100644 --- a/docs/reference/ocm_add_componentversions.md +++ b/docs/reference/ocm_add_componentversions.md @@ -15,22 +15,23 @@ componentversions, componentversion, cv, components, component, comps, comp, c ### Options ``` - --addenv access environment for templating - -C, --complete include all referenced component version - -L, --copy-local-resources transfer referenced local resources by-value - -V, --copy-resources transfer referenced resources by-value - -c, --create (re)create archive - --dry-run evaluate and print component specifications - -F, --file string target file/directory (default "transport-archive") - -f, --force remove existing content - -h, --help help for componentversions - --lookup stringArray repository name or spec for closure lookup fallback - -O, --output string output file for dry-run - -S, --scheme string schema version (default "v2") - -s, --settings stringArray settings file with variable settings (yaml) - --templater string templater to use (go, none, spiff, subst) (default "subst") - -t, --type string archive format (directory, tar, tgz) (default "directory") - -v, --version string default version for components + --addenv access environment for templating + -C, --complete include all referenced component version + -L, --copy-local-resources transfer referenced local resources by-value + -V, --copy-resources transfer referenced resources by-value + -c, --create (re)create archive + --dry-run evaluate and print component specifications + -F, --file string target file/directory (default "transport-archive") + -f, --force remove existing content + -h, --help help for componentversions + --lookup stringArray repository name or spec for closure lookup fallback + -O, --output string output file for dry-run + -S, --scheme string schema version (default "v2") + -s, --settings stringArray settings file with variable settings (yaml) + --templater string templater to use (go, none, spiff, subst) (default "subst") + -t, --type string archive format (directory, tar, tgz) (default "directory") + --uploader = repository uploader ([:[:]]=script option family. + +If the --uploader option is specified, appropriate uploader handlers +are configured for the operation. It has the following format + +
+
<name>:<artifact type>:<media type>=<yaml target config>
+
+ +The uploader name may be a path expression with the following possibilities: + - ocm/ociArtifacts: downloading OCI artifacts + + The ociArtifacts downloader is able to download OCI artifacts + as artifact archive according to the OCI distribution spec. + The following artifact media types are supported: + - application/vnd.oci.image.manifest.v1+tar + - application/vnd.oci.image.manifest.v1+tar+gzip + - application/vnd.oci.image.index.v1+tar + - application/vnd.oci.image.index.v1+tar+gzip + - application/vnd.docker.distribution.manifest.v2+tar + - application/vnd.docker.distribution.manifest.v2+tar+gzip + - application/vnd.docker.distribution.manifest.list.v2+tar + - application/vnd.docker.distribution.manifest.list.v2+tar+gzip + + By default, it is registered for these mimetypes. + + It accepts a config with the following fields: + - namespacePrefix: a namespace prefix used for the uploaded artifacts + - ociRef: an OCI repository reference + - repository: an OCI repository specification for the target OCI registry + + Alternatively, a single string value can be given representing an OCI repository + reference. + + - ocm/npmPackage: uploading npm artifacts + + The ocm/npmPackage uploader is able to upload npm artifacts + as artifact archive according to the npm package spec. + If registered the default mime type is: application/x-tgz + + It accepts a plain string for the URL or a config with the following field: + 'url': the URL of the npm repository. + + - plugin: [downloaders provided by plugins] + + sub namespace of the form <plugin name>/<handler> + + - ocm/mavenPackage: uploading maven artifacts + + The ocm/mavenPackage uploader is able to upload maven artifacts (whole GAV only!) + as artifact archive according to the maven artifact spec. + If registered the default mime type is: application/x-tgz + + It accepts a plain string for the URL or a config with the following field: + 'url': the URL of the maven repository. + + + +See [ocm ocm-uploadhandlers](ocm_ocm-uploadhandlers.md) for further details on using +upload handlers. + + ### Examples @@ -207,4 +269,5 @@ next to the description file. * [ocm add resources](ocm_add_resources.md) — add resources to a component version * [ocm add references](ocm_add_references.md) — add aggregation information to a component version * [ocm ocm-labels](ocm_ocm-labels.md) — Labels and Label Merging +* [ocm ocm-uploadhandlers](ocm_ocm-uploadhandlers.md) — List of all available upload handlers diff --git a/docs/reference/ocm_check_componentversions.md b/docs/reference/ocm_check_componentversions.md index 66af32da98..03860c1dab 100644 --- a/docs/reference/ocm_check_componentversions.md +++ b/docs/reference/ocm_check_componentversions.md @@ -76,7 +76,7 @@ OCI Repository types (using standard component repository to OCI mapping): If the options --local-resources and/or --local-sources are given the -the check additionally assures that all resources or sources are included into the component version. +check additionally assures that all resources or sources are included into the component version. This means that they are using local access methods, only. With the option --output the output mode can be selected. diff --git a/docs/reference/ocm_oci-references.md b/docs/reference/ocm_oci-references.md index b317192bfa..7593f291b7 100644 --- a/docs/reference/ocm_oci-references.md +++ b/docs/reference/ocm_oci-references.md @@ -30,7 +30,7 @@ or Notice that this notation optionally also allows a double slash to -seperate <domain>[:<port>] and <repository>. While it is +separate <domain>[:<port>] and <repository>. While it is not necessary for unambiguous parsing here, it is supported for consistency with the other notations. diff --git a/docs/reference/ocm_ocm-uploadhandlers.md b/docs/reference/ocm_ocm-uploadhandlers.md index 5c6ac57448..a41640afbe 100644 --- a/docs/reference/ocm_ocm-uploadhandlers.md +++ b/docs/reference/ocm_ocm-uploadhandlers.md @@ -73,9 +73,9 @@ The following handler names are possible: sub namespace of the form <plugin name>/<handler> - - ocm/mavenArtifact: uploading maven artifacts + - ocm/mavenPackage: uploading maven artifacts - The ocm/mavenArtifact uploader is able to upload maven artifacts (whole GAV only!) + The ocm/mavenPackage uploader is able to upload maven artifacts (whole GAV only!) as artifact archive according to the maven artifact spec. If registered the default mime type is: application/x-tgz diff --git a/docs/reference/ocm_transfer_commontransportarchive.md b/docs/reference/ocm_transfer_commontransportarchive.md index eaa4b1f1fb..e842259798 100644 --- a/docs/reference/ocm_transfer_commontransportarchive.md +++ b/docs/reference/ocm_transfer_commontransportarchive.md @@ -147,9 +147,9 @@ The uploader name may be a path expression with the following possibilities: sub namespace of the form <plugin name>/<handler> - - ocm/mavenArtifact: uploading maven artifacts + - ocm/mavenPackage: uploading maven artifacts - The ocm/mavenArtifact uploader is able to upload maven artifacts (whole GAV only!) + The ocm/mavenPackage uploader is able to upload maven artifacts (whole GAV only!) as artifact archive according to the maven artifact spec. If registered the default mime type is: application/x-tgz diff --git a/docs/reference/ocm_transfer_componentversions.md b/docs/reference/ocm_transfer_componentversions.md index b58c17b15f..b08dfa2593 100644 --- a/docs/reference/ocm_transfer_componentversions.md +++ b/docs/reference/ocm_transfer_componentversions.md @@ -204,9 +204,9 @@ The uploader name may be a path expression with the following possibilities: sub namespace of the form <plugin name>/<handler> - - ocm/mavenArtifact: uploading maven artifacts + - ocm/mavenPackage: uploading maven artifacts - The ocm/mavenArtifact uploader is able to upload maven artifacts (whole GAV only!) + The ocm/mavenPackage uploader is able to upload maven artifacts (whole GAV only!) as artifact archive according to the maven artifact spec. If registered the default mime type is: application/x-tgz diff --git a/examples/lib/comparison-scenario/00-provider.go b/examples/lib/comparison-scenario/00-provider.go index d9df96b2f1..519338830c 100644 --- a/examples/lib/comparison-scenario/00-provider.go +++ b/examples/lib/comparison-scenario/00-provider.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ocireg" diff --git a/examples/lib/comparison-scenario/01-create.go b/examples/lib/comparison-scenario/01-create.go index 5fbf4b1443..f3fca77566 100644 --- a/examples/lib/comparison-scenario/01-create.go +++ b/examples/lib/comparison-scenario/01-create.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/ocm" metav1 "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/meta/v1" diff --git a/examples/lib/comparison-scenario/02-sign.go b/examples/lib/comparison-scenario/02-sign.go index 839c29aa97..ab85c547bf 100644 --- a/examples/lib/comparison-scenario/02-sign.go +++ b/examples/lib/comparison-scenario/02-sign.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/signingattr" diff --git a/examples/lib/comparison-scenario/03-write.go b/examples/lib/comparison-scenario/03-write.go index 89330589af..b727d5052e 100644 --- a/examples/lib/comparison-scenario/03-write.go +++ b/examples/lib/comparison-scenario/03-write.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" ociidentity "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/oci/identity" "github.com/open-component-model/ocm/pkg/contexts/oci" @@ -33,7 +34,7 @@ func Write(cfg *helper.Config) error { fmt.Printf("persisting public key to %s", KEYFILE) pubkey := signingattr.Get(ctx).GetPublicKey("acme.org") - file, err := os.OpenFile(KEYFILE, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600) + file, err := os.OpenFile(KEYFILE, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o600) if err != nil { return errors.Wrapf(err, "cannot persist public key") } diff --git a/examples/lib/comparison-scenario/04-transport.go b/examples/lib/comparison-scenario/04-transport.go index 5b799170f5..9060566d04 100644 --- a/examples/lib/comparison-scenario/04-transport.go +++ b/examples/lib/comparison-scenario/04-transport.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/contexts/ocm" diff --git a/examples/lib/comparison-scenario/05-verify.go b/examples/lib/comparison-scenario/05-verify.go index 9441a96bea..58563dbedf 100644 --- a/examples/lib/comparison-scenario/05-verify.go +++ b/examples/lib/comparison-scenario/05-verify.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/signing" diff --git a/examples/lib/comparison-scenario/07-getref.go b/examples/lib/comparison-scenario/07-getref.go index f4980c8f96..c87c41b1c7 100644 --- a/examples/lib/comparison-scenario/07-getref.go +++ b/examples/lib/comparison-scenario/07-getref.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/ocm" metav1 "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/meta/v1" diff --git a/examples/lib/comparison-scenario/08-deployscript.go b/examples/lib/comparison-scenario/08-deployscript.go index 83699ab17c..4d24dec70d 100644 --- a/examples/lib/comparison-scenario/08-deployscript.go +++ b/examples/lib/comparison-scenario/08-deployscript.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/ocm" metav1 "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/meta/v1" diff --git a/examples/lib/comparison-scenario/09-localize.go b/examples/lib/comparison-scenario/09-localize.go index 400d1bb62b..44e084f2ac 100644 --- a/examples/lib/comparison-scenario/09-localize.go +++ b/examples/lib/comparison-scenario/09-localize.go @@ -32,8 +32,8 @@ type DeployDescriptor struct { } func EvaluateDeployDescriptor(cv ocm.ComponentVersionAccess, res ocm.ResourceAccess, resolver ocm.ComponentVersionResolver, - config template.Values, path string, fss ...vfs.FileSystem) ([]byte, *chart.Chart, string, error) { - + config template.Values, path string, fss ...vfs.FileSystem, +) ([]byte, *chart.Chart, string, error) { fs := utils.FileSystem(fss...) id := res.Meta().GetIdentity(cv.GetDescriptor().Resources) diff --git a/examples/lib/comparison-scenario/main.go b/examples/lib/comparison-scenario/main.go index 533b186b0c..7ffe43da7d 100644 --- a/examples/lib/comparison-scenario/main.go +++ b/examples/lib/comparison-scenario/main.go @@ -8,8 +8,10 @@ import ( "github.com/open-component-model/ocm/pkg/utils/template" ) -const COMPONENT_NAME = "acme.org/podinfo" -const COMPONENT_VERSION = "0.1.0" +const ( + COMPONENT_NAME = "acme.org/podinfo" + COMPONENT_VERSION = "0.1.0" +) // CFG is the path to the file containing the credentials var CFG = "config/config.yaml" diff --git a/examples/lib/config1/example.go b/examples/lib/config1/example.go index 8ccbd92c74..7269d9a87a 100644 --- a/examples/lib/config1/example.go +++ b/examples/lib/config1/example.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/credentials" ociid "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/oci/identity" diff --git a/examples/lib/config2/example.go b/examples/lib/config2/example.go index 6f71bb9fa8..6995c3fdf9 100644 --- a/examples/lib/config2/example.go +++ b/examples/lib/config2/example.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/pkg/contexts/credentials" ociid "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/oci/identity" "github.com/open-component-model/ocm/pkg/contexts/ocm" diff --git a/examples/lib/config3/example.go b/examples/lib/config3/example.go index 320d923b37..c5fd4c2407 100644 --- a/examples/lib/config3/example.go +++ b/examples/lib/config3/example.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/pkg/contexts/config" "github.com/open-component-model/ocm/pkg/contexts/config/cpi" "github.com/open-component-model/ocm/pkg/runtime" diff --git a/examples/lib/cred1/example.go b/examples/lib/cred1/example.go index 3469dfc034..07325f698c 100644 --- a/examples/lib/cred1/example.go +++ b/examples/lib/cred1/example.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/contexts/ocm" diff --git a/examples/lib/cred2/example.go b/examples/lib/cred2/example.go index cbe2e1af81..1ca1e13fc6 100644 --- a/examples/lib/cred2/example.go +++ b/examples/lib/cred2/example.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/contexts/credentials" @@ -80,7 +81,6 @@ func SimpleWriteWithCredentials() (ferr error) { Type: resourcetypes.OCI_IMAGE, Relation: metav1.ExternalRelation, }, imageAccess) - if err != nil { return errors.Wrapf(err, "cannot add image resource") } diff --git a/examples/lib/cred3/example.go b/examples/lib/cred3/example.go index fc88a75427..6e1d40709b 100644 --- a/examples/lib/cred3/example.go +++ b/examples/lib/cred3/example.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/contexts/credentials/repositories/dockerconfig" diff --git a/examples/lib/ctf/example.go b/examples/lib/ctf/example.go index 7defc0cef7..1a26b5f42c 100644 --- a/examples/lib/ctf/example.go +++ b/examples/lib/ctf/example.go @@ -6,8 +6,8 @@ import ( "github.com/mandelsoft/goutils/errors" "github.com/mandelsoft/goutils/finalizer" "github.com/mandelsoft/vfs/pkg/memoryfs" - "github.com/open-component-model/ocm/pkg/blobaccess" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/accessobj" "github.com/open-component-model/ocm/pkg/contexts/ocm" @@ -18,8 +18,10 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const COMP = "acme.org/mytestcomponent" -const VERS = "1.0.0" +const ( + COMP = "acme.org/mytestcomponent" + VERS = "1.0.0" +) func CTFExample() (rerr error) { var finalize finalizer.Finalizer @@ -68,7 +70,6 @@ func CTFExample() (rerr error) { blobaccess.ForString(mime.MIME_TEXT, "testdata"), "", nil, ) - if err != nil { return errors.Wrapf(err, "cannot add resource") } diff --git a/examples/lib/example.go b/examples/lib/example.go index 798dcac412..510581ef2b 100644 --- a/examples/lib/example.go +++ b/examples/lib/example.go @@ -10,8 +10,10 @@ import ( "github.com/open-component-model/ocm/pkg/utils" ) -const componentName = "ocm.software/toi/demo/helmdemo" -const componentVersion = "0.3.0-rc.2" +const ( + componentName = "ocm.software/toi/demo/helmdemo" + componentVersion = "0.3.0-rc.2" +) const resourceName = "package" diff --git a/examples/lib/helper/helper.go b/examples/lib/helper/helper.go index e51ec34ec7..4085301df5 100644 --- a/examples/lib/helper/helper.go +++ b/examples/lib/helper/helper.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/pkg/contexts/credentials" "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/oci/identity" "github.com/open-component-model/ocm/pkg/runtime" diff --git a/examples/lib/tour/01-getting-started/README.md b/examples/lib/tour/01-getting-started/README.md index 5f807a67f3..819aeda827 100644 --- a/examples/lib/tour/01-getting-started/README.md +++ b/examples/lib/tour/01-getting-started/README.md @@ -164,32 +164,32 @@ differ, because the code always describes the latest version): ``` resources of the latest version: - version: 0.10.0 + version: 0.11.0 provider: ocm.software 1: name: ocmcli extra identity: "architecture"="amd64","os"="linux" resource type: executable - access: Local blob sha256:e2d8f578083e9317bd199b3f374b7ea60e7f28cf989e8d39ae0ea54ac4fa8847[] + access: Local blob sha256:28c39f8c1623d50398e916494582ebdeaf608dd8e27d112d01625bb903b95ecf[] 2: name: ocmcli extra identity: "architecture"="arm64","os"="linux" resource type: executable - access: Local blob sha256:2acef3da732a6674fb047f3d60f0dabcbb60ffeb8dd362a169df97c4dc4489a8[] + access: Local blob sha256:c9f1eb5ba391e0cfe1c84e34d8b7e9923b061e5917c12c73e21f6a4d300813d8[] 3: name: ocmcli extra identity: "architecture"="arm64","os"="darwin" resource type: executable - access: Local blob sha256:b05fbc5e8aaa3622e2ecc39ead7f066030fd183c625b0dc202dbac8131f06d1d[] + access: Local blob sha256:8dafc347d7129d3ff3b4f54cc9d82d8852980dc38e778c96aa82b16d1ddb4288[] 4: name: ocmcli extra identity: "architecture"="amd64","os"="darwin" resource type: executable - access: Local blob sha256:aec88249f7e5a395eaa18ac6017831b275c7de90d3c10f0cd9e572027ad6c6e9[] + access: Local blob sha256:611d693ec021a2c6001d515c3d896ac769beab39de4f859d9a7bc0bcdba10f3e[] 5: name: ocmcli extra identity: "architecture"="amd64","os"="windows" resource type: executable - access: Local blob sha256:cdbac49bd004aa2a8b89fafb9e845f45bfcfaab2df402296f55b403b9b1035a2[] + access: Local blob sha256:884d76b98fe37c0fdb0a9d1f3707eb98e6bfc0385658ba4f6890b2de75fb331e[] 6: name: ocmcli-image extra identity: resource type: ociImage - access: OCI artifact ghcr.io/open-component-model/ocm/ocm.software/ocmcli/ocmcli-image:0.10.0 + access: OCI artifact ghcr.io/open-component-model/ocm/ocm.software/ocmcli/ocmcli-image:0.11.0 ``` Resources have some metadata, like their identity and a resource type. @@ -276,7 +276,7 @@ Now, we just read the content and copy it to the intended output file (`/tmp/ocmcli`). ```go - file, err := os.OpenFile("/tmp/ocmcli", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0766) + file, err := os.OpenFile("/tmp/ocmcli", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o766) if err != nil { return errors.Wrapf(err, "cannot open output file") } diff --git a/examples/lib/tour/01-getting-started/example.go b/examples/lib/tour/01-getting-started/example.go index 767c7fc19f..23188abbb2 100644 --- a/examples/lib/tour/01-getting-started/example.go +++ b/examples/lib/tour/01-getting-started/example.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/contexts/ocm" metav1 "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/meta/v1" @@ -210,7 +211,7 @@ func GettingStarted() error { // --- end closing reader --- // --- begin copy --- - file, err := os.OpenFile("/tmp/ocmcli", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0766) + file, err := os.OpenFile("/tmp/ocmcli", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o766) if err != nil { return errors.Wrapf(err, "cannot open output file") } diff --git a/examples/lib/tour/02-composing-a-component-version/01-basic-componentversion-creation.go b/examples/lib/tour/02-composing-a-component-version/01-basic-componentversion-creation.go index bcdb5f60d1..da13cdc0bb 100644 --- a/examples/lib/tour/02-composing-a-component-version/01-basic-componentversion-creation.go +++ b/examples/lib/tour/02-composing-a-component-version/01-basic-componentversion-creation.go @@ -6,8 +6,8 @@ import ( "github.com/mandelsoft/goutils/errors" "github.com/mandelsoft/goutils/finalizer" - "github.com/open-component-model/ocm/pkg/blobaccess" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact" diff --git a/examples/lib/tour/02-composing-a-component-version/02-composition-version.go b/examples/lib/tour/02-composing-a-component-version/02-composition-version.go index bf935462b0..dc664d227c 100644 --- a/examples/lib/tour/02-composing-a-component-version/02-composition-version.go +++ b/examples/lib/tour/02-composing-a-component-version/02-composition-version.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/composition" ) diff --git a/examples/lib/tour/03-working-with-credentials/01-using-credentials.go b/examples/lib/tour/03-working-with-credentials/01-using-credentials.go index 0539fddda9..8bf49d3252 100644 --- a/examples/lib/tour/03-working-with-credentials/01-using-credentials.go +++ b/examples/lib/tour/03-working-with-credentials/01-using-credentials.go @@ -2,6 +2,7 @@ package main import ( "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" ociidentity "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/oci/identity" "github.com/open-component-model/ocm/pkg/contexts/ocm" diff --git a/examples/lib/tour/03-working-with-credentials/02-basic-credential-management.go b/examples/lib/tour/03-working-with-credentials/02-basic-credential-management.go index f3b6c01e7b..3d9a8ddf6d 100644 --- a/examples/lib/tour/03-working-with-credentials/02-basic-credential-management.go +++ b/examples/lib/tour/03-working-with-credentials/02-basic-credential-management.go @@ -6,6 +6,7 @@ import ( "os" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/credentials" ociidentity "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/oci/identity" diff --git a/examples/lib/tour/03-working-with-credentials/03-credential-repositories.go b/examples/lib/tour/03-working-with-credentials/03-credential-repositories.go index d6e3271ceb..a00b38a78e 100644 --- a/examples/lib/tour/03-working-with-credentials/03-credential-repositories.go +++ b/examples/lib/tour/03-working-with-credentials/03-credential-repositories.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/credentials" ociidentity "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/oci/identity" diff --git a/examples/lib/tour/03-working-with-credentials/common.go b/examples/lib/tour/03-working-with-credentials/common.go index 84d2e03b76..86151feab0 100644 --- a/examples/lib/tour/03-working-with-credentials/common.go +++ b/examples/lib/tour/03-working-with-credentials/common.go @@ -6,8 +6,8 @@ import ( "github.com/mandelsoft/goutils/errors" "github.com/mandelsoft/goutils/finalizer" - "github.com/open-component-model/ocm/pkg/blobaccess" + "github.com/open-component-model/ocm/pkg/blobaccess" "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/ocm" diff --git a/examples/lib/tour/04-working-with-config/01-basic-config-management.go b/examples/lib/tour/04-working-with-config/01-basic-config-management.go index 129afe2997..1045e20a88 100644 --- a/examples/lib/tour/04-working-with-config/01-basic-config-management.go +++ b/examples/lib/tour/04-working-with-config/01-basic-config-management.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/go-test/deep" - "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/config" "github.com/open-component-model/ocm/pkg/contexts/credentials" diff --git a/examples/lib/tour/04-working-with-config/02-handle-arbitrary-config.go b/examples/lib/tour/04-working-with-config/02-handle-arbitrary-config.go index 306c3122c9..a93e914d7b 100644 --- a/examples/lib/tour/04-working-with-config/02-handle-arbitrary-config.go +++ b/examples/lib/tour/04-working-with-config/02-handle-arbitrary-config.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/config" configcfg "github.com/open-component-model/ocm/pkg/contexts/config/config" diff --git a/examples/lib/tour/04-working-with-config/03-using-ocm-config.go b/examples/lib/tour/04-working-with-config/03-using-ocm-config.go index a4ee8e8fb6..cf8f5aa755 100644 --- a/examples/lib/tour/04-working-with-config/03-using-ocm-config.go +++ b/examples/lib/tour/04-working-with-config/03-using-ocm-config.go @@ -17,7 +17,6 @@ import ( ) func HandleOCMConfig(cfg *helper.Config) error { - // Although the configuration of an OCM context can // be done by a sequence of explicit calls the mechanism // shown in the example before, is used to provide a simple diff --git a/examples/lib/tour/04-working-with-config/04-write-config-type.go b/examples/lib/tour/04-working-with-config/04-write-config-type.go index 24c439cc55..403fbad1cb 100644 --- a/examples/lib/tour/04-working-with-config/04-write-config-type.go +++ b/examples/lib/tour/04-working-with-config/04-write-config-type.go @@ -93,7 +93,6 @@ type RepositoryTarget interface { // to a dedicated object, which wants to be configured. // --- begin method apply ---. func (c *ExampleConfigSpec) ApplyTo(_ cpi.Context, tgt interface{}) error { - switch t := tgt.(type) { // if the target is a credentials context // configure the credentials to be used for the @@ -148,7 +147,6 @@ func init() { // --- end init ---. func WriteConfigType(cfg *helper.Config) error { - // after preparing a new special config type // we can feed it into the config management. // because of the registration the config management diff --git a/examples/lib/tour/04-working-with-config/05-write-config-consumer.go b/examples/lib/tour/04-working-with-config/05-write-config-consumer.go index 67ca452ff1..bd1c578abd 100644 --- a/examples/lib/tour/04-working-with-config/05-write-config-consumer.go +++ b/examples/lib/tour/04-working-with-config/05-write-config-consumer.go @@ -5,6 +5,7 @@ import ( "sync" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/config/cpi" "github.com/open-component-model/ocm/pkg/contexts/credentials" diff --git a/examples/lib/tour/04-working-with-config/README.md b/examples/lib/tour/04-working-with-config/README.md index 0ec8a67c0c..3eef9b8a5d 100644 --- a/examples/lib/tour/04-working-with-config/README.md +++ b/examples/lib/tour/04-working-with-config/README.md @@ -562,7 +562,6 @@ object. ```go func (c *ExampleConfigSpec) ApplyTo(_ cpi.Context, tgt interface{}) error { - switch t := tgt.(type) { // if the target is a credentials context // configure the credentials to be used for the diff --git a/examples/lib/tour/05-transporting-component-versions/common.go b/examples/lib/tour/05-transporting-component-versions/common.go index df0297bf66..81fdab6c30 100644 --- a/examples/lib/tour/05-transporting-component-versions/common.go +++ b/examples/lib/tour/05-transporting-component-versions/common.go @@ -6,8 +6,8 @@ import ( "github.com/mandelsoft/goutils/errors" "github.com/mandelsoft/goutils/finalizer" - "github.com/open-component-model/ocm/pkg/blobaccess" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact" diff --git a/examples/lib/tour/05-transporting-component-versions/example.go b/examples/lib/tour/05-transporting-component-versions/example.go index 2c1540b289..1b1406342f 100644 --- a/examples/lib/tour/05-transporting-component-versions/example.go +++ b/examples/lib/tour/05-transporting-component-versions/example.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" ociidentity "github.com/open-component-model/ocm/pkg/contexts/credentials/builtin/oci/identity" "github.com/open-component-model/ocm/pkg/contexts/oci" diff --git a/examples/lib/tour/06-signing-component-versions/01-basic-signing.go b/examples/lib/tour/06-signing-component-versions/01-basic-signing.go index 0d40a7013c..b40dfe7f79 100644 --- a/examples/lib/tour/06-signing-component-versions/01-basic-signing.go +++ b/examples/lib/tour/06-signing-component-versions/01-basic-signing.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/composition" diff --git a/examples/lib/tour/06-signing-component-versions/02-using-context-settings.go b/examples/lib/tour/06-signing-component-versions/02-using-context-settings.go index 64b34cc251..faa2897cd6 100644 --- a/examples/lib/tour/06-signing-component-versions/02-using-context-settings.go +++ b/examples/lib/tour/06-signing-component-versions/02-using-context-settings.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mandelsoft/goutils/errors" + "github.com/open-component-model/ocm/examples/lib/helper" configcfg "github.com/open-component-model/ocm/pkg/contexts/config/config" "github.com/open-component-model/ocm/pkg/contexts/ocm" diff --git a/examples/lib/tour/06-signing-component-versions/common.go b/examples/lib/tour/06-signing-component-versions/common.go index 0b96555bcb..f0d013f572 100644 --- a/examples/lib/tour/06-signing-component-versions/common.go +++ b/examples/lib/tour/06-signing-component-versions/common.go @@ -8,9 +8,9 @@ import ( "github.com/mandelsoft/goutils/errors" "github.com/mandelsoft/goutils/finalizer" - "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/examples/lib/helper" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/ociartifact" diff --git a/examples/lib/transfer1/example.go b/examples/lib/transfer1/example.go index 30243752aa..f1904fe616 100644 --- a/examples/lib/transfer1/example.go +++ b/examples/lib/transfer1/example.go @@ -4,14 +4,14 @@ import ( "fmt" "os" + "github.com/mandelsoft/goutils/errors" // "github.com/mandelsoft/vfs/pkg/memoryfs" "github.com/mandelsoft/goutils/finalizer" "github.com/mandelsoft/vfs/pkg/osfs" "github.com/mandelsoft/vfs/pkg/vfs" - "github.com/open-component-model/ocm/pkg/blobaccess" - "github.com/mandelsoft/goutils/errors" "github.com/open-component-model/ocm/examples/lib/helper" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/accessobj" @@ -26,8 +26,10 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const componentName = "github.com/mandelsoft/test1" -const componentVersion = "0.1.0" +const ( + componentName = "github.com/mandelsoft/test1" + componentVersion = "0.1.0" +) const resourceName = "package" diff --git a/hack/Makefile b/hack/Makefile index d2de231042..a9ed4affbd 100644 --- a/hack/Makefile +++ b/hack/Makefile @@ -33,7 +33,7 @@ ifeq ("v$(JQ)","v0.0") deps += $(detected_OS)_jq endif -GOLANGCILINT_VERSION := "v1.54.2" +GOLANGCILINT_VERSION := "v1.59.1" GOLANGCILINTV := $(shell (golangci-lint --version 2>/dev/null || echo 0.0.0) | sed 's/.*v\([0-9\.]*\) .*/\1/') ifneq ("v$(GOLANGCILINTV)",$(GOLANGCILINT_VERSION)) deps += golangci-lint @@ -43,6 +43,16 @@ GO_BINDATA := $(shell (go-bindata -version 2>/dev/null || echo 0.0.0) | head -n ifneq ("v$(GO_BINDATA)",$(GO_BINDATA_VERSION)) deps += go-bindata endif +GCI_VERSION := "v0.13.4" +GCI := $(shell (gci --version 2>/dev/null || echo 0.0) | sed 's/.* \([0-9\.]*\).*/\1/') +ifneq ("v$(GCI)", $(GCI_VERSION)) + deps += gci +endif +GOFUMPT_VERSION := "v0.6.0" +GOFUMPT := $(shell (gofumpt --version 2>/dev/null || echo 0.0) | sed 's/\(v[0-9\.]*\).*/\1/') +ifneq ("$(GOFUMPT)", $(GOFUMPT_VERSION)) + deps += gofumpt +endif VAULT_VERSION := 1.16.2 VAULT := $(shell ($(LOCALBIN)/vault --version 2>/dev/null || echo 0.0) | sed 's/.*Vault v\([0-9\.]*\).*/\1/') ifneq ($(VAULT), $(VAULT_VERSION)) @@ -58,6 +68,14 @@ endif install-requirements: $(deps) $(GOPATH)/bin/goimports mdref # @$(REPO_ROOT)/hack/install-requirements.sh +.PHONY: gci +gci: + go install -v github.com/daixiang0/gci@$(GCI_VERSION) + +.PHONY: gofumpt +gofumpt: + go install -v mvdan.cc/gofumpt@$(GOFUMPT_VERSION) + .PHONY: golangci-lint golangci-lint: @# no recommended by website diff --git a/hack/check.sh b/hack/check.sh index 7f9ad288a7..c7e78b636a 100755 --- a/hack/check.sh +++ b/hack/check.sh @@ -4,6 +4,12 @@ set -e GOLANGCI_LINT_CONFIG_FILE="" +if [ "$1" == "--fix" ]; then + opt="--fix" + shift +fi + + for arg in "$@"; do case $arg in --golangci-lint-config=*) @@ -16,7 +22,7 @@ done echo "> Check" echo "Executing golangci-lint" -echo " golangci-lint run $GOLANGCI_LINT_CONFIG_FILE --timeout 10m $@" -golangci-lint run $GOLANGCI_LINT_CONFIG_FILE --timeout 10m $@ +echo " golangci-lint run $GOLANGCI_LINT_CONFIG_FILE $opt --timeout 10m $@" +golangci-lint run $GOLANGCI_LINT_CONFIG_FILE $opt --timeout 10m $@ echo "All checks successful" diff --git a/hack/format.sh b/hack/format.sh index c8267b2a16..1e19c9b977 100755 --- a/hack/format.sh +++ b/hack/format.sh @@ -12,27 +12,27 @@ pkgprefix="github.com/open-component-model/ocm" log "Format with gci" # gci write --custom-order --skip-generated -s standard -s blank -s dot -s default -s "Prefix(github.com/open-component-model/ocm)" GCIFMT=( -s standard -s blank -s dot -s default -s="prefix(${pkgprefix})" --custom-order ) -gci diff --skip-generated "${GCIFMT[@]}" $@ =")) }) - }) diff --git a/pkg/cobrautils/flag/path_array_test.go b/pkg/cobrautils/flag/path_array_test.go index c403dc7b67..95f3089618 100644 --- a/pkg/cobrautils/flag/path_array_test.go +++ b/pkg/cobrautils/flag/path_array_test.go @@ -29,5 +29,4 @@ var _ = Describe("path flags", func() { PathArrayVarPF(flags, &val, "path", "p", []string{`/foo/bar`, `other/path`}, "help message") Expect(val).To(Equal([]string{"/foo/bar", "other/path"})) }) - }) diff --git a/pkg/cobrautils/flag/path_array_win_test.go b/pkg/cobrautils/flag/path_array_win_test.go index 888954e4a9..7be5fbec6c 100644 --- a/pkg/cobrautils/flag/path_array_win_test.go +++ b/pkg/cobrautils/flag/path_array_win_test.go @@ -29,5 +29,4 @@ var _ = Describe("path flags", func() { PathArrayVarPF(flags, &val, "path", "p", []string{`C:\foo\bar`, `E:\other\path`}, "help message") Expect(val).To(Equal([]string{"C:/foo/bar", "E:/other/path"})) }) - }) diff --git a/pkg/cobrautils/flag/path_test.go b/pkg/cobrautils/flag/path_test.go index 1de8cecc33..dad81f3307 100644 --- a/pkg/cobrautils/flag/path_test.go +++ b/pkg/cobrautils/flag/path_test.go @@ -29,5 +29,4 @@ var _ = Describe("path flags", func() { PathVarP(flags, &val, "path", "p", `/t/bugrepo/postgresql-14.0.5.tgz`, "help message") Expect(val).To(Equal("/t/bugrepo/postgresql-14.0.5.tgz")) }) - }) diff --git a/pkg/cobrautils/flag/path_win_test.go b/pkg/cobrautils/flag/path_win_test.go index bea185436b..7c28732aa4 100644 --- a/pkg/cobrautils/flag/path_win_test.go +++ b/pkg/cobrautils/flag/path_win_test.go @@ -29,5 +29,4 @@ var _ = Describe("path flags", func() { PathVarP(flags, &val, "path", "p", `E:\t\bugrepo\postgresql-14.0.5.tgz`, "help message") Expect(val).To(Equal("E:/t/bugrepo/postgresql-14.0.5.tgz")) }) - }) diff --git a/pkg/cobrautils/flag/string_to_value_test.go b/pkg/cobrautils/flag/string_to_value_test.go index 5abcb54674..77f568e802 100644 --- a/pkg/cobrautils/flag/string_to_value_test.go +++ b/pkg/cobrautils/flag/string_to_value_test.go @@ -4,9 +4,8 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/spf13/pflag" - "github.com/mandelsoft/goutils/testutils" + "github.com/spf13/pflag" ) var _ = Describe("value map", func() { @@ -74,5 +73,4 @@ var _ = Describe("value map", func() { Expect(err).To(HaveOccurred()) Expect(err.Error()).To(Equal("invalid argument \"a\" for \"--flag\" flag: expected =")) }) - }) diff --git a/pkg/cobrautils/flag/yaml_test.go b/pkg/cobrautils/flag/yaml_test.go index 457cdb207a..3af124277c 100644 --- a/pkg/cobrautils/flag/yaml_test.go +++ b/pkg/cobrautils/flag/yaml_test.go @@ -51,5 +51,4 @@ var _ = Describe("yaml flags", func() { Expect(flags.Parse([]string{"--flag", value})).To(Succeed()) Expect(flag).To(Equal(&T{"va"})) }) - }) diff --git a/pkg/cobrautils/flagsets/configure_test.go b/pkg/cobrautils/flagsets/configure_test.go index 4ee0a76fab..acea6b9df4 100644 --- a/pkg/cobrautils/flagsets/configure_test.go +++ b/pkg/cobrautils/flagsets/configure_test.go @@ -60,5 +60,4 @@ var _ = Describe("configure", func() { Expect(flags.Parse([]string{"--entryType=t1", "--common=string", "--t1=value", "--t2=value"})).To(Succeed()) ExpectError(prov.GetConfigFor(opts)).To(MatchError(`option "t2" given, but not possible for entry type t1`)) }) - }) diff --git a/pkg/cobrautils/flagsets/utils_test.go b/pkg/cobrautils/flagsets/utils_test.go index 6112d9b722..91f83b0ba7 100644 --- a/pkg/cobrautils/flagsets/utils_test.go +++ b/pkg/cobrautils/flagsets/utils_test.go @@ -9,8 +9,10 @@ import ( type Config = flagsets.Config -var GetField = flagsets.GetField -var SetField = flagsets.SetField +var ( + GetField = flagsets.GetField + SetField = flagsets.SetField +) var _ = Describe("config", func() { Context("get", func() { diff --git a/pkg/common/accessio/cache_test.go b/pkg/common/accessio/cache_test.go index e11c58e5a4..07399def41 100644 --- a/pkg/common/accessio/cache_test.go +++ b/pkg/common/accessio/cache_test.go @@ -1,13 +1,14 @@ package accessio_test import ( - "github.com/mandelsoft/vfs/pkg/osfs" - "github.com/mandelsoft/vfs/pkg/vfs" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/open-component-model/ocm/pkg/blobaccess/blobaccess" + + "github.com/mandelsoft/vfs/pkg/osfs" + "github.com/mandelsoft/vfs/pkg/vfs" "github.com/opencontainers/go-digest" + "github.com/open-component-model/ocm/pkg/blobaccess/blobaccess" "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/common/accessio" ) diff --git a/pkg/common/accessio/resettablereader_test.go b/pkg/common/accessio/resettablereader_test.go index 3f6e646d8d..c19ae9742a 100644 --- a/pkg/common/accessio/resettablereader_test.go +++ b/pkg/common/accessio/resettablereader_test.go @@ -93,5 +93,4 @@ var _ = Describe("resettable reader", func() { Expect(vfs.Exists(osfs.New(), w.path)).To(BeFalse()) }) - }) diff --git a/pkg/common/accessio/retry_test.go b/pkg/common/accessio/retry_test.go index 45a3447d6d..470378ca06 100644 --- a/pkg/common/accessio/retry_test.go +++ b/pkg/common/accessio/retry_test.go @@ -13,8 +13,10 @@ import ( "github.com/open-component-model/ocm/pkg/common/accessio" ) -var Retry = accessio.Retry -var RetriableError = accessio.RetriableError +var ( + Retry = accessio.Retry + RetriableError = accessio.RetriableError +) var _ = Describe("retry", func() { It("retries to success", func() { diff --git a/pkg/common/accessobj/cachedblob_test.go b/pkg/common/accessobj/cachedblob_test.go index 4a66137bb8..be1fbcb7d8 100644 --- a/pkg/common/accessobj/cachedblob_test.go +++ b/pkg/common/accessobj/cachedblob_test.go @@ -112,5 +112,4 @@ var _ = Describe("cached blob", func() { Expect(err).To(Succeed()) Expect(len(dir)).To(Equal(0)) }) - }) diff --git a/pkg/common/history_test.go b/pkg/common/history_test.go index 018a90cb17..03852ff161 100644 --- a/pkg/common/history_test.go +++ b/pkg/common/history_test.go @@ -33,7 +33,6 @@ func New(n string, hist ...string) *Elem { } var _ = Describe("processing buffer", func() { - Context("history", func() { It("compare", func() { Expect(common.CompareHistoryElement(New("a"), New("b")) < 0).To(BeTrue()) @@ -57,7 +56,6 @@ var _ = Describe("processing buffer", func() { Expect(common.CompareHistoryElement(New("a", "a"), New("a")) > 0).To(BeTrue()) Expect(common.CompareHistoryElement(New("a", "a"), New("b")) < 0).To(BeTrue()) - }) It("sort", func() { s := []*Elem{ @@ -90,6 +88,5 @@ var _ = Describe("processing buffer", func() { Expect(s).To(Equal(r)) }) - }) }) diff --git a/pkg/common/printer_test.go b/pkg/common/printer_test.go index 05e525a3a3..6b0aa46fc8 100644 --- a/pkg/common/printer_test.go +++ b/pkg/common/printer_test.go @@ -6,14 +6,13 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/mandelsoft/goutils/testutils" "github.com/mandelsoft/logging" - "github.com/mandelsoft/goutils/testutils" ocmlog "github.com/open-component-model/ocm/pkg/logging" ) var _ = Describe("Printer", func() { - var buf *bytes.Buffer var printer Printer @@ -97,6 +96,5 @@ V[3] line 1 V[3] line 2 `)) }) - }) }) diff --git a/pkg/contexts/clictx/config/config_test.go b/pkg/contexts/clictx/config/config_test.go index 3d1299df52..b005a7059e 100644 --- a/pkg/contexts/clictx/config/config_test.go +++ b/pkg/contexts/clictx/config/config_test.go @@ -28,7 +28,6 @@ func normalize(i interface{}) ([]byte, error) { } var _ = Describe("command config", func() { - ocispec := ocireg.NewRepositorySpec("ghcr.io") ocidata, err := normalize(ocispec) @@ -41,9 +40,7 @@ var _ = Describe("command config", func() { specdata := "{\"ociRepositories\":{\"oci\":" + string(ocidata) + "},\"ocmRepositories\":{\"ocm\":" + string(ocmdata) + "},\"type\":\"" + config.OCMCmdConfigType + "\"}" Context("serialize", func() { - It("serializes config", func() { - cfg := config.New() err := cfg.AddOCIRepository("oci", ocispec) Expect(err).To(Succeed()) diff --git a/pkg/contexts/config/config/context_test.go b/pkg/contexts/config/config/context_test.go index 0ea5aa587a..8f24fea51a 100644 --- a/pkg/contexts/config/config/context_test.go +++ b/pkg/contexts/config/config/context_test.go @@ -25,7 +25,6 @@ func CheckRefs(ctx config.Context, n int) { } var _ = Describe("generic config handling", func() { - var scheme config.ConfigTypeScheme var cfgctx config.Context @@ -88,7 +87,6 @@ var _ = Describe("generic config handling", func() { }) It("it applies unknown type to existing context", func() { - cfg, err := cfgctx.GetConfigForData(testdataconfig, nil) Expect(err).To(Succeed()) diff --git a/pkg/contexts/config/config/dummy_test.go b/pkg/contexts/config/config/dummy_test.go index 321c378877..3c8c2bae35 100644 --- a/pkg/contexts/config/config/dummy_test.go +++ b/pkg/contexts/config/config/dummy_test.go @@ -80,6 +80,7 @@ func (d *dummyContext) getApplied() []*Config { d.update() return d.applied } + func (d *dummyContext) update() error { gen, err := d.config.ApplyTo(d.lastGeneration, d) d.lastGeneration = gen diff --git a/pkg/contexts/config/context_test.go b/pkg/contexts/config/context_test.go index 7bc1de1ec1..19f75f4695 100644 --- a/pkg/contexts/config/context_test.go +++ b/pkg/contexts/config/context_test.go @@ -14,7 +14,6 @@ import ( ) var _ = Describe("config handling", func() { - var scheme config.ConfigTypeScheme var cfgctx config.Context @@ -74,7 +73,6 @@ var _ = Describe("config handling", func() { }) It("it applies generic to new context", func() { - cfg := NewConfig("a", "b") data, err := json.Marshal(cfg) Expect(err).To(Succeed()) @@ -88,5 +86,4 @@ var _ = Describe("config handling", func() { d := newDummy(cfgctx) Expect(d.getApplied()).To(Equal([]*Config{cfg})) }) - }) diff --git a/pkg/contexts/config/dummy_test.go b/pkg/contexts/config/dummy_test.go index 15ecb8af85..72f59e1cdb 100644 --- a/pkg/contexts/config/dummy_test.go +++ b/pkg/contexts/config/dummy_test.go @@ -65,6 +65,7 @@ func (d *dummyContext) getApplied() []*Config { d.update() return d.applied } + func (d *dummyContext) update() error { gen, err := d.config.ApplyTo(d.lastGeneration, d) d.lastGeneration = gen diff --git a/pkg/contexts/config/internal/builder_test.go b/pkg/contexts/config/internal/builder_test.go index f7bd7ed4bb..aff15ecc8a 100644 --- a/pkg/contexts/config/internal/builder_test.go +++ b/pkg/contexts/config/internal/builder_test.go @@ -34,5 +34,4 @@ var _ = Describe("builder test", func() { Expect(ctx.ConfigTypes()).NotTo(BeIdenticalTo(local.DefaultConfigTypeScheme)) Expect(len(ctx.ConfigTypes().KnownTypeNames())).To(Equal(0)) }) - }) diff --git a/pkg/contexts/credentials/area_test.go b/pkg/contexts/credentials/area_test.go index df37deea50..7bc91a31f2 100644 --- a/pkg/contexts/credentials/area_test.go +++ b/pkg/contexts/credentials/area_test.go @@ -26,5 +26,4 @@ var _ = Describe("area test", func() { Expect(reflect.TypeOf(dctx).String()).To(Equal("*internal.gcWrapper")) Expect(dctx).To(BeIdenticalTo(DefaultContext)) }) - }) diff --git a/pkg/contexts/credentials/builtin/oci/identity/id_test.go b/pkg/contexts/credentials/builtin/oci/identity/id_test.go index 39e5644086..e516ef0ed7 100644 --- a/pkg/contexts/credentials/builtin/oci/identity/id_test.go +++ b/pkg/contexts/credentials/builtin/oci/identity/id_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("ctf management", func() { - Context("with path", func() { pat := credentials.ConsumerIdentity{ identity.ID_HOSTNAME: "host", @@ -143,5 +142,4 @@ var _ = Describe("ctf management", func() { Expect(identity.IdentityMatcher(pat, pat, id)).To(BeFalse()) }) }) - }) diff --git a/pkg/contexts/credentials/builtin/wget/identity/identity_test.go b/pkg/contexts/credentials/builtin/wget/identity/identity_test.go index 56c32c1fcb..263548988a 100644 --- a/pkg/contexts/credentials/builtin/wget/identity/identity_test.go +++ b/pkg/contexts/credentials/builtin/wget/identity/identity_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("wget credential management", func() { - Context("with path", func() { pat := credentials.ConsumerIdentity{ ID_HOSTNAME: "host", @@ -143,5 +142,4 @@ var _ = Describe("wget credential management", func() { Expect(IdentityMatcher(pat, pat, id)).To(BeFalse()) }) }) - }) diff --git a/pkg/contexts/credentials/config/config_test.go b/pkg/contexts/credentials/config/config_test.go index df88a0485f..e07492762f 100644 --- a/pkg/contexts/credentials/config/config_test.go +++ b/pkg/contexts/credentials/config/config_test.go @@ -8,6 +8,7 @@ import ( . "github.com/onsi/gomega" "github.com/mandelsoft/goutils/testutils" + "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/contexts/config" "github.com/open-component-model/ocm/pkg/contexts/credentials" @@ -36,7 +37,6 @@ var _ = Describe("generic credentials", func() { _ = props Context("serialize", func() { - It("serializes repository spec not in map", func() { mapdata := "{\"repositories\":{\"repository\":{\"repoName\":\"test\",\"type\":\"Memory\"}}}" type S struct { @@ -95,7 +95,6 @@ var _ = Describe("generic credentials", func() { }) It("composes a config for repositories", func() { - cfg := localconfig.New() cfg.AddRepository(repospec, direct) @@ -111,7 +110,6 @@ var _ = Describe("generic credentials", func() { }) It("composes a config for aliases", func() { - cfg := localconfig.New() cfg.AddAlias("alias", repospec, direct) @@ -207,6 +205,5 @@ consumers: Expect(result.Properties()).To(Equal(props)) }) - }) }) diff --git a/pkg/contexts/credentials/identity/hostpath/id_test.go b/pkg/contexts/credentials/identity/hostpath/id_test.go index c0b1148372..bbaaa2007d 100644 --- a/pkg/contexts/credentials/identity/hostpath/id_test.go +++ b/pkg/contexts/credentials/identity/hostpath/id_test.go @@ -14,7 +14,6 @@ func IdentityMatcher(pattern, cur, id cpi.ConsumerIdentity) bool { } var _ = Describe("ctf management", func() { - Context("with path", func() { pat := credentials.ConsumerIdentity{ hostpath.ID_HOSTNAME: "host", @@ -202,5 +201,4 @@ var _ = Describe("ctf management", func() { Expect(IdentityMatcher(pat, pat, id)).To(BeFalse()) }) }) - }) diff --git a/pkg/contexts/credentials/internal/builder_test.go b/pkg/contexts/credentials/internal/builder_test.go index a96db96b95..d686a7d485 100644 --- a/pkg/contexts/credentials/internal/builder_test.go +++ b/pkg/contexts/credentials/internal/builder_test.go @@ -55,5 +55,4 @@ var _ = Describe("builder test", func() { Expect(ctx.ConfigContext()).NotTo(BeIdenticalTo(config.DefaultContext())) Expect(len(ctx.ConfigContext().ConfigTypes().KnownTypeNames())).To(Equal(0)) }) - }) diff --git a/pkg/contexts/credentials/repositories/aliases/repo_test.go b/pkg/contexts/credentials/repositories/aliases/repo_test.go index 326d38dd56..1e98ba8ce6 100644 --- a/pkg/contexts/credentials/repositories/aliases/repo_test.go +++ b/pkg/contexts/credentials/repositories/aliases/repo_test.go @@ -15,7 +15,6 @@ import ( var DefaultContext = credentials.New() var _ = Describe("alias credentials", func() { - props := common.Properties{ "user": "USER", "password": "PASSWORD", @@ -68,5 +67,4 @@ var _ = Describe("alias credentials", func() { Expect(err).To(Succeed()) Expect(creds.Properties()).To(Equal(props)) }) - }) diff --git a/pkg/contexts/credentials/repositories/dockerconfig/repo_test.go b/pkg/contexts/credentials/repositories/dockerconfig/repo_test.go index da863d982a..e3e2e8c7b6 100644 --- a/pkg/contexts/credentials/repositories/dockerconfig/repo_test.go +++ b/pkg/contexts/credentials/repositories/dockerconfig/repo_test.go @@ -21,7 +21,6 @@ import ( ) var _ = Describe("docker config", func() { - props := common.Properties{ "username": "mandelsoft", "password": "password", diff --git a/pkg/contexts/credentials/repositories/gardenerconfig/repo_test.go b/pkg/contexts/credentials/repositories/gardenerconfig/repo_test.go index 5c51f5ed28..beb5a32418 100644 --- a/pkg/contexts/credentials/repositories/gardenerconfig/repo_test.go +++ b/pkg/contexts/credentials/repositories/gardenerconfig/repo_test.go @@ -197,5 +197,4 @@ var _ = Describe("gardener config", func() { Expect(err).ToNot(HaveOccurred()) Expect(credentialsFromRepo).To(Equal(expectedCreds)) }) - }) diff --git a/pkg/contexts/credentials/repositories/memory/config/config_test.go b/pkg/contexts/credentials/repositories/memory/config/config_test.go index ff1b2b48be..139c1770fe 100644 --- a/pkg/contexts/credentials/repositories/memory/config/config_test.go +++ b/pkg/contexts/credentials/repositories/memory/config/config_test.go @@ -14,7 +14,6 @@ import ( ) var _ = Describe("configure credentials", func() { - var env *Environment var ctx credentials.Context var cfg config.Context diff --git a/pkg/contexts/credentials/repositories/memory/repo_test.go b/pkg/contexts/credentials/repositories/memory/repo_test.go index 58af3b1828..0e7ca7b714 100644 --- a/pkg/contexts/credentials/repositories/memory/repo_test.go +++ b/pkg/contexts/credentials/repositories/memory/repo_test.go @@ -116,5 +116,4 @@ var _ = Describe("direct credentials", func() { Expect(err).To(Succeed()) Expect(creds.Properties()).To(Equal(props)) }) - }) diff --git a/pkg/contexts/credentials/repositories/npm/config_test.go b/pkg/contexts/credentials/repositories/npm/config_test.go index 06c1fa5bbc..177c607787 100644 --- a/pkg/contexts/credentials/repositories/npm/config_test.go +++ b/pkg/contexts/credentials/repositories/npm/config_test.go @@ -1,10 +1,10 @@ package npm_test import ( + . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - . "github.com/mandelsoft/goutils/testutils" "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/builtin/npm/identity" diff --git a/pkg/contexts/credentials/repositories/npm/repository_test.go b/pkg/contexts/credentials/repositories/npm/repository_test.go index 9e3619ee17..2e4442a504 100644 --- a/pkg/contexts/credentials/repositories/npm/repository_test.go +++ b/pkg/contexts/credentials/repositories/npm/repository_test.go @@ -17,7 +17,6 @@ import ( ) var _ = Describe("NPM config - .npmrc", func() { - props := common.Properties{ npmCredentials.ATTR_TOKEN: "npm_TOKEN", } diff --git a/pkg/contexts/credentials/repositories/vault/repo_int_test.go b/pkg/contexts/credentials/repositories/vault/repo_int_test.go index a49c19e9c4..bdabe36c05 100644 --- a/pkg/contexts/credentials/repositories/vault/repo_int_test.go +++ b/pkg/contexts/credentials/repositories/vault/repo_int_test.go @@ -80,7 +80,6 @@ var _ = Describe("vault config", func() { }) Context("authentication to vault and reading secrets", func() { - spec := me.NewRepositorySpec("http://"+VAULT_ADDRESS, me.WithPath(VAULT_PATH_REPO1), me.WithMountPath("secret")) spec1 := me.NewRepositorySpec("http://"+VAULT_ADDRESS, me.WithPath(VAULT_PATH_REPO2), me.WithMountPath("secret")) @@ -138,7 +137,8 @@ var _ = Describe("vault config", func() { Data: map[string]any{ "password1": "ocm-password-1", "password2": "ocm-password-2", - }}, + }, + }, vault.WithMountPath("secret"), )) @@ -164,7 +164,8 @@ var _ = Describe("vault config", func() { _ = Must(vaultClient.Secrets.KvV2Write(ctx, VAULT_PATH_REPO1+"/"+VAULT_SECRET_2, schema.KvV2WriteRequest{ Data: map[string]any{ "password2": "ocm-password-2", - }}, + }, + }, vault.WithMountPath("secret"), )) @@ -196,7 +197,8 @@ var _ = Describe("vault config", func() { _ = Must(vaultClient.Secrets.KvV2Write(ctx, VAULT_PATH_REPO1+"/"+VAULT_SECRET_2, schema.KvV2WriteRequest{ Data: map[string]any{ "password2": "ocm-password-2", - }}, + }, + }, vault.WithMountPath("secret"), )) @@ -253,7 +255,8 @@ var _ = Describe("vault config", func() { _ = Must(vaultClient.Secrets.KvV2Write(ctx, VAULT_PATH_REPO1+"/"+VAULT_SECRET_2, schema.KvV2WriteRequest{ Data: map[string]any{ "password2": "ocm-password-2", - }}, + }, + }, vault.WithMountPath("secret"), )) @@ -288,7 +291,8 @@ var _ = Describe("vault config", func() { _ = Must(vaultClient.Secrets.KvV2Write(ctx, VAULT_PATH_REPO1+"/"+VAULT_SECRET_2, schema.KvV2WriteRequest{ Data: map[string]any{ "password2": "ocm-password-2", - }}, + }, + }, vault.WithMountPath("secret"), )) diff --git a/pkg/contexts/datacontext/action/api/action_test.go b/pkg/contexts/datacontext/action/api/action_test.go index d2f0a301ab..be26d30149 100644 --- a/pkg/contexts/datacontext/action/api/action_test.go +++ b/pkg/contexts/datacontext/action/api/action_test.go @@ -75,8 +75,7 @@ type ActionResultV2 struct { Data string `json:"data"` } -type convertSpecV2 struct { -} +type convertSpecV2 struct{} func (c convertSpecV2) ConvertFrom(in *ActionSpec) (*ActionSpecV2, error) { return &ActionSpecV2{ @@ -92,8 +91,7 @@ func (c convertSpecV2) ConvertTo(in *ActionSpecV2) (*ActionSpec, error) { }, nil } -type convertResultV2 struct { -} +type convertResultV2 struct{} func (c convertResultV2) ConvertFrom(in *ActionResult) (*ActionResultV2, error) { return &ActionResultV2{ diff --git a/pkg/contexts/datacontext/action/api/registry_test.go b/pkg/contexts/datacontext/action/api/registry_test.go index ed9e8dd300..d5e22c04f3 100644 --- a/pkg/contexts/datacontext/action/api/registry_test.go +++ b/pkg/contexts/datacontext/action/api/registry_test.go @@ -36,7 +36,6 @@ var _ = Describe("action registry", func() { }) Context("plain", func() { - It("registers", func() { Expect(registry.SupportedActionVersions(NAME)).To(Equal([]string{"v1", "v2"})) }) diff --git a/pkg/contexts/datacontext/attrs/rootcertsattr/attr_test.go b/pkg/contexts/datacontext/attrs/rootcertsattr/attr_test.go index 96a91a6250..ef15153035 100644 --- a/pkg/contexts/datacontext/attrs/rootcertsattr/attr_test.go +++ b/pkg/contexts/datacontext/attrs/rootcertsattr/attr_test.go @@ -63,5 +63,4 @@ var _ = Describe("attribute", func() { Expect(cfgctx.ApplyConfig(cfg, "from test")).To(Succeed()) Expect(me.Get(ctx).HasRootCertificates()).To(BeTrue()) }) - }) diff --git a/pkg/contexts/datacontext/config/attrs/config_test.go b/pkg/contexts/datacontext/config/attrs/config_test.go index c410fd705b..4b4eb7a558 100644 --- a/pkg/contexts/datacontext/config/attrs/config_test.go +++ b/pkg/contexts/datacontext/config/attrs/config_test.go @@ -19,8 +19,7 @@ func init() { datacontext.RegisterAttributeType(ATTR_KEY, AttributeType{}) } -type AttributeType struct { -} +type AttributeType struct{} func (a AttributeType) Name() string { return ATTR_KEY @@ -60,9 +59,7 @@ var _ = Describe("generic attributes", func() { }) Context("applies", func() { - It("applies later attribute config", func() { - sub := credentials.WithConfigs(ctx).New() spec := local.New() Expect(spec.AddAttribute(ATTR_KEY, attribute)).To(Succeed()) @@ -72,7 +69,6 @@ var _ = Describe("generic attributes", func() { }) It("applies earlier attribute config", func() { - spec := local.New() Expect(spec.AddAttribute(ATTR_KEY, attribute)).To(Succeed()) Expect(ctx.ApplyConfig(spec, "test")).To(Succeed()) diff --git a/pkg/contexts/datacontext/config/logging/config_test.go b/pkg/contexts/datacontext/config/logging/config_test.go index 2c10fc9147..d57a017c79 100644 --- a/pkg/contexts/datacontext/config/logging/config_test.go +++ b/pkg/contexts/datacontext/config/logging/config_test.go @@ -36,7 +36,7 @@ var _ = Describe("logging configuration", func() { }) AfterEach(func() { - //logging.SetDefaultContext(orig) + // logging.SetDefaultContext(orig) }) _ = cfg _ = orig diff --git a/pkg/contexts/datacontext/gc_test.go b/pkg/contexts/datacontext/gc_test.go index 1caad0c1f0..23022c9ffd 100644 --- a/pkg/contexts/datacontext/gc_test.go +++ b/pkg/contexts/datacontext/gc_test.go @@ -23,7 +23,6 @@ var _ = Describe("area test", func() { runtime.GC() time.Sleep(time.Second) Expect(r.Get()).To(ConsistOf(id)) - }) It("provides second reference", func() { diff --git a/pkg/contexts/oci/art_test.go b/pkg/contexts/oci/art_test.go index c0bf38dfae..1e722090bb 100644 --- a/pkg/contexts/oci/art_test.go +++ b/pkg/contexts/oci/art_test.go @@ -35,5 +35,4 @@ var _ = Describe("art parsing", func() { CheckArt("ubu@ntu", nil) CheckArt("ubu@sha256:123", nil) }) - }) diff --git a/pkg/contexts/oci/artdesc/utils_test.go b/pkg/contexts/oci/artdesc/utils_test.go index 55a88525ea..2a598a80ad 100644 --- a/pkg/contexts/oci/artdesc/utils_test.go +++ b/pkg/contexts/oci/artdesc/utils_test.go @@ -8,7 +8,6 @@ import ( ) var _ = Describe("utils", func() { - It("strips media type", func() { Expect(artdesc.ToContentMediaType(artdesc.MediaTypeImageManifest)).To(Equal("application/vnd.oci.image.manifest.v1")) Expect(artdesc.ToContentMediaType(artdesc.MediaTypeImageIndex)).To(Equal("application/vnd.oci.image.index.v1")) diff --git a/pkg/contexts/oci/config/config_test.go b/pkg/contexts/oci/config/config_test.go index 1a1fa5b3d1..3cc1b311fd 100644 --- a/pkg/contexts/oci/config/config_test.go +++ b/pkg/contexts/oci/config/config_test.go @@ -25,7 +25,6 @@ func normalize(i interface{}) ([]byte, error) { } var _ = Describe("oci config", func() { - spec := ocireg.NewRepositorySpec("ghcr.io") data, err := normalize(spec) Expect(err).To(Succeed()) diff --git a/pkg/contexts/oci/cpi/utils_test.go b/pkg/contexts/oci/cpi/utils_test.go index e325c5ebcb..7f5fa83475 100644 --- a/pkg/contexts/oci/cpi/utils_test.go +++ b/pkg/contexts/oci/cpi/utils_test.go @@ -59,5 +59,4 @@ var _ = Describe("OCI CPI utils", func() { "a/b", })) }) - }) diff --git a/pkg/contexts/oci/grammar/grammar_test.go b/pkg/contexts/oci/grammar/grammar_test.go index 4b6172f1b2..4d9ddee88d 100644 --- a/pkg/contexts/oci/grammar/grammar_test.go +++ b/pkg/contexts/oci/grammar/grammar_test.go @@ -38,12 +38,14 @@ func Type(t string) string { } return t + "::" } + func Sub(t string) string { if t == "" { return t } return "/" + t } + func Vers(t string) string { if t == "" { return t @@ -52,7 +54,6 @@ func Vers(t string) string { } var _ = Describe("ref matching", func() { - Context("parts", func() { It("path port", func() { Check("/some/path/docker.sock:100", tool.Anchored(tool.Capture(PathPortRegexp)), "/some/path/docker.sock:100") @@ -80,5 +81,4 @@ var _ = Describe("ref matching", func() { CheckURI("DockerDaemon::unix://some/path/docker.sock:100//repo:test", t, s, p[1:], r, v, "") }) }) - }) diff --git a/pkg/contexts/oci/internal/builder_test.go b/pkg/contexts/oci/internal/builder_test.go index a3a4e77b55..ea13e485a1 100644 --- a/pkg/contexts/oci/internal/builder_test.go +++ b/pkg/contexts/oci/internal/builder_test.go @@ -68,5 +68,4 @@ var _ = Describe("builder test", func() { Expect(ctx.CredentialsContext()).NotTo(BeIdenticalTo(credentials.DefaultContext())) Expect(len(ctx.CredentialsContext().RepositoryTypes().KnownTypeNames())).To(Equal(0)) }) - }) diff --git a/pkg/contexts/oci/ociutils/helm/sympath/walk_test.go b/pkg/contexts/oci/ociutils/helm/sympath/walk_test.go index c27278adcd..afe642d28a 100644 --- a/pkg/contexts/oci/ociutils/helm/sympath/walk_test.go +++ b/pkg/contexts/oci/ociutils/helm/sympath/walk_test.go @@ -73,7 +73,7 @@ func makeTree(t *testing.T) { fd.Close() } } else { - if err := os.Mkdir(path, 0770); err != nil { + if err := os.Mkdir(path, 0o770); err != nil { t.Fatalf("makeTree: %v", err) } } diff --git a/pkg/contexts/oci/ociutils/print.go b/pkg/contexts/oci/ociutils/print.go index 0637020d08..fe5678a4fe 100644 --- a/pkg/contexts/oci/ociutils/print.go +++ b/pkg/contexts/oci/ociutils/print.go @@ -129,7 +129,7 @@ func PrintIndex(pr common.Printer, i cpi.IndexAccess, listFiles bool) { pr.Printf(" digest: %s\n", l.Digest) if l.Platform != nil { pr.Printf(" platform:\n") - pr := pr.AddGap(" ") //nolint: govet // yes + pr := pr.AddGap(" ") optS(pr, "OS ", l.Platform.OS) optS(pr, "Architecture ", l.Platform.Architecture) optS(pr, "OSCersion ", l.Platform.OSVersion) diff --git a/pkg/contexts/oci/ref_test.go b/pkg/contexts/oci/ref_test.go index dd72548edf..ba64f812a3 100644 --- a/pkg/contexts/oci/ref_test.go +++ b/pkg/contexts/oci/ref_test.go @@ -23,6 +23,7 @@ func Type(t string) string { } return t + "::" } + func FileFormat(t, f string) string { if t == "" { return f @@ -32,6 +33,7 @@ func FileFormat(t, f string) string { } return t + "+" + f } + func FileType(t, f string) string { if t != "" { return t @@ -39,18 +41,21 @@ func FileType(t, f string) string { return f } } + func Scheme(s string) string { if s == "" { return s } return s + "://" } + func Sub(t string) string { if t == "" { return t } return "/" + t } + func Vers(t, d string) string { if t == "" && d == "" { return "" @@ -559,7 +564,6 @@ var _ = Describe("ref parsing", func() { CheckRef("::ghcr.io/", &oci.RefSpec{UniformRepositorySpec: ghcr}) }) It("succeeds", func() { - CheckRef("ubuntu", &oci.RefSpec{UniformRepositorySpec: docker, ArtSpec: oci.ArtSpec{Repository: "library/ubuntu"}}) CheckRef("ubuntu:v1", &oci.RefSpec{UniformRepositorySpec: docker, ArtSpec: oci.ArtSpec{Repository: "library/ubuntu", Tag: &tag}}) CheckRef("test/ubuntu", &oci.RefSpec{UniformRepositorySpec: docker, ArtSpec: oci.ArtSpec{Repository: "test/ubuntu"}}) @@ -702,7 +706,6 @@ var _ = Describe("ref parsing", func() { Info: "/tmp/ctf", }, }) - }) It("json spec", func() { @@ -757,7 +760,6 @@ var _ = Describe("ref parsing", func() { CheckRef("test/ubuntu@4711", nil) CheckRef("test/ubuntu:v1@4711", nil) CheckRef("ghcr.io/test/ubuntu:v1@4711", nil) - }) It("repo", func() { CheckRepo("ghcr.io", &oci.UniformRepositorySpec{ diff --git a/pkg/contexts/oci/repositories/artifactset/artifactset_test.go b/pkg/contexts/oci/repositories/artifactset/artifactset_test.go index dfd00d28cf..d49b03050f 100644 --- a/pkg/contexts/oci/repositories/artifactset/artifactset_test.go +++ b/pkg/contexts/oci/repositories/artifactset/artifactset_test.go @@ -46,7 +46,7 @@ var _ = Describe("artifact management", func() { }) It("creates with default format", func() { - a, err := artifactset.FormatDirectory.Create("test", opts, 0700) + a, err := artifactset.FormatDirectory.Create("test", opts, 0o700) Expect(err).To(Succeed()) Expect(vfs.DirExists(tempfs, "test/"+artifactset.BlobsDirectoryName)).To(BeTrue()) @@ -63,7 +63,7 @@ var _ = Describe("artifact management", func() { opts, err := accessio.AccessOptions(&artifactset.Options{}, opts, artifactset.StructureFormat(format)) Expect(err).To(Succeed()) - a, err := artifactset.FormatDirectory.Create("test", opts, 0700) + a, err := artifactset.FormatDirectory.Create("test", opts, 0o700) Expect(err).To(Succeed()) Expect(vfs.DirExists(tempfs, "test/"+artifactset.BlobsDirectoryName)).To(BeTrue()) @@ -91,7 +91,7 @@ var _ = Describe("artifact management", func() { opts, err := accessio.AccessOptions(&artifactset.Options{}, opts, artifactset.StructureFormat(format)) Expect(err).To(Succeed()) - a, err := artifactset.FormatTGZ.Create("test.tgz", opts, 0600) + a, err := artifactset.FormatTGZ.Create("test.tgz", opts, 0o600) Expect(err).To(Succeed()) defaultManifestFill(a) @@ -144,7 +144,7 @@ var _ = Describe("artifact management", func() { opts, err := accessio.AccessOptions(&artifactset.Options{FormatVersion: format}, opts, accessio.File(file)) Expect(err).To(Succeed()) - a, err := artifactset.FormatTGZ.Create("", opts, 0600) + a, err := artifactset.FormatTGZ.Create("", opts, 0o600) Expect(err).To(Succeed()) defaultManifestFill(a) @@ -192,7 +192,7 @@ var _ = Describe("artifact management", func() { TestForAllFormats("read from filesystem artifact", func(format string) { opts := Must(accessio.AccessOptions(&artifactset.Options{}, opts, artifactset.StructureFormat(format))) - a := Must(artifactset.FormatDirectory.Create("test", opts, 0700)) + a := Must(artifactset.FormatDirectory.Create("test", opts, 0o700)) Expect(vfs.DirExists(tempfs, "test/"+artifactset.BlobsDirectoryName)).To(BeTrue()) defaultManifestFill(a) Expect(a.Close()).To(Succeed()) @@ -211,7 +211,7 @@ var _ = Describe("artifact management", func() { TestForAllFormats("read from tgz artifact", func(format string) { opts := Must(accessio.AccessOptions(&artifactset.Options{}, opts, artifactset.StructureFormat(format))) - a := Must(artifactset.FormatTGZ.Create("test.tgz", opts, 0700)) + a := Must(artifactset.FormatTGZ.Create("test.tgz", opts, 0o700)) defaultManifestFill(a) Expect(a.Close()).To(Succeed()) diff --git a/pkg/contexts/oci/repositories/ctf/ctf_test.go b/pkg/contexts/oci/repositories/ctf/ctf_test.go index 8243f01f5c..ac0ad430d8 100644 --- a/pkg/contexts/oci/repositories/ctf/ctf_test.go +++ b/pkg/contexts/oci/repositories/ctf/ctf_test.go @@ -8,7 +8,6 @@ import ( . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/open-component-model/ocm/pkg/blobaccess" . "github.com/open-component-model/ocm/pkg/contexts/oci/repositories/ctf/testhelper" "github.com/mandelsoft/goutils/errors" @@ -18,6 +17,7 @@ import ( "github.com/mandelsoft/vfs/pkg/vfs" "github.com/opencontainers/go-digest" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/accessobj" "github.com/open-component-model/ocm/pkg/contexts/oci" @@ -52,7 +52,7 @@ var _ = Describe("ctf management", func() { var finalize finalizer.Finalizer defer Defer(finalize.Finalize) - r := Must(ctf.FormatDirectory.Create(oci.DefaultContext(), "test", &spec.StandardOptions, 0700)) + r := Must(ctf.FormatDirectory.Create(oci.DefaultContext(), "test", &spec.StandardOptions, 0o700)) finalize.Close(r) Expect(vfs.DirExists(tempfs, "test/"+ctf.BlobsDirectoryName)).To(BeTrue()) diff --git a/pkg/contexts/oci/repositories/ctf/synthesis_test.go b/pkg/contexts/oci/repositories/ctf/synthesis_test.go index dbd290a98b..11ac47c368 100644 --- a/pkg/contexts/oci/repositories/ctf/synthesis_test.go +++ b/pkg/contexts/oci/repositories/ctf/synthesis_test.go @@ -4,7 +4,6 @@ import ( . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/open-component-model/ocm/pkg/blobaccess/blobaccess" . "github.com/open-component-model/ocm/pkg/contexts/oci/repositories/ctf/testhelper" "github.com/mandelsoft/filepath/pkg/filepath" @@ -13,6 +12,7 @@ import ( "github.com/mandelsoft/vfs/pkg/vfs" "github.com/opencontainers/go-digest" + "github.com/open-component-model/ocm/pkg/blobaccess/blobaccess" "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/accessobj" "github.com/open-component-model/ocm/pkg/contexts/oci" @@ -117,7 +117,7 @@ var _ = Describe("syntheses", func() { nested := finalize.Nested() // setup the scene - r := Must(ctf.FormatDirectory.Create(oci.DefaultContext(), "test", &spec.StandardOptions, 0700)) + r := Must(ctf.FormatDirectory.Create(oci.DefaultContext(), "test", &spec.StandardOptions, 0o700)) nested.Close(r, "create ctf") n := Must(r.LookupNamespace("mandelsoft/test")) nested.Close(n, "ns") diff --git a/pkg/contexts/oci/repositories/ctf/testhelper/fill.go b/pkg/contexts/oci/repositories/ctf/testhelper/fill.go index a63715c56e..653994e27c 100644 --- a/pkg/contexts/oci/repositories/ctf/testhelper/fill.go +++ b/pkg/contexts/oci/repositories/ctf/testhelper/fill.go @@ -14,7 +14,6 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -//nolint:gosec // digests of test manifests const ( TAG = "v1" DIGEST_MANIFEST = "3d05e105e350edf5be64fe356f4906dd3f9bf442a279e4142db9879bba8e677a" diff --git a/pkg/contexts/oci/repositories/ocireg/namespace.go b/pkg/contexts/oci/repositories/ocireg/namespace.go index 80e5b194af..423b2d7614 100644 --- a/pkg/contexts/oci/repositories/ocireg/namespace.go +++ b/pkg/contexts/oci/repositories/ocireg/namespace.go @@ -83,7 +83,6 @@ func (n *NamespaceContainer) getPusher(vers string) (resolve.Pusher, error) { var err error resolver, err = n.repo.getResolver(n.impl.GetNamespace()) - if err != nil { return nil, fmt.Errorf("unable get resolver: %w", err) } diff --git a/pkg/contexts/oci/repositories/ocireg/repository.go b/pkg/contexts/oci/repositories/ocireg/repository.go index a967d1940d..d20f92441f 100644 --- a/pkg/contexts/oci/repositories/ocireg/repository.go +++ b/pkg/contexts/oci/repositories/ocireg/repository.go @@ -194,7 +194,6 @@ func (r *RepositoryImpl) ExistsArtifact(name string, version string) (bool, erro } ref := r.GetRef(name, version) _, _, err = res.Resolve(context.Background(), ref) - if err != nil { if errdefs.IsNotFound(err) { return false, nil diff --git a/pkg/contexts/oci/testhelper/manifests.go b/pkg/contexts/oci/testhelper/manifests.go index ceee04ac82..c9756bc262 100644 --- a/pkg/contexts/oci/testhelper/manifests.go +++ b/pkg/contexts/oci/testhelper/manifests.go @@ -1,4 +1,3 @@ -//nolint:gosec // digests of test manifests package testhelper import ( diff --git a/pkg/contexts/oci/transfer/transfer_test.go b/pkg/contexts/oci/transfer/transfer_test.go index 229fe29c34..9fdd16564d 100644 --- a/pkg/contexts/oci/transfer/transfer_test.go +++ b/pkg/contexts/oci/transfer/transfer_test.go @@ -17,11 +17,12 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/oci/transfer/filters" ) -const OUT = "/tmp/res" -const OCIPATH = "/tmp/oci" +const ( + OUT = "/tmp/res" + OCIPATH = "/tmp/oci" +) var _ = Describe("transfer OCI artifacts", func() { - var env *Builder var idesc *artdesc.Descriptor @@ -46,7 +47,7 @@ var _ = Describe("transfer OCI artifacts", func() { art := Must(src.LookupArtifact(OCINAMESPACE3, OCIINDEXVERSION)) finalize.Close(art, "source artifact") - tgt := Must(ctf.Create(env.OCIContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCIContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer Close(tgt, "target") ns := Must(tgt.LookupNamespace(OCINAMESPACE3)) defer Close(ns, "target namespace") @@ -94,7 +95,6 @@ var _ = Describe("transfer OCI artifacts", func() { data = Must(blob.Get()) Expect(string(data)).To(Equal(OCILAYER2)) Expect(manifests[2].Platform).To(Equal(&artdesc.Platform{OS: "darwin", Architecture: "arm64"})) - }) Context("with filter", func() { @@ -108,7 +108,7 @@ var _ = Describe("transfer OCI artifacts", func() { art := Must(src.LookupArtifact(OCINAMESPACE3, OCIINDEXVERSION)) finalize.Close(art, "source artifact") - tgt := Must(ctf.Create(env.OCIContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCIContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer Close(tgt, "target") ns := Must(tgt.LookupNamespace(OCINAMESPACE3)) defer Close(ns, "target namespace") @@ -158,7 +158,7 @@ var _ = Describe("transfer OCI artifacts", func() { art := Must(src.LookupArtifact(OCINAMESPACE3, OCIINDEXVERSION)) finalize.Close(art, "source artifact") - tgt := Must(ctf.Create(env.OCIContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCIContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer Close(tgt, "target") ns := Must(tgt.LookupNamespace(OCINAMESPACE3)) defer Close(ns, "target namespace") diff --git a/pkg/contexts/ocm/accessmethods/github/method_test.go b/pkg/contexts/ocm/accessmethods/github/method_test.go index bc285b8a41..e7b23c1a9e 100644 --- a/pkg/contexts/ocm/accessmethods/github/method_test.go +++ b/pkg/contexts/ocm/accessmethods/github/method_test.go @@ -51,7 +51,6 @@ func NewTestClient(fn RoundTripFunc) *http.Client { return &http.Client{ Transport: fn, } - } var _ = Describe("Method", func() { diff --git a/pkg/contexts/ocm/accessmethods/localblob/method_test.go b/pkg/contexts/ocm/accessmethods/localblob/method_test.go index dd1a58c0e4..5298fea2a9 100644 --- a/pkg/contexts/ocm/accessmethods/localblob/method_test.go +++ b/pkg/contexts/ocm/accessmethods/localblob/method_test.go @@ -20,15 +20,16 @@ import ( "github.com/open-component-model/ocm/pkg/runtime" ) -const CTF = "ctf" -const COMPONENT = "fabianburth.org/component" -const VERSION = "v1.0" -const ARTIFACT_NAME = "artifact" -const ARTIFACT_VERSION = "v1.0" +const ( + CTF = "ctf" + COMPONENT = "fabianburth.org/component" + VERSION = "v1.0" + ARTIFACT_NAME = "artifact" + ARTIFACT_VERSION = "v1.0" +) var _ = Describe("Method", func() { - - var data = `globalAccess: + data := `globalAccess: digest: sha256:1bf729fa00e355199e711933ccfa27467ee3d2de1343aef2a7c1ecbdf885e63a mediaType: application/tar+gzip ref: ghcr.io/vasu1124/ocm/component-descriptors/github.com/vasu1124/introspect-delivery diff --git a/pkg/contexts/ocm/accessmethods/localfsblob/method_test.go b/pkg/contexts/ocm/accessmethods/localfsblob/method_test.go index 09da7dc696..bbd3e093ab 100644 --- a/pkg/contexts/ocm/accessmethods/localfsblob/method_test.go +++ b/pkg/contexts/ocm/accessmethods/localfsblob/method_test.go @@ -12,8 +12,7 @@ import ( ) var _ = Describe("Method", func() { - - var data = `globalAccess: + data := `globalAccess: digest: sha256:1bf729fa00e355199e711933ccfa27467ee3d2de1343aef2a7c1ecbdf885e63a mediaType: application/tar+gzip ref: ghcr.io/vasu1124/ocm/component-descriptors/github.com/vasu1124/introspect-delivery diff --git a/pkg/contexts/ocm/accessmethods/maven/method_test.go b/pkg/contexts/ocm/accessmethods/maven/method_test.go index a5dc7c9223..a6e3df6beb 100644 --- a/pkg/contexts/ocm/accessmethods/maven/method_test.go +++ b/pkg/contexts/ocm/accessmethods/maven/method_test.go @@ -4,8 +4,6 @@ import ( "crypto" "time" - "github.com/open-component-model/ocm/pkg/maven/maventest" - . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -15,6 +13,7 @@ import ( me "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/maven" "github.com/open-component-model/ocm/pkg/contexts/ocm/cpi" "github.com/open-component-model/ocm/pkg/iotools" + "github.com/open-component-model/ocm/pkg/maven/maventest" "github.com/open-component-model/ocm/pkg/mime" "github.com/open-component-model/ocm/pkg/utils/tarutils" ) diff --git a/pkg/contexts/ocm/accessmethods/npm/method_test.go b/pkg/contexts/ocm/accessmethods/npm/method_test.go index bb74c94412..0e00ec152a 100644 --- a/pkg/contexts/ocm/accessmethods/npm/method_test.go +++ b/pkg/contexts/ocm/accessmethods/npm/method_test.go @@ -3,21 +3,23 @@ package npm_test import ( "crypto" + . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + . "github.com/open-component-model/ocm/pkg/env" + . "github.com/open-component-model/ocm/pkg/env/builder" - . "github.com/mandelsoft/goutils/testutils" "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/npm" "github.com/open-component-model/ocm/pkg/contexts/ocm/cpi" - . "github.com/open-component-model/ocm/pkg/env" - . "github.com/open-component-model/ocm/pkg/env/builder" "github.com/open-component-model/ocm/pkg/iotools" "github.com/open-component-model/ocm/pkg/mime" ) -const NPMPATH = "/testdata/registry" -const FAILPATH = "/testdata/failregistry" +const ( + NPMPATH = "/testdata/registry" + FAILPATH = "/testdata/failregistry" +) var _ = Describe("Method", func() { var env *Builder diff --git a/pkg/contexts/ocm/accessmethods/ociartifact/method_test.go b/pkg/contexts/ocm/accessmethods/ociartifact/method_test.go index fce7b5a706..093533e10e 100644 --- a/pkg/contexts/ocm/accessmethods/ociartifact/method_test.go +++ b/pkg/contexts/ocm/accessmethods/ociartifact/method_test.go @@ -3,10 +3,10 @@ package ociartifact_test import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/open-component-model/ocm/pkg/blobaccess/blobaccess" . "github.com/open-component-model/ocm/pkg/contexts/oci/testhelper" . "github.com/open-component-model/ocm/pkg/env/builder" + "github.com/open-component-model/ocm/pkg/blobaccess/blobaccess" "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/contexts/credentials" "github.com/open-component-model/ocm/pkg/contexts/oci" @@ -15,8 +15,10 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/cpi/accspeccpi" ) -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" +const ( + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) var _ = Describe("Method", func() { var env *Builder diff --git a/pkg/contexts/ocm/accessmethods/ociblob/method_test.go b/pkg/contexts/ocm/accessmethods/ociblob/method_test.go index 6f8c92eb7d..f673bb37ad 100644 --- a/pkg/contexts/ocm/accessmethods/ociblob/method_test.go +++ b/pkg/contexts/ocm/accessmethods/ociblob/method_test.go @@ -13,8 +13,10 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/cpi" ) -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" +const ( + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) var _ = Describe("Method", func() { var env *Builder diff --git a/pkg/contexts/ocm/accessmethods/plugin/cmd_test.go b/pkg/contexts/ocm/accessmethods/plugin/cmd_test.go index 84f681e386..af64f7a942 100644 --- a/pkg/contexts/ocm/accessmethods/plugin/cmd_test.go +++ b/pkg/contexts/ocm/accessmethods/plugin/cmd_test.go @@ -19,8 +19,10 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/registration" ) -const CA = "/tmp/ca" -const VERSION = "v1" +const ( + CA = "/tmp/ca" + VERSION = "v1" +) var _ = Describe("Add with new access method", func() { var env *Environment diff --git a/pkg/contexts/ocm/accessmethods/plugin/method_test.go b/pkg/contexts/ocm/accessmethods/plugin/method_test.go index c70b49389b..a3af2cf8c6 100644 --- a/pkg/contexts/ocm/accessmethods/plugin/method_test.go +++ b/pkg/contexts/ocm/accessmethods/plugin/method_test.go @@ -19,10 +19,12 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ctf" ) -const ARCH = "ctf" -const COMP = "github.com/mandelsoft/comp" -const VERS = "1.0.0" -const PROVIDER = "mandelsoft" +const ( + ARCH = "ctf" + COMP = "github.com/mandelsoft/comp" + VERS = "1.0.0" + PROVIDER = "mandelsoft" +) var _ = Describe("setup plugin cache", func() { var ctx ocm.Context @@ -54,7 +56,6 @@ someattr: value }) It("registers access methods", func() { - env.OCMCommonTransport(ARCH, accessio.FormatDirectory, func() { env.Component(COMP, func() { env.Version(VERS, func() { diff --git a/pkg/contexts/ocm/accessmethods/relativeociref/method_test.go b/pkg/contexts/ocm/accessmethods/relativeociref/method_test.go index 8c54dfdb8c..65de51186d 100644 --- a/pkg/contexts/ocm/accessmethods/relativeociref/method_test.go +++ b/pkg/contexts/ocm/accessmethods/relativeociref/method_test.go @@ -4,12 +4,12 @@ import ( . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/open-component-model/ocm/pkg/blobaccess/blobaccess" . "github.com/open-component-model/ocm/pkg/contexts/oci/testhelper" . "github.com/open-component-model/ocm/pkg/env/builder" "github.com/mandelsoft/goutils/finalizer" + "github.com/open-component-model/ocm/pkg/blobaccess/blobaccess" "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/accessobj" "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/relativeociref" @@ -19,12 +19,16 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/utils" ) -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" +const ( + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) -const COMP = "acme.org/compo" -const COMPVERS = "v1.0.0" -const RES = "ref" +const ( + COMP = "acme.org/compo" + COMPVERS = "v1.0.0" + RES = "ref" +) var _ = Describe("Method", func() { var env *Builder diff --git a/pkg/contexts/ocm/accessmethods/relativeociref/transfer_test.go b/pkg/contexts/ocm/accessmethods/relativeociref/transfer_test.go index ca8f747d84..5435603a1d 100644 --- a/pkg/contexts/ocm/accessmethods/relativeociref/transfer_test.go +++ b/pkg/contexts/ocm/accessmethods/relativeociref/transfer_test.go @@ -66,7 +66,7 @@ var _ = Describe("Transfer handler", func() { Expect(err).To(Succeed()) cv, err := src.LookupComponentVersion(COMP, COMPVERS) Expect(err).To(Succeed()) - tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env) + tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env) Expect(err).To(Succeed()) defer tgt.Close() opts := &standard.Options{} @@ -121,7 +121,7 @@ var _ = Describe("Transfer handler", func() { cv, err := src.LookupComponentVersion(COMP, COMPVERS) Expect(err).To(Succeed()) - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer tgt.Close() opts := &standard.Options{} opts.SetResourcesByValue(true) diff --git a/pkg/contexts/ocm/accessmethods/wget/method_test.go b/pkg/contexts/ocm/accessmethods/wget/method_test.go index 983dd8198a..f822378437 100644 --- a/pkg/contexts/ocm/accessmethods/wget/method_test.go +++ b/pkg/contexts/ocm/accessmethods/wget/method_test.go @@ -406,5 +406,4 @@ var _ = Describe("wget access method", func() { noredirectContent := Must(noredirectMethod.Get()) Expect(string(noredirectContent)).To(Equal(NOREDIRECT_CONTENT)) }) - }) diff --git a/pkg/contexts/ocm/attrs/signingattr/attr_test.go b/pkg/contexts/ocm/attrs/signingattr/attr_test.go index eaad443bb0..b79ce8b1c7 100644 --- a/pkg/contexts/ocm/attrs/signingattr/attr_test.go +++ b/pkg/contexts/ocm/attrs/signingattr/attr_test.go @@ -72,5 +72,4 @@ EVQVGDF6KNU= Expect(cfgctx.ApplyConfig(cfg, "from test")).To(Succeed()) Expect(rootcertsattr.Get(ocmctx).HasRootCertificates()).To(BeTrue()) }) - }) diff --git a/pkg/contexts/ocm/blobhandler/handlers/generic/maven/blobhandler_test.go b/pkg/contexts/ocm/blobhandler/handlers/generic/maven/blobhandler_test.go index 36990c2dc2..66e6eb4d69 100644 --- a/pkg/contexts/ocm/blobhandler/handlers/generic/maven/blobhandler_test.go +++ b/pkg/contexts/ocm/blobhandler/handlers/generic/maven/blobhandler_test.go @@ -97,5 +97,4 @@ var _ = Describe("blobhandler generic maven tests", func() { "sdk-modules-bom-5.7.0.pom.sha1", "sdk-modules-bom-5.7.0.pom.sha256")) }) - }) diff --git a/pkg/contexts/ocm/blobhandler/handlers/generic/maven/registration_test.go b/pkg/contexts/ocm/blobhandler/handlers/generic/maven/registration_test.go index 6ff085e74d..316b8e2069 100644 --- a/pkg/contexts/ocm/blobhandler/handlers/generic/maven/registration_test.go +++ b/pkg/contexts/ocm/blobhandler/handlers/generic/maven/registration_test.go @@ -10,7 +10,6 @@ import ( ) var _ = Describe("Config deserialization Test Environment", func() { - It("deserializes string", func() { cfg := Must(registrations.DecodeConfig[maven.Config]("test")) Expect(cfg).To(Equal(&maven.Config{Url: "test"})) diff --git a/pkg/contexts/ocm/blobhandler/handlers/generic/npm/publish_test.go b/pkg/contexts/ocm/blobhandler/handlers/generic/npm/publish_test.go index 0bc25cbcdf..3cc9efd187 100644 --- a/pkg/contexts/ocm/blobhandler/handlers/generic/npm/publish_test.go +++ b/pkg/contexts/ocm/blobhandler/handlers/generic/npm/publish_test.go @@ -10,7 +10,6 @@ import ( ) var _ = Describe("NPM Publish Test Environment", func() { - It("prepare package and json marshal", func() { data := Must(os.ReadFile("testdata/testdata.tgz")) pkg := Must(prepare(data)) @@ -21,5 +20,4 @@ var _ = Describe("NPM Publish Test Environment", func() { fixture := `{"name":"testdata","version":"0.8.15","readme":"# Test Data\n\nreadme\n","description":"Test data description.","dist":{"integrity":"sha512-Dsbnf3b4scCugxBZ+rHm8Hr1CAfyC3h8su31KnPGw21BAkM6X5gbi5Jbci9WaCCBBxm1tMTRKCJqk29j5Aw0gg==","shasum":"602b69a43903fa1694d59fefd8cb326cd68e8935","tarball":""}}` Expect(string(jsn)).To(Equal(fixture)) }) - }) diff --git a/pkg/contexts/ocm/blobhandler/handlers/generic/npm/registration_test.go b/pkg/contexts/ocm/blobhandler/handlers/generic/npm/registration_test.go index 1a58c7c94b..c5ad5c0054 100644 --- a/pkg/contexts/ocm/blobhandler/handlers/generic/npm/registration_test.go +++ b/pkg/contexts/ocm/blobhandler/handlers/generic/npm/registration_test.go @@ -10,7 +10,6 @@ import ( ) var _ = Describe("Config deserialization Test Environment", func() { - It("deserializes string", func() { cfg := Must(registrations.DecodeConfig[npm.Config]("test")) Expect(cfg).To(Equal(&npm.Config{Url: "test"})) diff --git a/pkg/contexts/ocm/blobhandler/handlers/generic/ocirepo/upload_test.go b/pkg/contexts/ocm/blobhandler/handlers/generic/ocirepo/upload_test.go index 267195316c..97c132bac2 100644 --- a/pkg/contexts/ocm/blobhandler/handlers/generic/ocirepo/upload_test.go +++ b/pkg/contexts/ocm/blobhandler/handlers/generic/ocirepo/upload_test.go @@ -24,15 +24,19 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/transfer/transferhandler/standard" ) -const COMP = "github.com/compa" -const VERS = "1.0.0" -const CA = "ca" -const CTF = "ctf" -const COPY = "ctf.copy" -const TARGET = "/tmp/target" +const ( + COMP = "github.com/compa" + VERS = "1.0.0" + CA = "ca" + CTF = "ctf" + COPY = "ctf.copy" + TARGET = "/tmp/target" +) -const OCIHOST = "alias" -const OCIPATH = "/tmp/source" +const ( + OCIHOST = "alias" + OCIPATH = "/tmp/source" +) var _ = Describe("upload", func() { var env *Builder @@ -62,7 +66,7 @@ var _ = Describe("upload", func() { oca := accessio.OnceCloser(ca) defer Close(oca) - ctf := Must(ctfocm.Create(env.OCMContext(), accessobj.ACC_CREATE, CTF, 0700, env)) + ctf := Must(ctfocm.Create(env.OCMContext(), accessobj.ACC_CREATE, CTF, 0o700, env)) octf := accessio.OnceCloser(ctf) defer Close(octf) @@ -80,7 +84,7 @@ var _ = Describe("upload", func() { It("validated original oci manifest", func() { ctx := env.OCMContext() - ocirepo := Must(ctfoci.Open(ctx, accessobj.ACC_READONLY, OCIPATH, 0700, env)) + ocirepo := Must(ctfoci.Open(ctx, accessobj.ACC_READONLY, OCIPATH, 0o700, env)) defer Close(ocirepo, "ocoirepo") ns := Must(ocirepo.LookupNamespace(OCINAMESPACE)) @@ -95,7 +99,7 @@ var _ = Describe("upload", func() { It("validated original digest", func() { ctx := env.OCMContext() - ctf := Must(ctfocm.Open(ctx, accessobj.ACC_READONLY, CTF, 0700, env)) + ctf := Must(ctfocm.Open(ctx, accessobj.ACC_READONLY, CTF, 0o700, env)) defer Close(ctf, "ctf") cv := Must(ctf.LookupComponentVersion(COMP, VERS)) @@ -111,7 +115,7 @@ var _ = Describe("upload", func() { It("transfers oci artifact", func() { ctx := env.OCMContext() - ctf := Must(ctfocm.Open(ctx, accessobj.ACC_READONLY, CTF, 0700, env)) + ctf := Must(ctfocm.Open(ctx, accessobj.ACC_READONLY, CTF, 0o700, env)) defer Close(ctf, "ctf") cv := Must(ctf.LookupComponentVersion(COMP, VERS)) @@ -122,7 +126,7 @@ var _ = Describe("upload", func() { Expect(acc.GetKind()).To(Equal(localblob.Type)) // transfer component - copy := Must(ctfocm.Create(ctx, accessobj.ACC_CREATE, COPY, 0700, env)) + copy := Must(ctfocm.Create(ctx, accessobj.ACC_CREATE, COPY, 0o700, env)) ocopy := accessio.OnceCloser(copy) defer Close(ocopy) @@ -154,7 +158,7 @@ var _ = Describe("upload", func() { It("transfers oci artifact with named handler and object config", func() { ctx := env.OCMContext() - ctf := Must(ctfocm.Open(ctx, accessobj.ACC_READONLY, CTF, 0700, env)) + ctf := Must(ctfocm.Open(ctx, accessobj.ACC_READONLY, CTF, 0o700, env)) defer Close(ctf, "ctf") cv := Must(ctf.LookupComponentVersion(COMP, VERS)) @@ -165,7 +169,7 @@ var _ = Describe("upload", func() { Expect(acc.GetKind()).To(Equal(localblob.Type)) // transfer component - copy := Must(ctfocm.Create(ctx, accessobj.ACC_CREATE, COPY, 0700, env)) + copy := Must(ctfocm.Create(ctx, accessobj.ACC_CREATE, COPY, 0o700, env)) ocopy := accessio.OnceCloser(copy) defer Close(ocopy) @@ -197,7 +201,7 @@ var _ = Describe("upload", func() { It("transfers oci artifact with named handler and string config", func() { ctx := env.OCMContext() - ctf := Must(ctfocm.Open(ctx, accessobj.ACC_READONLY, CTF, 0700, env)) + ctf := Must(ctfocm.Open(ctx, accessobj.ACC_READONLY, CTF, 0o700, env)) defer Close(ctf, "ctf") cv := Must(ctf.LookupComponentVersion(COMP, VERS)) @@ -208,7 +212,7 @@ var _ = Describe("upload", func() { Expect(acc.GetKind()).To(Equal(localblob.Type)) // transfer component - copy := Must(ctfocm.Create(ctx, accessobj.ACC_CREATE, COPY, 0700, env)) + copy := Must(ctfocm.Create(ctx, accessobj.ACC_CREATE, COPY, 0o700, env)) ocopy := accessio.OnceCloser(copy) defer Close(ocopy) diff --git a/pkg/contexts/ocm/blobhandler/handlers/generic/plugin/upload_test.go b/pkg/contexts/ocm/blobhandler/handlers/generic/plugin/upload_test.go index 6c11d4273b..1a288c9036 100644 --- a/pkg/contexts/ocm/blobhandler/handlers/generic/plugin/upload_test.go +++ b/pkg/contexts/ocm/blobhandler/handlers/generic/plugin/upload_test.go @@ -36,19 +36,23 @@ import ( const PLUGIN = "test" -const ARCH = "ctf" -const OUT = "/tmp/res" -const COMP = "github.com/mandelsoft/comp" -const VERS = "1.0.0" -const PROVIDER = "mandelsoft" -const RSCTYPE = "TestArtifact" -const MEDIA = "text/plain" - -const REPOTYPE = "test/v1" -const ACCTYPE = "test/v1" -const REPO = "plugin" -const CONTENT = "some test content\n" -const HINT = "given" +const ( + ARCH = "ctf" + OUT = "/tmp/res" + COMP = "github.com/mandelsoft/comp" + VERS = "1.0.0" + PROVIDER = "mandelsoft" + RSCTYPE = "TestArtifact" + MEDIA = "text/plain" +) + +const ( + REPOTYPE = "test/v1" + ACCTYPE = "test/v1" + REPO = "plugin" + CONTENT = "some test content\n" + HINT = "given" +) type RepoSpec struct { runtime.ObjectVersionedType @@ -84,8 +88,8 @@ var _ = Describe("setup plugin cache", func() { var repodir string var env *Builder - var accessSpec = NewAccessSpec(MEDIA, "given", REPO) - var repoSpec = NewRepoSpec(REPO) + accessSpec := NewAccessSpec(MEDIA, "given", REPO) + repoSpec := NewRepoSpec(REPO) BeforeEach(func() { repodir = Must(os.MkdirTemp(os.TempDir(), "uploadtest-*")) @@ -134,7 +138,7 @@ var _ = Describe("setup plugin cache", func() { Expect(name).To(Equal("testuploader")) Expect(keys).To(Equal(plugin2.UploaderKeySet{}.Add(plugin2.UploaderKey{}.SetArtifact(RSCTYPE, "")))) - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer Close(tgt, "target repo") MustBeSuccessful(transfer.TransferVersion(nil, nil, cv, tgt, Must(standard.New(standard.ResourcesByValue())))) @@ -169,7 +173,7 @@ var _ = Describe("setup plugin cache", func() { repospec := Must(json.Marshal(repoSpec)) MustBeSuccessful(blobhandler.RegisterHandlerByName(ctx, "plugin/test", repospec)) - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer Close(tgt, "target repo") MustBeSuccessful(transfer.TransferVersion(nil, nil, cv, tgt, Must(standard.New(standard.ResourcesByValue())))) diff --git a/pkg/contexts/ocm/blobhandler/handlers/oci/ocirepo/handler_test.go b/pkg/contexts/ocm/blobhandler/handlers/oci/ocirepo/handler_test.go index f9e1d862f4..339b8bde1a 100644 --- a/pkg/contexts/ocm/blobhandler/handlers/oci/ocirepo/handler_test.go +++ b/pkg/contexts/ocm/blobhandler/handlers/oci/ocirepo/handler_test.go @@ -30,15 +30,17 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ctf" -const ARCH2 = "/tmp/ctf2" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENT = "github.com/mandelsoft/test" -const COMPONENT2 = "github.com/mandelsoft/test2" -const OUT = "/tmp/res" -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" +const ( + ARCH = "/tmp/ctf" + ARCH2 = "/tmp/ctf2" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENT = "github.com/mandelsoft/test" + COMPONENT2 = "github.com/mandelsoft/test2" + OUT = "/tmp/res" + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) func FakeOCIRegBaseFunction(ctx *storagecontext.StorageContext) string { return "baseurl.io" @@ -87,7 +89,7 @@ var _ = Describe("oci artifact transfer", func() { src := Must(ctf.Open(env.OCMContext(), accessobj.ACC_READONLY, ARCH, 0, env)) cv := Must(src.LookupComponentVersion(COMPONENT, VERSION)) - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer tgt.Close() opts := &standard.Options{} @@ -126,7 +128,7 @@ var _ = Describe("oci artifact transfer", func() { src := Must(ctf.Open(env.OCMContext(), accessobj.ACC_READONLY, ARCH, 0, env)) cv := Must(src.LookupComponentVersion(COMPONENT, VERSION)) - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer tgt.Close() opts := &standard.Options{} @@ -164,7 +166,7 @@ var _ = Describe("oci artifact transfer", func() { src := Must(ctf.Open(env.OCMContext(), accessobj.ACC_READONLY, ARCH, 0, env)) cv := Must(src.LookupComponentVersion(COMPONENT, VERSION)) - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer tgt.Close() opts := &standard.Options{} @@ -205,7 +207,7 @@ var _ = Describe("oci artifact transfer", func() { src := Must(ctf.Open(env.OCMContext(), accessobj.ACC_READONLY, ARCH, 0, env)) cv := Must(src.LookupComponentVersion(COMPONENT, VERSION)) - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer tgt.Close() opts := &standard.Options{} diff --git a/pkg/contexts/ocm/blobhandler/handlers/ocm/comparch/blobhandler_test.go b/pkg/contexts/ocm/blobhandler/handlers/ocm/comparch/blobhandler_test.go index fa85f3d8c9..a86ea2710d 100644 --- a/pkg/contexts/ocm/blobhandler/handlers/ocm/comparch/blobhandler_test.go +++ b/pkg/contexts/ocm/blobhandler/handlers/ocm/comparch/blobhandler_test.go @@ -78,5 +78,4 @@ var _ = Describe("blobhandler", func() { Expect(found).To(Equal(spec)) }) }) - }) diff --git a/pkg/contexts/ocm/compdesc/compdesc_test.go b/pkg/contexts/ocm/compdesc/compdesc_test.go index e75c5ee71c..4f1ba09463 100644 --- a/pkg/contexts/ocm/compdesc/compdesc_test.go +++ b/pkg/contexts/ocm/compdesc/compdesc_test.go @@ -21,7 +21,7 @@ func NormalizeYAML(y string) string { } var _ = Describe("serialization", func() { - var CDv2 = NormalizeYAML(` + CDv2 := NormalizeYAML(` component: componentReferences: [] name: github.com/vasu1124/introspect @@ -81,7 +81,7 @@ var _ = Describe("serialization", func() { schemaVersion: v2 `) - var CDv3 = NormalizeYAML(fmt.Sprintf(` + CDv3 := NormalizeYAML(fmt.Sprintf(` apiVersion: %s kind: ComponentVersion metadata: diff --git a/pkg/contexts/ocm/compdesc/copy_test.go b/pkg/contexts/ocm/compdesc/copy_test.go index 5a24715f6a..e2d8f006b3 100644 --- a/pkg/contexts/ocm/compdesc/copy_test.go +++ b/pkg/contexts/ocm/compdesc/copy_test.go @@ -17,7 +17,6 @@ import ( var _ = Describe("Component Descripor Copy Test Suitet", func() { Context("compdesc copy", func() { It("copies CD", func() { - labels := v1.Labels{ *Must(v1.NewLabel("label", "value", v1.WithVersion("v1"), diff --git a/pkg/contexts/ocm/compdesc/equal_test.go b/pkg/contexts/ocm/compdesc/equal_test.go index 9acf26d466..be9b9f9f9c 100644 --- a/pkg/contexts/ocm/compdesc/equal_test.go +++ b/pkg/contexts/ocm/compdesc/equal_test.go @@ -660,5 +660,4 @@ var _ = Describe("equivalence", func() { CheckNotEquivalent(b.Equivalent(a)) }) }) - }) diff --git a/pkg/contexts/ocm/compdesc/helper_test.go b/pkg/contexts/ocm/compdesc/helper_test.go index 7654048286..fecfa419bb 100644 --- a/pkg/contexts/ocm/compdesc/helper_test.go +++ b/pkg/contexts/ocm/compdesc/helper_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("helper", func() { - It("should inject a new repository context if none is defined", func() { cd := &compdesc.ComponentDescriptor{} compdesc.DefaultComponent(cd) @@ -185,7 +184,6 @@ var _ = Describe("helper", func() { Expect(res).To(Equal(compdesc.Resources{r4v3})) res = Must(cd.GetResourcesBySelectors([]compdesc.IdentitySelector{compdesc.WithExtraIdentity("extra", "value")}, nil)) Expect(res).To(Equal(compdesc.Resources{r4v3})) - }) It("selects none with wrong extra identity value", func() { _, err := cd.GetResourcesBySelectors(nil, []compdesc.ResourceSelector{compdesc.WithExtraIdentity("extra", "other")}) @@ -422,7 +420,6 @@ var _ = Describe("helper", func() { Expect(res).To(Equal(compdesc.References{r4v3})) res = Must(cd.GetReferencesBySelectors([]compdesc.IdentitySelector{compdesc.WithExtraIdentity("extra", "value")}, nil)) Expect(res).To(Equal(compdesc.References{r4v3})) - }) It("selects none with wrong extra identity value", func() { _, err := cd.GetReferencesBySelectors(nil, []compdesc.ReferenceSelector{compdesc.WithExtraIdentity("extra", "other")}) diff --git a/pkg/contexts/ocm/compdesc/logging_test.go b/pkg/contexts/ocm/compdesc/logging_test.go index 416997263a..41f4ed2149 100644 --- a/pkg/contexts/ocm/compdesc/logging_test.go +++ b/pkg/contexts/ocm/compdesc/logging_test.go @@ -7,10 +7,10 @@ import ( . "github.com/onsi/gomega" "github.com/go-logr/logr" + "github.com/mandelsoft/goutils/testutils" "github.com/mandelsoft/logging" "github.com/tonglil/buflogr" - "github.com/mandelsoft/goutils/testutils" "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc" ocmlog "github.com/open-component-model/ocm/pkg/logging" ) @@ -35,7 +35,6 @@ var _ = Describe("logging", func() { }) It("logs failures", func() { - _, err := compdesc.Decode([]byte("[]")) Expect(err).To(MatchError(`error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into Go value of type struct { Meta v1.Metadata "json:\"meta\""; APIVersion string "json:\"apiVersion\"" }`)) Expect(buf.String()).To(testutils.StringEqualTrimmedWithContext(` @@ -44,7 +43,6 @@ V[4] decoding of component descriptor failed realm ocm realm ocm/compdesc error }) It("logs format failures", func() { - _, err := compdesc.Decode([]byte(` meta: schemaVersion: v2 @@ -63,5 +61,4 @@ component: V[4] versioned decoding of component descriptor failed realm ocm realm ocm/compdesc error component.creationTime: Does not match format 'date-time' scheme v2 data meta: schemaVersion: v2 component: name: acme.org/test version: 1.0.0 provider: acme.org creationTime: "0815" repositoryContexts: [] resources: [] sources: [] componentReferences: [] `)) }) - }) diff --git a/pkg/contexts/ocm/compdesc/meta/v1/identity_test.go b/pkg/contexts/ocm/compdesc/meta/v1/identity_test.go index 16538a8e29..32c8980c75 100644 --- a/pkg/contexts/ocm/compdesc/meta/v1/identity_test.go +++ b/pkg/contexts/ocm/compdesc/meta/v1/identity_test.go @@ -41,6 +41,5 @@ var _ = Describe("identity", func() { CheckNotLocalHashEqual(a.Equivalent(b)) CheckNotLocalHashEqual(b.Equivalent(a)) }) - }) }) diff --git a/pkg/contexts/ocm/compdesc/meta/v1/labels_test.go b/pkg/contexts/ocm/compdesc/meta/v1/labels_test.go index 5f993ecf05..966d14ac69 100644 --- a/pkg/contexts/ocm/compdesc/meta/v1/labels_test.go +++ b/pkg/contexts/ocm/compdesc/meta/v1/labels_test.go @@ -135,7 +135,6 @@ var _ = Describe("labels", func() { It("detects equal", func() { eq := labels.Equivalent(labels.Copy()) CheckEquivalent(eq) - }) It("detects volatile value modification", func() { diff --git a/pkg/contexts/ocm/compdesc/versions/ocm.software/v3alpha1/validation_test.go b/pkg/contexts/ocm/compdesc/versions/ocm.software/v3alpha1/validation_test.go index c466a3cfbf..87393ab06a 100644 --- a/pkg/contexts/ocm/compdesc/versions/ocm.software/v3alpha1/validation_test.go +++ b/pkg/contexts/ocm/compdesc/versions/ocm.software/v3alpha1/validation_test.go @@ -83,7 +83,6 @@ var _ = Describe("Validation", func() { }) Context("#Metadata", func() { - It("should forbid if the component schemaVersion is missing", func() { comp := ComponentDescriptor{} @@ -101,7 +100,6 @@ var _ = Describe("Validation", func() { "Field": Equal("apiVersion"), })))) }) - }) Context("#ObjectMeta", func() { @@ -126,7 +124,6 @@ var _ = Describe("Validation", func() { "Field": Equal("metadata.name"), })))) }) - }) Context("#Sources", func() { diff --git a/pkg/contexts/ocm/compdesc/versions/v2/validation_test.go b/pkg/contexts/ocm/compdesc/versions/v2/validation_test.go index 443ff057fc..e8b0d9d0ee 100644 --- a/pkg/contexts/ocm/compdesc/versions/v2/validation_test.go +++ b/pkg/contexts/ocm/compdesc/versions/v2/validation_test.go @@ -85,7 +85,6 @@ var _ = Describe("Validation", func() { }) Context("#Metadata", func() { - It("should forbid if the component schemaVersion is missing", func() { comp := ComponentDescriptor{ Metadata: meta.Metadata{}, @@ -105,7 +104,6 @@ var _ = Describe("Validation", func() { "Field": Equal("meta.schemaVersion"), })))) }) - }) Context("#ObjectMeta", func() { @@ -130,7 +128,6 @@ var _ = Describe("Validation", func() { "Field": Equal("component.name"), })))) }) - }) Context("#Sources", func() { @@ -387,7 +384,6 @@ var _ = Describe("Validation", func() { }) Context("#labels", func() { - It("should forbid if labels are defined multiple times in the same context", func() { comp.ComponentReferences = []ComponentReference{ { diff --git a/pkg/contexts/ocm/config/config_test.go b/pkg/contexts/ocm/config/config_test.go index f6ecfc444d..3e0098b3fb 100644 --- a/pkg/contexts/ocm/config/config_test.go +++ b/pkg/contexts/ocm/config/config_test.go @@ -25,7 +25,6 @@ func normalize(i interface{}) ([]byte, error) { } var _ = Describe("oci config", func() { - spec := ocireg.NewRepositorySpec("gcr.io", nil) data, err := normalize(spec) Expect(err).To(Succeed()) diff --git a/pkg/contexts/ocm/cpi/compose_test.go b/pkg/contexts/ocm/cpi/compose_test.go index c8d5c371f6..a33277a147 100644 --- a/pkg/contexts/ocm/cpi/compose_test.go +++ b/pkg/contexts/ocm/cpi/compose_test.go @@ -5,12 +5,12 @@ import ( . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/open-component-model/ocm/pkg/blobaccess" . "github.com/open-component-model/ocm/pkg/contexts/ocm/testhelper" "github.com/mandelsoft/vfs/pkg/memoryfs" "github.com/mandelsoft/vfs/pkg/vfs" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/accessobj" "github.com/open-component-model/ocm/pkg/contexts/datacontext" @@ -23,8 +23,10 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const COMPONENT = "github.com/mandelsoft/ocm" -const VERSION = "1.0.0" +const ( + COMPONENT = "github.com/mandelsoft/ocm" + VERSION = "1.0.0" +) var _ = Describe("access method", func() { var fs vfs.FileSystem diff --git a/pkg/contexts/ocm/download/handlers/ocirepo/upload_test.go b/pkg/contexts/ocm/download/handlers/ocirepo/upload_test.go index 7ebef6ed0a..fcf95934c6 100644 --- a/pkg/contexts/ocm/download/handlers/ocirepo/upload_test.go +++ b/pkg/contexts/ocm/download/handlers/ocirepo/upload_test.go @@ -25,20 +25,28 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const COMP = "github.com/compa" -const VERS = "1.0.0" -const CTF = "ctf" +const ( + COMP = "github.com/compa" + VERS = "1.0.0" + CTF = "ctf" +) -const HINT = "ocm.software/test" -const UPLOAD = "ocm.software/upload" +const ( + HINT = "ocm.software/test" + UPLOAD = "ocm.software/upload" +) -const TARGETHOST = "target" -const TARGETPATH = "/tmp/target" +const ( + TARGETHOST = "target" + TARGETPATH = "/tmp/target" +) -const OCIHOST = "source" -const OCIPATH = "/tmp/source" -const OCINAMESPACE = "ocm/value" -const OCIVERSION = "v2.0" +const ( + OCIHOST = "source" + OCIPATH = "/tmp/source" + OCINAMESPACE = "ocm/value" + OCIVERSION = "v2.0" +) const ARTIFACTSET = "/tmp/set.tgz" diff --git a/pkg/contexts/ocm/download/handlers/plugin/download_test.go b/pkg/contexts/ocm/download/handlers/plugin/download_test.go index 08383c63d0..75fccb7737 100644 --- a/pkg/contexts/ocm/download/handlers/plugin/download_test.go +++ b/pkg/contexts/ocm/download/handlers/plugin/download_test.go @@ -31,17 +31,21 @@ import ( const PLUGIN = "test" -const ARCH = "ctf" -const COMP = "github.com/mandelsoft/comp" -const VERS = "1.0.0" -const PROVIDER = "mandelsoft" -const RSCTYPE = "TestArtifact" -const MEDIA = "text/plain" - -const REPOTYPE = "test/v1" -const ACCTYPE = "test/v1" -const CONTENT = "some test content\n" -const HINT = "given" +const ( + ARCH = "ctf" + COMP = "github.com/mandelsoft/comp" + VERS = "1.0.0" + PROVIDER = "mandelsoft" + RSCTYPE = "TestArtifact" + MEDIA = "text/plain" +) + +const ( + REPOTYPE = "test/v1" + ACCTYPE = "test/v1" + CONTENT = "some test content\n" + HINT = "given" +) type AccessSpec struct { runtime.ObjectVersionedType @@ -121,6 +125,5 @@ var _ = Describe("setup plugin cache", func() { Expect(string(data)).To(StringEqualTrimmedWithContext(` downloaded ` + CONTENT)) - }) }) diff --git a/pkg/contexts/ocm/elements/artifactaccess/genericaccess/resource_test.go b/pkg/contexts/ocm/elements/artifactaccess/genericaccess/resource_test.go index 82a15e4a90..5445709201 100644 --- a/pkg/contexts/ocm/elements/artifactaccess/genericaccess/resource_test.go +++ b/pkg/contexts/ocm/elements/artifactaccess/genericaccess/resource_test.go @@ -17,8 +17,10 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/resourcetypes" ) -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" +const ( + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) var _ = Describe("dir tree resource access", func() { var env *Builder diff --git a/pkg/contexts/ocm/elements/artifactblob/dirtreeblob/resource_test.go b/pkg/contexts/ocm/elements/artifactblob/dirtreeblob/resource_test.go index 469e0f07a6..ee8b443505 100644 --- a/pkg/contexts/ocm/elements/artifactblob/dirtreeblob/resource_test.go +++ b/pkg/contexts/ocm/elements/artifactblob/dirtreeblob/resource_test.go @@ -65,7 +65,7 @@ var _ = Describe("dir tree resource access", func() { me.WithGlobalAccess(global), ) - arch := Must(ctf.Create(env, accessobj.ACC_CREATE, "ctf", 0700, env, accessobj.FormatDirectory)) + arch := Must(ctf.Create(env, accessobj.ACC_CREATE, "ctf", 0o700, env, accessobj.FormatDirectory)) c := Must(arch.LookupComponent("arcme.org/test")) v := Must(c.NewVersion("v1.0.0")) diff --git a/pkg/contexts/ocm/elements/artifactblob/helmblob/helmblob_test.go b/pkg/contexts/ocm/elements/artifactblob/helmblob/helmblob_test.go index dfda335250..5b63e98f5e 100644 --- a/pkg/contexts/ocm/elements/artifactblob/helmblob/helmblob_test.go +++ b/pkg/contexts/ocm/elements/artifactblob/helmblob/helmblob_test.go @@ -18,7 +18,6 @@ var _ = Describe("", func() { BeforeEach(func() { e = NewBuilder(env.TestData()) - }) AfterEach(func() { diff --git a/pkg/contexts/ocm/elements/artifactblob/mavenblob/access_test.go b/pkg/contexts/ocm/elements/artifactblob/mavenblob/access_test.go index afe44af33c..2c09d0a80d 100644 --- a/pkg/contexts/ocm/elements/artifactblob/mavenblob/access_test.go +++ b/pkg/contexts/ocm/elements/artifactblob/mavenblob/access_test.go @@ -5,13 +5,13 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/open-component-model/ocm/pkg/env/builder" - "github.com/open-component-model/ocm/pkg/maven/maventest" "github.com/open-component-model/ocm/pkg/contexts/ocm/elements" me "github.com/open-component-model/ocm/pkg/contexts/ocm/elements/artifactblob/mavenblob" "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/composition" "github.com/open-component-model/ocm/pkg/contexts/ocm/resourcetypes" "github.com/open-component-model/ocm/pkg/maven" + "github.com/open-component-model/ocm/pkg/maven/maventest" ) const ( @@ -25,7 +25,6 @@ const ( ) var _ = Describe("blobaccess for maven", func() { - Context("maven filesystem repository", func() { var env *Builder var repo *maven.Repository diff --git a/pkg/contexts/ocm/grammar/grammar_test.go b/pkg/contexts/ocm/grammar/grammar_test.go index 5649bd1511..d0a09de981 100644 --- a/pkg/contexts/ocm/grammar/grammar_test.go +++ b/pkg/contexts/ocm/grammar/grammar_test.go @@ -46,18 +46,21 @@ func Type(t string) string { } return t + "::" } + func Scheme(sc string) string { if sc == "" { return sc } return sc + "://" } + func Sub(t string) string { if t == "" { return t } return "/" + t } + func Vers(t string) string { if t == "" { return t @@ -168,7 +171,5 @@ var _ = Describe("ref matching", func() { CheckVers("ghcr.io:v1") CheckVers(":v1") }) - }) - }) diff --git a/pkg/contexts/ocm/internal/blobhandler_test.go b/pkg/contexts/ocm/internal/blobhandler_test.go index ac4b404f77..be007510b2 100644 --- a/pkg/contexts/ocm/internal/blobhandler_test.go +++ b/pkg/contexts/ocm/internal/blobhandler_test.go @@ -236,7 +236,6 @@ var _ = Describe("blob handler registry test", func() { h = copy.LookupHandler(internal.ImplementationRepositoryType{internal.CONTEXT_TYPE, REPO}, ART, mime.MIME_OCTET) Expect(h).To(Equal(internal.MultiBlobHandler{new})) - }, Entry("plain", ®), Entry("extended", &ext), diff --git a/pkg/contexts/ocm/internal/digesthandler_test.go b/pkg/contexts/ocm/internal/digesthandler_test.go index 5455cf652c..c89af110e4 100644 --- a/pkg/contexts/ocm/internal/digesthandler_test.go +++ b/pkg/contexts/ocm/internal/digesthandler_test.go @@ -93,8 +93,7 @@ var _ = Describe("blob digester registry test", func() { ) }) -type accessMethod struct { -} +type accessMethod struct{} var _ internal.AccessMethodImpl = (*accessMethod)(nil) diff --git a/pkg/contexts/ocm/labels/routingslip/slip_test.go b/pkg/contexts/ocm/labels/routingslip/slip_test.go index 1e70662ea1..c9ceb18823 100644 --- a/pkg/contexts/ocm/labels/routingslip/slip_test.go +++ b/pkg/contexts/ocm/labels/routingslip/slip_test.go @@ -18,8 +18,10 @@ import ( "github.com/open-component-model/ocm/pkg/signing/handlers/rsa" ) -const ORG = "acme.org" -const OTHER = "ocm.software" +const ( + ORG = "acme.org" + OTHER = "ocm.software" +) var _ = Describe("management", func() { var env *builder.Builder diff --git a/pkg/contexts/ocm/labels/routingslip/transfer_test.go b/pkg/contexts/ocm/labels/routingslip/transfer_test.go index 3f5b920ca9..74b892b6c5 100644 --- a/pkg/contexts/ocm/labels/routingslip/transfer_test.go +++ b/pkg/contexts/ocm/labels/routingslip/transfer_test.go @@ -22,11 +22,13 @@ import ( "github.com/open-component-model/ocm/pkg/signing/handlers/rsa" ) -const ARCH = "/tmp/ctf" -const TARGET = "/tmp/target" -const COMPONENT = "acme.org/routingslip" -const VERSION = "1.0.0" -const LOCAL = "local.org" +const ( + ARCH = "/tmp/ctf" + TARGET = "/tmp/target" + COMPONENT = "acme.org/routingslip" + VERSION = "1.0.0" + LOCAL = "local.org" +) var _ = Describe("management", func() { var env *builder.Builder diff --git a/pkg/contexts/ocm/labels/routingslip/types/plugin/cmd_test.go b/pkg/contexts/ocm/labels/routingslip/types/plugin/cmd_test.go index c4b68af16f..984e2b8e35 100644 --- a/pkg/contexts/ocm/labels/routingslip/types/plugin/cmd_test.go +++ b/pkg/contexts/ocm/labels/routingslip/types/plugin/cmd_test.go @@ -18,10 +18,12 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/registration" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const COMP = "test.de/x" -const PROVIDER = "acme.org" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + COMP = "test.de/x" + PROVIDER = "acme.org" +) var _ = Describe("Test Environment", func() { var env *Environment diff --git a/pkg/contexts/ocm/labels/routingslip/types/plugin/entry_test.go b/pkg/contexts/ocm/labels/routingslip/types/plugin/entry_test.go index 994c4df544..794c0b6a9d 100644 --- a/pkg/contexts/ocm/labels/routingslip/types/plugin/entry_test.go +++ b/pkg/contexts/ocm/labels/routingslip/types/plugin/entry_test.go @@ -64,5 +64,4 @@ var _ = Describe("setup plugin cache", func() { "mediaType": "a simple test", })) }) - }) diff --git a/pkg/contexts/ocm/plugin/common/describe.go b/pkg/contexts/ocm/plugin/common/describe.go index 2352d7ed6e..c7cb53490d 100644 --- a/pkg/contexts/ocm/plugin/common/describe.go +++ b/pkg/contexts/ocm/plugin/common/describe.go @@ -143,11 +143,11 @@ func DescribeAccessMethods(d *descriptor.Descriptor, out common.Printer) { if m.Description != "" { out.Printf("%s\n", utils2.IndentLines(m.Description, " ")) } - out := out.AddGap(" ") //nolint: govet // just use always out + out := out.AddGap(" ") out.Printf("Versions:\n") for _, vn := range utils2.StringMapKeys(m.Versions) { out.Printf("- Version: %s\n", vn) - out := out.AddGap(" ") //nolint: govet // just use always out + out := out.AddGap(" ") v := m.Versions[vn] if v.Format != "" { out.Printf("%s\n", v.Format) @@ -227,7 +227,7 @@ func DescribeActions(reg api.ActionTypeRegistry, d *descriptor.Descriptor, out c out.Printf(" Info:\n") out.Printf("%s\n", utils2.IndentLines(a.ActionDesc, " ")) } - out := out.AddGap(" ") //nolint: govet // just use always out + out := out.AddGap(" ") if a.BestVersion == "" { out.Printf("No version matches actual ocm version!\n") } @@ -372,11 +372,11 @@ func DescribeValueSets(d *descriptor.Descriptor, out common.Printer) { if m.Description != "" { out.Printf("%s\n", utils2.IndentLines(m.Description, " ")) } - out := out.AddGap(" ") //nolint: govet // just use always out + out := out.AddGap(" ") out.Printf("Versions:\n") for _, vn := range utils2.StringMapKeys(m.Versions) { out.Printf("- Version: %s\n", vn) - out := out.AddGap(" ") //nolint: govet // just use always out + out := out.AddGap(" ") v := m.Versions[vn] if v.Format != "" { out.Printf("%s\n", v.Format) @@ -411,7 +411,7 @@ func ListElements[E DescribableElement[C], C Describable](msg string, elems []E, for _, n := range utils2.StringMapKeys(keys) { m := keys[n] out.Printf("- Name: %s\n", n) - out := out.AddGap(" ") //nolint: govet // just use always out + out := out.AddGap(" ") if m.GetDescription() != "" { desc := m.GetDescription() if !strings.HasSuffix(desc, "\n") { diff --git a/pkg/contexts/ocm/plugin/descriptor/utils_test.go b/pkg/contexts/ocm/plugin/descriptor/utils_test.go index 22aae84b93..3105d5c929 100644 --- a/pkg/contexts/ocm/plugin/descriptor/utils_test.go +++ b/pkg/contexts/ocm/plugin/descriptor/utils_test.go @@ -6,7 +6,6 @@ import ( ) var _ = Describe("utils", func() { - It("merges lists", func() { l1 := List[StringName]{"a", "b"} l2 := List[StringName]{"b", "c"} diff --git a/pkg/contexts/ocm/ref_test.go b/pkg/contexts/ocm/ref_test.go index 67bf710127..27a07f699a 100644 --- a/pkg/contexts/ocm/ref_test.go +++ b/pkg/contexts/ocm/ref_test.go @@ -16,6 +16,7 @@ func Type(t string) string { } return t + "::" } + func FileFormat(t, f string) string { if t == "" { return f @@ -25,6 +26,7 @@ func FileFormat(t, f string) string { } return t + "+" + f } + func FileType(t, f string) string { if t != "" { return t @@ -32,18 +34,21 @@ func FileType(t, f string) string { return f } } + func Scheme(s string) string { if s == "" { return s } return s + "://" } + func Sub(t string) string { if t == "" { return t } return "/" + t } + func Vers(t string) string { if t == "" { return t diff --git a/pkg/contexts/ocm/repositories/comparch/accessmethod_test.go b/pkg/contexts/ocm/repositories/comparch/accessmethod_test.go index 7137c051e1..edc68c1681 100644 --- a/pkg/contexts/ocm/repositories/comparch/accessmethod_test.go +++ b/pkg/contexts/ocm/repositories/comparch/accessmethod_test.go @@ -23,7 +23,6 @@ import ( var DefaultContext = ocm.New() var _ = Describe("access method", func() { - legacy := "{\"type\":\"localFilesystemBlob\",\"fileName\":\"anydigest\",\"mediaType\":\"application/json\"}" Context("local access method", func() { @@ -47,7 +46,7 @@ var _ = Describe("access method", func() { data := Must(os.ReadFile("testdata/descriptor/component-descriptor.yaml")) cd := Must(compdesc.Decode(data)) - ca := Must(comparch.New(DefaultContext, accessobj.ACC_CREATE, nil, nil, nil, 0600)) + ca := Must(comparch.New(DefaultContext, accessobj.ACC_CREATE, nil, nil, nil, 0o600)) defer Close(ca, "component archive") ca.GetDescriptor().Name = "acme.org/dummy" diff --git a/pkg/contexts/ocm/repositories/comparch/comparch_test.go b/pkg/contexts/ocm/repositories/comparch/comparch_test.go index e8e73b293f..08892b749b 100644 --- a/pkg/contexts/ocm/repositories/comparch/comparch_test.go +++ b/pkg/contexts/ocm/repositories/comparch/comparch_test.go @@ -6,7 +6,6 @@ import ( . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/open-component-model/ocm/pkg/blobaccess" . "github.com/open-component-model/ocm/pkg/contexts/ocm/testhelper" "github.com/mandelsoft/filepath/pkg/filepath" @@ -15,6 +14,7 @@ import ( "github.com/mandelsoft/vfs/pkg/osfs" "github.com/mandelsoft/vfs/pkg/vfs" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/accessobj" "github.com/open-component-model/ocm/pkg/contexts/ocm" @@ -40,7 +40,6 @@ const ( ) var _ = Describe("Repository", func() { - It("marshal/unmarshal simple", func() { octx := ocm.DefaultContext() spec := Must(comparch.NewRepositorySpec(accessobj.ACC_READONLY, TEST_FILEPATH)) diff --git a/pkg/contexts/ocm/repositories/composition/close_test.go b/pkg/contexts/ocm/repositories/composition/close_test.go index 853b6678b6..3395aa795d 100644 --- a/pkg/contexts/ocm/repositories/composition/close_test.go +++ b/pkg/contexts/ocm/repositories/composition/close_test.go @@ -20,8 +20,10 @@ import ( "github.com/open-component-model/ocm/pkg/refmgmt" ) -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" +const ( + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) const RES = "ref" @@ -37,7 +39,6 @@ var _ = Describe("cached access method blob", func() { }) Context("ocireg", func() { - BeforeEach(func() { env.OCICommonTransport(OCIPATH, accessio.FormatDirectory, func() { OCIManifest1(env) diff --git a/pkg/contexts/ocm/repositories/composition/gc_test.go b/pkg/contexts/ocm/repositories/composition/gc_test.go index 6d13cf79b4..ccb2dc9cd7 100644 --- a/pkg/contexts/ocm/repositories/composition/gc_test.go +++ b/pkg/contexts/ocm/repositories/composition/gc_test.go @@ -15,7 +15,6 @@ import ( ) var _ = Describe("repository", func() { - It("finalizes with context", func() { ctx := ocm.New(datacontext.MODE_EXTENDED) diff --git a/pkg/contexts/ocm/repositories/composition/repository_test.go b/pkg/contexts/ocm/repositories/composition/repository_test.go index f5bc0d7c71..52a5d2ac6d 100644 --- a/pkg/contexts/ocm/repositories/composition/repository_test.go +++ b/pkg/contexts/ocm/repositories/composition/repository_test.go @@ -23,11 +23,13 @@ import ( "github.com/open-component-model/ocm/pkg/refmgmt" ) -const COMPONENT = "acme.org/testcomp" -const VERSION = "1.0.0" +const ( + COMPONENT = "acme.org/testcomp" + VERSION = "1.0.0" +) var _ = Describe("repository", func() { - var ctx = ocm.DefaultContext() + ctx := ocm.DefaultContext() It("handles cvs", func() { finalize := finalizer.Finalizer{} diff --git a/pkg/contexts/ocm/repositories/composition/version_test.go b/pkg/contexts/ocm/repositories/composition/version_test.go index 35e0b6d4a6..51de4968dd 100644 --- a/pkg/contexts/ocm/repositories/composition/version_test.go +++ b/pkg/contexts/ocm/repositories/composition/version_test.go @@ -19,7 +19,7 @@ import ( ) var _ = Describe("version", func() { - var ctx = ocm.DefaultContext() + ctx := ocm.DefaultContext() It("handles anonymous version", func() { finalize := finalizer.Finalizer{} diff --git a/pkg/contexts/ocm/repositories/ctf/ctf_test.go b/pkg/contexts/ocm/repositories/ctf/ctf_test.go index d9514537b2..c4cfd65871 100644 --- a/pkg/contexts/ocm/repositories/ctf/ctf_test.go +++ b/pkg/contexts/ocm/repositories/ctf/ctf_test.go @@ -81,6 +81,5 @@ var _ = Describe("access method", func() { spec := Must(ocm.ParseRepoToSpec(ctx, "ca::test/repository")) Expect(comparch.NewRepositorySpec(ctf.ACC_WRITABLE, "test/repository", accessio.PathFileSystem(fs))).To(DeepEqual(spec)) }) - }) }) diff --git a/pkg/contexts/ocm/repositories/ctf/repo_test.go b/pkg/contexts/ocm/repositories/ctf/repo_test.go index 113cf8b880..e8167168e0 100644 --- a/pkg/contexts/ocm/repositories/ctf/repo_test.go +++ b/pkg/contexts/ocm/repositories/ctf/repo_test.go @@ -7,7 +7,6 @@ import ( . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/open-component-model/ocm/pkg/blobaccess" . "github.com/open-component-model/ocm/pkg/contexts/ocm/testhelper" "github.com/mandelsoft/logging" @@ -15,6 +14,7 @@ import ( "github.com/mandelsoft/vfs/pkg/vfs" "github.com/tonglil/buflogr" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/accessobj" "github.com/open-component-model/ocm/pkg/contexts/ocm" @@ -28,8 +28,10 @@ import ( "github.com/open-component-model/ocm/pkg/refmgmt" ) -const COMPONENT = "github.com/mandelsoft/ocm" -const VERSION = "1.0.0" +const ( + COMPONENT = "github.com/mandelsoft/ocm" + VERSION = "1.0.0" +) var _ = Describe("access method", func() { var fs vfs.FileSystem diff --git a/pkg/contexts/ocm/repositories/genericocireg/cred_test.go b/pkg/contexts/ocm/repositories/genericocireg/cred_test.go index 236973d3e0..1969ab4437 100644 --- a/pkg/contexts/ocm/repositories/genericocireg/cred_test.go +++ b/pkg/contexts/ocm/repositories/genericocireg/cred_test.go @@ -46,5 +46,4 @@ var _ = Describe("consumer id handling", func() { ociidentity.ATTR_PASSWORD: "password", })) }) - }) diff --git a/pkg/contexts/ocm/repositories/genericocireg/fallback_test.go b/pkg/contexts/ocm/repositories/genericocireg/fallback_test.go index 7e807c4b2e..89d0d4b040 100644 --- a/pkg/contexts/ocm/repositories/genericocireg/fallback_test.go +++ b/pkg/contexts/ocm/repositories/genericocireg/fallback_test.go @@ -5,11 +5,11 @@ import ( . "github.com/onsi/gomega" "github.com/mandelsoft/goutils/testutils" + "github.com/open-component-model/ocm/pkg/contexts/ocm" ) var _ = Describe("decode fallback", func() { - It("creates a dummy component", func() { specdata := ` type: other/v1 diff --git a/pkg/contexts/ocm/repositories/genericocireg/repo_test.go b/pkg/contexts/ocm/repositories/genericocireg/repo_test.go index b63f364566..a71c45ae2b 100644 --- a/pkg/contexts/ocm/repositories/genericocireg/repo_test.go +++ b/pkg/contexts/ocm/repositories/genericocireg/repo_test.go @@ -50,8 +50,10 @@ import ( var DefaultContext = ocm.New() -const COMPONENT = "github.com/mandelsoft/ocm" -const TESTBASE = "testbase.de" +const ( + COMPONENT = "github.com/mandelsoft/ocm" + TESTBASE = "testbase.de" +) var _ = Describe("component repository mapping", func() { var tempfs vfs.FileSystem @@ -221,7 +223,7 @@ var _ = Describe("component repository mapping", func() { // create artifactset opts := Must(accessio.AccessOptions(nil, accessio.PathFileSystem(tempfs))) - r := Must(artifactset.FormatTGZ.Create("test.tgz", opts, 0700)) + r := Must(artifactset.FormatTGZ.Create("test.tgz", opts, 0o700)) testhelper.DefaultManifestFill(r) r.Annotate(artifactset.MAINARTIFACT_ANNOTATION, "sha256:"+testhelper.DIGEST_MANIFEST) Expect(r.Close()).To(Succeed()) diff --git a/pkg/contexts/ocm/repositories/genericocireg/semver_test.go b/pkg/contexts/ocm/repositories/genericocireg/semver_test.go index 21af86792a..51c20e538a 100644 --- a/pkg/contexts/ocm/repositories/genericocireg/semver_test.go +++ b/pkg/contexts/ocm/repositories/genericocireg/semver_test.go @@ -26,16 +26,13 @@ func mapversion(s *semver.Version) (*semver.Version, error) { } var _ = Describe("ref parsing", func() { - It("omit v", func() { - s := Must(semver.NewVersion("1.0.0-rc.1+65")) v := Must(mapversion(s)) Expect(v.Original()).To(Equal("1.0.0-rc.1" + META_SEPARATOR + "65")) }) It("keep v", func() { - s := Must(semver.NewVersion("v1.0.0-rc.1+65")) s.Metadata() @@ -43,12 +40,10 @@ var _ = Describe("ref parsing", func() { Expect(v.Original()).To(Equal("v1.0.0-rc.1" + META_SEPARATOR + "65")) }) It("no meta", func() { - s := Must(semver.NewVersion("v1.0.0-rc.1")) s.Metadata() v := Must(mapversion(s)) Expect(v.Original()).To(Equal("v1.0.0-rc.1")) }) - }) diff --git a/pkg/contexts/ocm/repositories/ocireg/specnorm_test.go b/pkg/contexts/ocm/repositories/ocireg/specnorm_test.go index 087c05eb97..e20994ed95 100644 --- a/pkg/contexts/ocm/repositories/ocireg/specnorm_test.go +++ b/pkg/contexts/ocm/repositories/ocireg/specnorm_test.go @@ -10,7 +10,6 @@ import ( ) var _ = Describe("ref parsing", func() { - Context("deserialization", func() { It("handles regular spec", func() { spec := ` diff --git a/pkg/contexts/ocm/repositories/virtual/repo_test.go b/pkg/contexts/ocm/repositories/virtual/repo_test.go index 2ed51f6fe3..d18c56cef8 100644 --- a/pkg/contexts/ocm/repositories/virtual/repo_test.go +++ b/pkg/contexts/ocm/repositories/virtual/repo_test.go @@ -4,7 +4,6 @@ import ( . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/open-component-model/ocm/pkg/blobaccess" . "github.com/open-component-model/ocm/pkg/env" . "github.com/open-component-model/ocm/pkg/env/builder" @@ -13,6 +12,7 @@ import ( "github.com/mandelsoft/vfs/pkg/memoryfs" "github.com/mandelsoft/vfs/pkg/projectionfs" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/contexts/ocm" "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/compose" "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/localblob" @@ -122,7 +122,6 @@ var _ = Describe("virtual repo", func() { a = Must(r.Access()) Expect(a.GetInexpensiveContentVersionIdentity(vers)).To(Equal("sha256:" + dig)) - }, Entry("with direct mode", false, localblob.Type), Entry("with composition mode", true, compose.Type), diff --git a/pkg/contexts/ocm/resolver_test.go b/pkg/contexts/ocm/resolver_test.go index 49fbaf6558..0161456b49 100644 --- a/pkg/contexts/ocm/resolver_test.go +++ b/pkg/contexts/ocm/resolver_test.go @@ -17,9 +17,11 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ocireg" ) -const ARCH = "ctf" -const COMPONENT = "ocm.software/test" -const VERSION = "1.0.0" +const ( + ARCH = "ctf" + COMPONENT = "ocm.software/test" + VERSION = "1.0.0" +) var _ = Describe("resolver", func() { var env *Builder @@ -40,7 +42,6 @@ var _ = Describe("resolver", func() { }) It("lookup cv per standard resolver", func() { - // ocmlog.Context().AddRule(logging.NewConditionRule(logging.TraceLevel, accessio.ALLOC_REALM)) ctx := ocm.New() diff --git a/pkg/contexts/ocm/session_test.go b/pkg/contexts/ocm/session_test.go index f60f40ad39..15c09d85ba 100644 --- a/pkg/contexts/ocm/session_test.go +++ b/pkg/contexts/ocm/session_test.go @@ -22,7 +22,6 @@ func (*test_spec) Key() (string, error) { } var _ = Describe("session", func() { - It("spec without key function", func() { spec := ocmreg.NewRepositorySpec("gcr.io", nil) key := Must(utils.Key(spec)) diff --git a/pkg/contexts/ocm/signing/signing_test.go b/pkg/contexts/ocm/signing/signing_test.go index 9ab58e927e..d6c47d8ce5 100644 --- a/pkg/contexts/ocm/signing/signing_test.go +++ b/pkg/contexts/ocm/signing/signing_test.go @@ -11,7 +11,6 @@ import ( . "github.com/onsi/gomega" . "github.com/open-component-model/ocm/pkg/contexts/oci/testhelper" . "github.com/open-component-model/ocm/pkg/contexts/ocm/signing" - "github.com/open-component-model/ocm/pkg/contexts/ocm/signing/signingtest" . "github.com/open-component-model/ocm/pkg/contexts/ocm/testhelper" . "github.com/open-component-model/ocm/pkg/env/builder" @@ -30,6 +29,7 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/composition" "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ctf" "github.com/open-component-model/ocm/pkg/contexts/ocm/resourcetypes" + "github.com/open-component-model/ocm/pkg/contexts/ocm/signing/signingtest" "github.com/open-component-model/ocm/pkg/mime" "github.com/open-component-model/ocm/pkg/signing" "github.com/open-component-model/ocm/pkg/signing/handlers/rsa" @@ -40,20 +40,24 @@ import ( var DefaultContext = ocm.New() -const ARCH = "/tmp/ctf" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENTA = "github.com/mandelsoft/test" -const COMPONENTB = "github.com/mandelsoft/ref" -const COMPONENTC = "github.com/mandelsoft/ref2" -const COMPONENTD = "github.com/mandelsoft/top" -const OUT = "/tmp/res" -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" - -const SIGNATURE = "test" -const SIGNATURE2 = "second" -const SIGN_ALGO = rsa.Algorithm +const ( + ARCH = "/tmp/ctf" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENTA = "github.com/mandelsoft/test" + COMPONENTB = "github.com/mandelsoft/ref" + COMPONENTC = "github.com/mandelsoft/ref2" + COMPONENTD = "github.com/mandelsoft/top" + OUT = "/tmp/res" + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) + +const ( + SIGNATURE = "test" + SIGNATURE2 = "second" + SIGN_ALGO = rsa.Algorithm +) var _ = Describe("access method", func() { var env *Builder @@ -289,7 +293,6 @@ applying to version "github.com/mandelsoft/test:v1"[github.com/mandelsoft/test:v Expect(err.Error()).To(StringEqualTrimmedWithContext("github.com/mandelsoft/test:v1: signature digest (0ae7ab0c1578d1292922b2a3884833c380a57df2cc7dfab7213ee051b092edc3) does not match found digest (" + digestA + ")")) // Reset to original to avoid write back in readonly mode cv.GetDescriptor().Signatures[0].Digest.Value = digestA - }, Entry(DIGESTMODE_TOP, DIGESTMODE_TOP), Entry(DIGESTMODE_LOCAL, DIGESTMODE_LOCAL), @@ -341,7 +344,6 @@ applying to version "github.com/mandelsoft/test:v1"[github.com/mandelsoft/test:v dig, err = Apply(nil, nil, cv, opts) Expect(err).To(Succeed()) Expect(dig.Value).To(Equal(digestA)) - }, Entry(DIGESTMODE_TOP, DIGESTMODE_TOP), Entry(DIGESTMODE_LOCAL, DIGESTMODE_LOCAL), @@ -911,7 +913,6 @@ github.com/mandelsoft/test:v1: SHA-256:${D_COMPA}[jsonNormalisation/v1] ) DescribeTable("fixes digest mode", func(subst Substitutions, mopts ...ocm.ModificationOption) { - setup(mopts...) var finalizer Finalizer @@ -1375,7 +1376,6 @@ func (*EntryLocal) Check1Corrupt(cva ocm.ComponentVersionAccess, f *Finalizer, _ cva.GetDescriptor().Resources[0].Digest.Value = wrongDigest MustBeSuccessful(cva.Update()) Check(f.Finalize) - } func (*EntryLocal) Check2Ref(cv ocm.ComponentVersionAccess, name string, d string) { diff --git a/pkg/contexts/ocm/signing/transport_test.go b/pkg/contexts/ocm/signing/transport_test.go index 8f787192d1..7d3e76a045 100644 --- a/pkg/contexts/ocm/signing/transport_test.go +++ b/pkg/contexts/ocm/signing/transport_test.go @@ -3,11 +3,11 @@ package signing_test import ( "fmt" + // . "github.com/open-component-model/ocm/pkg/contexts/ocm/signing" + . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/open-component-model/ocm/pkg/contexts/oci/testhelper" - // . "github.com/open-component-model/ocm/pkg/contexts/ocm/signing" - . "github.com/mandelsoft/goutils/testutils" . "github.com/open-component-model/ocm/pkg/contexts/ocm/testhelper" . "github.com/open-component-model/ocm/pkg/env/builder" diff --git a/pkg/contexts/ocm/testhelper/resources.go b/pkg/contexts/ocm/testhelper/resources.go index c43778bf2c..c3f71361c3 100644 --- a/pkg/contexts/ocm/testhelper/resources.go +++ b/pkg/contexts/ocm/testhelper/resources.go @@ -1,4 +1,3 @@ -//nolint:gosec // digests of test manifests package testhelper import ( diff --git a/pkg/contexts/ocm/transfer/autohandler_test.go b/pkg/contexts/ocm/transfer/autohandler_test.go index 0d8c8a072f..8a627abed5 100644 --- a/pkg/contexts/ocm/transfer/autohandler_test.go +++ b/pkg/contexts/ocm/transfer/autohandler_test.go @@ -57,5 +57,4 @@ var _ = Describe("auto detection", func() { Expect(err).To(Equal(errors.ErrNotSupported(transferhandler.KIND_TRANSFEROPTION, "error"))) }) - }) diff --git a/pkg/contexts/ocm/transfer/transferhandler/spiff/handler_test.go b/pkg/contexts/ocm/transfer/transferhandler/spiff/handler_test.go index 8525f64fdd..f58abbc033 100644 --- a/pkg/contexts/ocm/transfer/transferhandler/spiff/handler_test.go +++ b/pkg/contexts/ocm/transfer/transferhandler/spiff/handler_test.go @@ -10,6 +10,7 @@ import ( . "github.com/open-component-model/ocm/pkg/env/builder" "github.com/mandelsoft/goutils/testutils" + "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/accessobj" "github.com/open-component-model/ocm/pkg/contexts/oci" @@ -26,15 +27,17 @@ import ( "github.com/open-component-model/ocm/pkg/mime" ) -const ARCH = "/tmp/ctf" -const ARCH2 = "/tmp/ctf2" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENT = "github.com/mandelsoft/test" -const COMPONENT2 = "github.com/mandelsoft/test2" -const OUT = "/tmp/res" -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" +const ( + ARCH = "/tmp/ctf" + ARCH2 = "/tmp/ctf2" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENT = "github.com/mandelsoft/test" + COMPONENT2 = "github.com/mandelsoft/test2" + OUT = "/tmp/res" + OCIPATH = "/tmp/oci" + OCIHOST = "alias" +) const script1 = ` rules: @@ -56,9 +59,7 @@ process: (( (*(rules[mode] || rules.default)).process )) ` var _ = Describe("Transfer handler", func() { - It("handles bool", func() { - handler, err := spiff.New(spiff.Script([]byte(script1))) Expect(err).To(Succeed()) @@ -74,7 +75,6 @@ var _ = Describe("Transfer handler", func() { }) It("handles componentversion", func() { - handler, err := spiff.New(spiff.Script([]byte(script1))) Expect(err).To(Succeed()) @@ -92,7 +92,6 @@ var _ = Describe("Transfer handler", func() { }) It("handles simple componentversion", func() { - handler, err := spiff.New(spiff.Script([]byte(script1))) Expect(err).To(Succeed()) binding := map[string]interface{}{ @@ -177,7 +176,7 @@ process: (( (*(rules[mode] || rules.default)).process )) Expect(err).To(Succeed()) cv, err := src.LookupComponentVersion(COMPONENT, VERSION) Expect(err).To(Succeed()) - tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env) + tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env) Expect(err).To(Succeed()) defer tgt.Close() @@ -227,7 +226,7 @@ process: (( (*(rules[mode] || rules.default)).process )) Expect(err).To(Succeed()) cv, err := src.LookupComponentVersion(COMPONENT, VERSION) Expect(err).To(Succeed()) - tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env) + tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env) Expect(err).To(Succeed()) defer tgt.Close() @@ -278,7 +277,7 @@ process: (( (*(rules[mode] || rules.default)).process )) Expect(err).To(Succeed()) childSrc, err := ctf.Open(env.OCMContext(), accessobj.ACC_READONLY, ARCH, 0, env) Expect(err).To(Succeed()) - tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env) + tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env) Expect(err).To(Succeed()) defer tgt.Close() handler, err := standard.New(standard.Recursive(), standard.Resolver(childSrc)) diff --git a/pkg/contexts/ocm/transfer/transferhandler/standard/handler_test.go b/pkg/contexts/ocm/transfer/transferhandler/standard/handler_test.go index 52c7bb1937..2832442ba6 100644 --- a/pkg/contexts/ocm/transfer/transferhandler/standard/handler_test.go +++ b/pkg/contexts/ocm/transfer/transferhandler/standard/handler_test.go @@ -7,13 +7,13 @@ import ( . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/open-component-model/ocm/pkg/blobaccess" . "github.com/open-component-model/ocm/pkg/contexts/oci/testhelper" . "github.com/open-component-model/ocm/pkg/contexts/ocm/testhelper" . "github.com/open-component-model/ocm/pkg/env/builder" "github.com/mandelsoft/goutils/finalizer" + "github.com/open-component-model/ocm/pkg/blobaccess" "github.com/open-component-model/ocm/pkg/common" "github.com/open-component-model/ocm/pkg/common/accessio" "github.com/open-component-model/ocm/pkg/common/accessobj" @@ -38,17 +38,19 @@ import ( "github.com/open-component-model/ocm/pkg/signing/handlers/rsa" ) -const ARCH = "/tmp/ctf" -const ARCH2 = "/tmp/ctf2" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENT = "github.com/mandelsoft/test" -const COMPONENT2 = "github.com/mandelsoft/test2" -const OUT = "/tmp/res" -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" -const SIGNATURE = "test" -const SIGN_ALGO = rsa.Algorithm +const ( + ARCH = "/tmp/ctf" + ARCH2 = "/tmp/ctf2" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENT = "github.com/mandelsoft/test" + COMPONENT2 = "github.com/mandelsoft/test2" + OUT = "/tmp/res" + OCIPATH = "/tmp/oci" + OCIHOST = "alias" + SIGNATURE = "test" + SIGN_ALGO = rsa.Algorithm +) type optionsChecker struct { standard.TransferOptionsCreator @@ -100,7 +102,6 @@ var _ = Describe("Transfer handler", func() { }) }) }) - }) AfterEach(func() { @@ -112,7 +113,7 @@ var _ = Describe("Transfer handler", func() { defer Close(src, "source") cv := Must(src.LookupComponentVersion(COMPONENT, VERSION)) defer Close(cv, "source cv") - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer Close(tgt, "target") tcv := Must(tgt.NewComponentVersion(cv.GetName(), cv.GetVersion())) @@ -137,7 +138,7 @@ var _ = Describe("Transfer handler", func() { defer Close(src, "source") cv := Must(src.LookupComponentVersion(COMPONENT, VERSION)) defer Close(cv, "source cv") - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer Close(tgt, "target") // handler, err := standard.New(standard.ResourcesByValue()) @@ -176,7 +177,7 @@ transferring version "github.com/mandelsoft/test:v1"... defer Close(src, "source") cv := Must(src.LookupComponentVersion(COMPONENT, VERSION)) defer Close(cv, "source cv") - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer Close(tgt, "target") // handler, err := standard.New(standard.ResourcesByValue()) @@ -265,7 +266,6 @@ warning: version "github.com/mandelsoft/test:v1" already present, but differs nested.Close(tcv, "target cv") Expect(tcd).To(DeepEqual(tcv.GetDescriptor())) MustBeSuccessful(nested.Finalize()) - }, Entry("without preserve global", "{\"localReference\":\"%s\",\"mediaType\":\"application/vnd.oci.image.manifest.v1+tar+gzip\",\"referenceName\":\""+OCINAMESPACE+":"+OCIVERSION+"\",\"type\":\"localBlob\"}", @@ -290,7 +290,7 @@ warning: version "github.com/mandelsoft/test:v1" already present, but differs defer Close(src, "source") cv := Must(src.LookupComponentVersion(COMPONENT, VERSION)) defer Close(cv, "source cv") - tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env)) + tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) defer Close(tgt, "target") // transfer by reference, first @@ -404,7 +404,6 @@ warning: version "github.com/mandelsoft/test:v1" already present, but differs ntcd := tcv.GetDescriptor() Expect(tcd).To(DeepEqual(ntcd)) MustBeSuccessful(nested.Finalize()) - }, Entry("without preserve global", "{\"localReference\":\"%s\",\"mediaType\":\"application/vnd.oci.image.manifest.v1+tar+gzip\",\"referenceName\":\""+OCINAMESPACE+":"+OCIVERSION+"\",\"type\":\"localBlob\"}", @@ -427,7 +426,7 @@ warning: version "github.com/mandelsoft/test:v1" already present, but differs Expect(err).To(Succeed()) cv, err := src.LookupComponentVersion(COMPONENT, VERSION) Expect(err).To(Succeed()) - tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env) + tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env) Expect(err).To(Succeed()) defer tgt.Close() @@ -465,7 +464,7 @@ warning: version "github.com/mandelsoft/test:v1" already present, but differs Expect(err).To(Succeed()) childSrc, err := ctf.Open(env.OCMContext(), accessobj.ACC_READONLY, ARCH, 0, env) Expect(err).To(Succeed()) - tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env) + tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env) Expect(err).To(Succeed()) defer tgt.Close() handler, err := standard.New(standard.Recursive(), standard.Resolver(childSrc)) @@ -505,7 +504,7 @@ warning: version "github.com/mandelsoft/test:v1" already present, but differs Expect(len(cv.GetDescriptor().Signatures)).To(Equal(1)) - tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0700, accessio.FormatDirectory, env) + tgt, err := ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env) Expect(err).To(Succeed()) defer tgt.Close() handler, err := standard.New(standard.ResourcesByValue()) diff --git a/pkg/contexts/ocm/utils/check/check_test.go b/pkg/contexts/ocm/utils/check/check_test.go index 883087ad01..b2e4de792e 100644 --- a/pkg/contexts/ocm/utils/check/check_test.go +++ b/pkg/contexts/ocm/utils/check/check_test.go @@ -18,12 +18,14 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/utils/check" ) -const ARCH = "/tmp/ca" -const VERSION = "v1" -const COMP = "test.de/x" -const COMP2 = "test.de/y" -const COMP3 = "test.de/z" -const COMP4 = "test.de/a" +const ( + ARCH = "/tmp/ca" + VERSION = "v1" + COMP = "test.de/x" + COMP2 = "test.de/y" + COMP3 = "test.de/z" + COMP4 = "test.de/a" +) var _ = Describe("Test Environment", func() { var env *Builder diff --git a/pkg/contexts/ocm/utils/localize/config_test.go b/pkg/contexts/ocm/utils/localize/config_test.go index 3b79594285..5b8615c71d 100644 --- a/pkg/contexts/ocm/utils/localize/config_test.go +++ b/pkg/contexts/ocm/utils/localize/config_test.go @@ -161,7 +161,6 @@ utilities: }) It("uses resolved library from component version", func() { - configs := UnmarshalConfigurations(` - name: test1 file: file1 @@ -185,7 +184,6 @@ utilities: }) It("uses templated configRules", func() { - configs := UnmarshalConfigurations(` - name: test1 file: file1 diff --git a/pkg/contexts/ocm/utils/localize/instantiate_test.go b/pkg/contexts/ocm/utils/localize/instantiate_test.go index d60528f22e..ad5f2f5629 100644 --- a/pkg/contexts/ocm/utils/localize/instantiate_test.go +++ b/pkg/contexts/ocm/utils/localize/instantiate_test.go @@ -28,7 +28,6 @@ import ( const RESOURCE_TYPE = "gitOpsTemplate" var _ = Describe("image value mapping", func() { - const ( ARCHIVE = "archive.ctf" COMPONENT = "github.com/comp" diff --git a/pkg/contexts/ocm/utils/localize/localize_test.go b/pkg/contexts/ocm/utils/localize/localize_test.go index 0d5b261f00..005e317374 100644 --- a/pkg/contexts/ocm/utils/localize/localize_test.go +++ b/pkg/contexts/ocm/utils/localize/localize_test.go @@ -17,7 +17,6 @@ import ( ) var _ = Describe("image value mapping", func() { - const ( ARCHIVE = "archive.ctf" COMPONENT = "github.com/comp" @@ -61,7 +60,6 @@ var _ = Describe("image value mapping", func() { }) It("uses image ref data from component version", func() { - mappings := UnmarshalLocalizations(` - name: test1 file: file1 @@ -80,7 +78,6 @@ var _ = Describe("image value mapping", func() { }) It("uses multiple resolved image ref data from component version", func() { - mappings := UnmarshalLocalizations(` - name: test1 file: file1 diff --git a/pkg/contexts/ocm/utils/localize/subst_test.go b/pkg/contexts/ocm/utils/localize/subst_test.go index 74b3c6aa2a..8d4abd874e 100644 --- a/pkg/contexts/ocm/utils/localize/subst_test.go +++ b/pkg/contexts/ocm/utils/localize/subst_test.go @@ -94,5 +94,4 @@ manifest: `) }) - }) diff --git a/pkg/contexts/ocm/utils/localize/target_test.go b/pkg/contexts/ocm/utils/localize/target_test.go index c2c048de5d..0da19d9fc4 100644 --- a/pkg/contexts/ocm/utils/localize/target_test.go +++ b/pkg/contexts/ocm/utils/localize/target_test.go @@ -17,7 +17,6 @@ import ( ) var _ = Describe("value substitution in single target", func() { - Context("localize", func() { const ( ARCHIVE = "archive.ctf" @@ -78,7 +77,6 @@ var _ = Describe("value substitution in single target", func() { }) It("uses multiple resolved image ref data from component version", func() { - mappings := UnmarshalImageMappings(` - name: test1 repository: a.b.rep @@ -104,7 +102,7 @@ var _ = Describe("value substitution in single target", func() { }) Context("substitute", func() { - var data = []byte(` + data := []byte(` manifest: value1: orig1 value2: orig2 diff --git a/pkg/contexts/ocm/utils/registry/registry_test.go b/pkg/contexts/ocm/utils/registry/registry_test.go index 3dfd2dd514..5ffe487023 100644 --- a/pkg/contexts/ocm/utils/registry/registry_test.go +++ b/pkg/contexts/ocm/utils/registry/registry_test.go @@ -9,12 +9,14 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/utils/registry" ) -var aKey = registry.RegistrationKey{}.SetArtifact("a", "") -var mKey = registry.RegistrationKey{}.SetArtifact("", "m") -var amKey = registry.RegistrationKey{}.SetArtifact("a", "m") -var a1mKey = registry.RegistrationKey{}.SetArtifact("a1", "m") -var am1Key = registry.RegistrationKey{}.SetArtifact("a", "m1") -var amtarKey = registry.RegistrationKey{}.SetArtifact("a", "m+tar") +var ( + aKey = registry.RegistrationKey{}.SetArtifact("a", "") + mKey = registry.RegistrationKey{}.SetArtifact("", "m") + amKey = registry.RegistrationKey{}.SetArtifact("a", "m") + a1mKey = registry.RegistrationKey{}.SetArtifact("a1", "m") + am1Key = registry.RegistrationKey{}.SetArtifact("a", "m1") + amtarKey = registry.RegistrationKey{}.SetArtifact("a", "m+tar") +) var _ = Describe("lookup", func() { var reg *registry.Registry[string, registry.RegistrationKey] diff --git a/pkg/contexts/ocm/utils/resourceref_test.go b/pkg/contexts/ocm/utils/resourceref_test.go index 811fb83aff..1194ca3ec9 100644 --- a/pkg/contexts/ocm/utils/resourceref_test.go +++ b/pkg/contexts/ocm/utils/resourceref_test.go @@ -18,17 +18,19 @@ import ( "github.com/open-component-model/ocm/pkg/signing/handlers/rsa" ) -const ARCH = "/tmp/ctf" -const PROVIDER = "mandelsoft" -const VERSION = "v1" -const COMPONENT = "github.com/mandelsoft/test" -const COMPONENT2 = "github.com/mandelsoft/test2" -const COMPONENT3 = "github.com/mandelsoft/test3" -const OUT = "/tmp/res" -const OCIPATH = "/tmp/oci" -const OCIHOST = "alias" -const SIGNATURE = "test" -const SIGN_ALGO = rsa.Algorithm +const ( + ARCH = "/tmp/ctf" + PROVIDER = "mandelsoft" + VERSION = "v1" + COMPONENT = "github.com/mandelsoft/test" + COMPONENT2 = "github.com/mandelsoft/test2" + COMPONENT3 = "github.com/mandelsoft/test3" + OUT = "/tmp/res" + OCIPATH = "/tmp/oci" + OCIHOST = "alias" + SIGNATURE = "test" + SIGN_ALGO = rsa.Algorithm +) func CheckResourceRef(cv ocm.ComponentVersionAccess, name string, path ...metav1.Identity) { data := Must(utils.GetResourceDataForRef(cv, metav1.NewNestedResourceRef(metav1.NewIdentity(name), path))) diff --git a/pkg/contexts/ocm/valuemergehandler/config/config_test.go b/pkg/contexts/ocm/valuemergehandler/config/config_test.go index f5f624c767..824ceb1150 100644 --- a/pkg/contexts/ocm/valuemergehandler/config/config_test.go +++ b/pkg/contexts/ocm/valuemergehandler/config/config_test.go @@ -16,7 +16,6 @@ import ( ) var _ = Describe("merge config", func() { - spec1 := Must(v1.NewMergeAlgorithmSpecification("test", "config1")) spec2 := Must(v1.NewMergeAlgorithmSpecification("algo", "config2")) diff --git a/pkg/contexts/ocm/valuemergehandler/handlers/maplistmerge/handler_test.go b/pkg/contexts/ocm/valuemergehandler/handlers/maplistmerge/handler_test.go index 7ca7efb849..370d01f9f4 100644 --- a/pkg/contexts/ocm/valuemergehandler/handlers/maplistmerge/handler_test.go +++ b/pkg/contexts/ocm/valuemergehandler/handlers/maplistmerge/handler_test.go @@ -11,17 +11,23 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/valuemergehandler/hpi" ) -type Value = me.Value -type VEntry = simplemapmerge.Value -type Config = me.Config +type ( + Value = me.Value + VEntry = simplemapmerge.Value + Config = me.Config +) -const ALGORITHM = me.ALGORITHM -const MODE_NONE = me.MODE_NONE -const MODE_LOCAL = me.MODE_LOCAL -const MODE_INBOUND = me.MODE_INBOUND +const ( + ALGORITHM = me.ALGORITHM + MODE_NONE = me.MODE_NONE + MODE_LOCAL = me.MODE_LOCAL + MODE_INBOUND = me.MODE_INBOUND +) -var NewConfig = me.NewConfig -var New = me.New +var ( + NewConfig = me.NewConfig + New = me.New +) var _ = Describe("list merge", func() { handler := New() @@ -140,7 +146,6 @@ var _ = Describe("list merge", func() { }) It("handles merge", func() { - d1[0]["local"] = "local" d2[0]["inbound"] = "inbound" @@ -187,5 +192,4 @@ var _ = Describe("list merge", func() { Expect(r).To(DeepEqual(d1)) }) }) - }) diff --git a/pkg/contexts/ocm/valuemergehandler/handlers/plugin/handler_test.go b/pkg/contexts/ocm/valuemergehandler/handlers/plugin/handler_test.go index dd104752a8..bad5ca3ad0 100644 --- a/pkg/contexts/ocm/valuemergehandler/handlers/plugin/handler_test.go +++ b/pkg/contexts/ocm/valuemergehandler/handlers/plugin/handler_test.go @@ -16,8 +16,10 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/valuemergehandler/hpi" ) -const PLUGIN = "merge" -const ALGORITHM = "acme.org/test" +const ( + PLUGIN = "merge" + ALGORITHM = "acme.org/test" +) var _ = Describe("plugin value merge handler", func() { var ctx ocm.Context diff --git a/pkg/contexts/ocm/valuemergehandler/handlers/simplelistmerge/handler_test.go b/pkg/contexts/ocm/valuemergehandler/handlers/simplelistmerge/handler_test.go index 532680cb0a..b7bdd07cb4 100644 --- a/pkg/contexts/ocm/valuemergehandler/handlers/simplelistmerge/handler_test.go +++ b/pkg/contexts/ocm/valuemergehandler/handlers/simplelistmerge/handler_test.go @@ -9,11 +9,15 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/valuemergehandler/hpi" ) -type Value = me.Value -type Config = me.Config +type ( + Value = me.Value + Config = me.Config +) -var NewConfig = me.NewConfig -var New = me.New +var ( + NewConfig = me.NewConfig + New = me.New +) var _ = Describe("list merge", func() { handler := New() diff --git a/pkg/contexts/ocm/valuemergehandler/handlers/simplemapmerge/handler_test.go b/pkg/contexts/ocm/valuemergehandler/handlers/simplemapmerge/handler_test.go index 119df97e8d..f951af1efd 100644 --- a/pkg/contexts/ocm/valuemergehandler/handlers/simplemapmerge/handler_test.go +++ b/pkg/contexts/ocm/valuemergehandler/handlers/simplemapmerge/handler_test.go @@ -10,16 +10,22 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/valuemergehandler/hpi" ) -type Value = me.Value -type Config = me.Config +type ( + Value = me.Value + Config = me.Config +) -const ALGORITHM = me.ALGORITHM -const MODE_NONE = me.MODE_NONE -const MODE_LOCAL = me.MODE_LOCAL -const MODE_INBOUND = me.MODE_INBOUND +const ( + ALGORITHM = me.ALGORITHM + MODE_NONE = me.MODE_NONE + MODE_LOCAL = me.MODE_LOCAL + MODE_INBOUND = me.MODE_INBOUND +) -var NewConfig = me.NewConfig -var New = me.New +var ( + NewConfig = me.NewConfig + New = me.New +) var _ = Describe("list merge", func() { handler := New() @@ -165,6 +171,5 @@ var _ = Describe("list merge", func() { MustBeSuccessful(b.GetValue(&r)) Expect(r).To(DeepEqual(d1)) }) - }) }) diff --git a/pkg/env/builder/ocm_version_test.go b/pkg/env/builder/ocm_version_test.go index bc1f8e0639..40ffa2ca1b 100644 --- a/pkg/env/builder/ocm_version_test.go +++ b/pkg/env/builder/ocm_version_test.go @@ -15,12 +15,14 @@ import ( ocmutils "github.com/open-component-model/ocm/pkg/contexts/ocm/utils" ) -const ARCH = "/tmp/ctf" -const ARCH2 = "/tmp/ctf2" -const PROVIDER = "open-component-model" -const VERSION = "v1" -const COMPONENT = "github.com/open-component-model/test" -const OUT = "/tmp/res" +const ( + ARCH = "/tmp/ctf" + ARCH2 = "/tmp/ctf2" + PROVIDER = "open-component-model" + VERSION = "v1" + COMPONENT = "github.com/open-component-model/test" + OUT = "/tmp/res" +) var _ = Describe("Transfer handler", func() { var env *Builder diff --git a/pkg/env/env_test.go b/pkg/env/env_test.go index a0896094ca..ab7ae3b64f 100644 --- a/pkg/env/env_test.go +++ b/pkg/env/env_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Environment", func() { - It("loads environment", func() { h := NewEnvironment(TestData()) defer h.Cleanup() @@ -25,5 +24,4 @@ var _ = Describe("Environment", func() { h := NewEnvironment(OCMContext(ctx), FileSystem(osfs.OsFs)) Expect(h.OCMContext()).To(BeIdenticalTo(ctx)) }) - }) diff --git a/pkg/errors/error_test.go b/pkg/errors/error_test.go index 3080551a8e..f8399022c6 100644 --- a/pkg/errors/error_test.go +++ b/pkg/errors/error_test.go @@ -14,7 +14,6 @@ var _ = Describe("errors", func() { Expect(errors.IsErrReadOnlyKind(uerr, "KIND")).To(BeTrue()) Expect(errors.IsErrReadOnlyKind(uerr, "other")).To(BeFalse()) - }) It("message with elem", func() { uerr := errors.ErrReadOnly("KIND", "obj") @@ -33,7 +32,6 @@ var _ = Describe("errors", func() { Expect(errors.IsErrUnknownKind(uerr, "KIND")).To(BeTrue()) Expect(errors.IsErrUnknownKind(uerr, "other")).To(BeFalse()) - }) It("find error in history", func() { uerr := errors.ErrUnknown("KIND", "obj") @@ -43,5 +41,4 @@ var _ = Describe("errors", func() { Expect(errors.IsErrUnknownKind(werr, "other")).To(BeFalse()) }) }) - }) diff --git a/pkg/errors/list_test.go b/pkg/errors/list_test.go index 2b81b325dd..0a0957d1c5 100644 --- a/pkg/errors/list_test.go +++ b/pkg/errors/list_test.go @@ -65,5 +65,4 @@ var _ = Describe("error list", func() { Expect(exp.Error()).To(Equal("\"test\" is invalid")) }) }) - }) diff --git a/pkg/exception/exception_test.go b/pkg/exception/exception_test.go index b6bdf5e9d0..c8b2916074 100644 --- a/pkg/exception/exception_test.go +++ b/pkg/exception/exception_test.go @@ -84,7 +84,6 @@ var _ = Describe("exceptions", func() { }) Context("with matchers", func() { - caller := func(e error, args ...interface{}) (err error) { defer exception.PropagateException(&err, exception.ByPrototypes(MyException{})) _caller(e, args...) diff --git a/pkg/logging/config_test.go b/pkg/logging/config_test.go index 2a9c95359a..062a95d560 100644 --- a/pkg/logging/config_test.go +++ b/pkg/logging/config_test.go @@ -52,5 +52,4 @@ V[2] warn realm ocm ERROR error realm ocm `)) }) - }) diff --git a/pkg/maven/coordinates_test.go b/pkg/maven/coordinates_test.go index ad38cf73d2..796420f35a 100644 --- a/pkg/maven/coordinates_test.go +++ b/pkg/maven/coordinates_test.go @@ -11,7 +11,6 @@ import ( ) var _ = Describe("Maven Test Environment", func() { - It("GAV, GroupPath, FilePath", func() { coords := me.NewCoordinates("ocm.software", "hello-ocm", "0.0.1", me.WithExtension("jar")) Expect(coords.GAV()).To(Equal("ocm.software:hello-ocm:0.0.1")) diff --git a/pkg/maven/maventest/const.go b/pkg/maven/maventest/const.go index 407ca55322..7c2deea322 100644 --- a/pkg/maven/maventest/const.go +++ b/pkg/maven/maventest/const.go @@ -6,7 +6,7 @@ const ( VERSION = "5.7.0" ARTIFACT_SIZE = 1504 - ARTIFACT_DIGEST = "dc5b38b58fd18cb0336c2e0deebeb5d2277c34312ae7024074812f34acfebc65" //nolint: gosec // yes + ARTIFACT_DIGEST = "dc5b38b58fd18cb0336c2e0deebeb5d2277c34312ae7024074812f34acfebc65" ) const POM_SHA1 = "SHA-1:34ccdeb9c008f8aaef90873fc636b09d3ae5c709" diff --git a/pkg/npm/login.go b/pkg/npm/login.go index 955750cdf3..6eaa94b2e8 100644 --- a/pkg/npm/login.go +++ b/pkg/npm/login.go @@ -34,7 +34,7 @@ func Login(registry string, username string, password string, email string) (str return "", err } req.SetBasicAuth(username, password) - req.Header.Set("content-type", "application/json") + req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { return "", err diff --git a/pkg/refmgmt/finalized/finalized_test.go b/pkg/refmgmt/finalized/finalized_test.go index 5847592b0d..bd8e3c4189 100644 --- a/pkg/refmgmt/finalized/finalized_test.go +++ b/pkg/refmgmt/finalized/finalized_test.go @@ -136,7 +136,5 @@ var _ = Describe("finalized ref", func() { rrefid, id, )) - }) - }) diff --git a/pkg/refmgmt/resource/resource_test.go b/pkg/refmgmt/resource/resource_test.go index 2a4f4e7fda..e6a3fc4a10 100644 --- a/pkg/refmgmt/resource/resource_test.go +++ b/pkg/refmgmt/resource/resource_test.go @@ -90,7 +90,6 @@ func New(name string) Resource { var _ = Describe("ref test", func() { It("handles main ref", func() { - r := New("alice") Expect(r.IsClosed()).To(BeFalse()) @@ -102,7 +101,6 @@ var _ = Describe("ref test", func() { }) It("handle last closed view", func() { - r := New("alice") Expect(r.IsClosed()).To(BeFalse()) v := Must(r.Dup()) diff --git a/pkg/registrations/registrations_test.go b/pkg/registrations/registrations_test.go index e485edba92..983aff661f 100644 --- a/pkg/registrations/registrations_test.go +++ b/pkg/registrations/registrations_test.go @@ -9,11 +9,9 @@ import ( "github.com/open-component-model/ocm/pkg/utils" ) -type Target interface { -} +type Target interface{} -type Option struct { -} +type Option struct{} //////////////////////////////////////////////////////////////////////////////// // Test instantiation of generic type @@ -34,8 +32,7 @@ func NewRegistrationHandlerInfo(path string, handler HandlerRegistrationHandler) //////////////////////////////////////////////////////////////////////////////// -type Handler struct { -} +type Handler struct{} func (b Handler) Do() { } diff --git a/pkg/runtime/binary.go b/pkg/runtime/binary.go index 8f037e014d..0593731a1b 100644 --- a/pkg/runtime/binary.go +++ b/pkg/runtime/binary.go @@ -40,5 +40,7 @@ func (m *Binary) UnmarshalJSON(data []byte) error { return nil } -var _ json.Marshaler = (*Binary)(nil) //nolint: gofumpt // yes -var _ json.Unmarshaler = (*Binary)(nil) +var ( + _ json.Marshaler = (*Binary)(nil) + _ json.Unmarshaler = (*Binary)(nil) +) diff --git a/pkg/runtime/object_test.go b/pkg/runtime/object_test.go index e39a6a55da..1f70eaf2f8 100644 --- a/pkg/runtime/object_test.go +++ b/pkg/runtime/object_test.go @@ -8,7 +8,6 @@ import ( ) var _ = Describe("*** basic types", func() { - Context("type name", func() { It("one arg", func() { t := runtime.TypeName("test") diff --git a/pkg/runtime/scheme_test.go b/pkg/runtime/scheme_test.go index 4aa39d1b62..e275a44403 100644 --- a/pkg/runtime/scheme_test.go +++ b/pkg/runtime/scheme_test.go @@ -29,14 +29,20 @@ type T2 struct { func (t *T1) TFunc() {} func (t *T2) TFunc() {} -var T1Decoder = runtime.MustNewDirectDecoder[T](&T1{}) -var T2Decoder = runtime.MustNewDirectDecoder[T](&T2{}) +var ( + T1Decoder = runtime.MustNewDirectDecoder[T](&T1{}) + T2Decoder = runtime.MustNewDirectDecoder[T](&T2{}) +) -var t1data = []byte(`{"type":"t1","t1":"v1"}`) -var t2data = []byte(`{"type":"t2","t2":"v2"}`) +var ( + t1data = []byte(`{"type":"t1","t1":"v1"}`) + t2data = []byte(`{"type":"t2","t2":"v2"}`) +) -var t1 = &T1{runtime.ObjectTypedObject{"t1"}, "v1"} -var t2 = &T2{runtime.ObjectTypedObject{"t2"}, "v2"} +var ( + t1 = &T1{runtime.ObjectTypedObject{"t1"}, "v1"} + t2 = &T2{runtime.ObjectTypedObject{"t2"}, "v2"} +) var _ = Describe("scheme", func() { var scheme runtime.Scheme[T, TType] diff --git a/pkg/runtime/unstructured_test.go b/pkg/runtime/unstructured_test.go index 9c982ca79d..d466a54185 100644 --- a/pkg/runtime/unstructured_test.go +++ b/pkg/runtime/unstructured_test.go @@ -83,7 +83,6 @@ var _ = Describe("*** unstructured", func() { }) Context("unstructured match", func() { - It("matches complete", func() { a := runtime.UnstructuredMap{ "map": map[string]interface{}{ diff --git a/pkg/runtime/version_test.go b/pkg/runtime/version_test.go index c1693b619c..3f29a62170 100644 --- a/pkg/runtime/version_test.go +++ b/pkg/runtime/version_test.go @@ -131,15 +131,13 @@ type encoder interface { getEncoder() int } -type object struct { -} +type object struct{} func (_ *object) getEncoder() int { return 1 } var _ = Describe("versioned types", func() { - var versions runtime.Scheme[TestSpecRealm, TestType] versions = runtime.MustNewDefaultScheme[TestSpecRealm, TestType](nil, false, nil) diff --git a/pkg/semverutils/utils_test.go b/pkg/semverutils/utils_test.go index 4ae52b70c1..4370317750 100644 --- a/pkg/semverutils/utils_test.go +++ b/pkg/semverutils/utils_test.go @@ -34,5 +34,4 @@ var _ = Describe("filter", func() { MustFailWithMessage(err, "invalid semver versions: 1.x") Expect(r).To(Equal(semver.Collection{V10, V19, V20})) }) - }) diff --git a/pkg/signing/cert_test.go b/pkg/signing/cert_test.go index 433b03d5af..38110f7fba 100644 --- a/pkg/signing/cert_test.go +++ b/pkg/signing/cert_test.go @@ -17,7 +17,6 @@ import ( func CreateCertificate(subject pkix.Name, validFrom *time.Time, validity time.Duration, pub interface{}, ca *x509.Certificate, priv interface{}, isCA bool, names ...string, ) ([]byte, error) { - spec := &signutils.Specification{ RootCAs: ca, IsCA: isCA, @@ -57,7 +56,6 @@ var _ = Describe("normalization", func() { } Context("foreignly signed", func() { - certData, err := CreateCertificate(subject, nil, 10*time.Hour, pub, ca, capriv, false) Expect(err).To(Succeed()) diff --git a/pkg/signing/norm/jcs/norm.go b/pkg/signing/norm/jcs/norm.go index 21bdf01ff4..d2404a0f88 100644 --- a/pkg/signing/norm/jcs/norm.go +++ b/pkg/signing/norm/jcs/norm.go @@ -109,7 +109,7 @@ func toString(v interface{}, gap string) string { sep := "" keys := maputils.OrderedKeys(castIn) for _, n := range keys { - v := castIn[n] //nolint: govet // yes + v := castIn[n] sep = "\n" + gap s = fmt.Sprintf("%s%s %s: %s", s, sep, n, toString(v, ngap)) } diff --git a/pkg/signing/normalization_test.go b/pkg/signing/normalization_test.go index ee9723f437..10c513eb69 100644 --- a/pkg/signing/normalization_test.go +++ b/pkg/signing/normalization_test.go @@ -142,7 +142,8 @@ var _ = Describe("normalization", func() { }, Labels: nil, }, - }}, + }, + }, Access: ociartifact.New("blob"), }, }, @@ -152,7 +153,6 @@ var _ = Describe("normalization", func() { cd = compdesc.DefaultComponent(cd) It("Normalizes struct without excludes", func() { - entries, err := signing.PrepareNormalization(entry.New(), cd, signing.NoExcludes{}) Expect(err).To(Succeed()) @@ -270,7 +270,6 @@ var _ = Describe("normalization", func() { }) It("Normalizes struct without repositoryContexts", func() { - entries, err := signing.PrepareNormalization(entry.New(), cd, signing.MapExcludes{ "component": signing.MapExcludes{ "repositoryContexts": nil, @@ -383,7 +382,6 @@ var _ = Describe("normalization", func() { }) It("Normalizes struct without access", func() { - entries, err := signing.PrepareNormalization(entry.New(), cd, signing.MapExcludes{ "component": signing.MapExcludes{ "resources": signing.ArrayExcludes{ @@ -496,7 +494,6 @@ var _ = Describe("normalization", func() { }) It("Normalizes struct without resources of type localBlob", func() { - entries, err := signing.PrepareNormalization(entry.New(), cd, signing.MapExcludes{ "component": signing.MapExcludes{ "resources": signing.DynamicArrayExcludes{ @@ -746,7 +743,6 @@ resources: }) It("Normalizes struct without no-signing resource labels", func() { - entries, err := signing.PrepareNormalization(entry.New(), cd, signing.MapExcludes{ "component": signing.MapExcludes{ "resources": signing.ArrayExcludes{ @@ -850,7 +846,6 @@ resources: }) It("Normalizes cd", func() { - entries, err := signing.PrepareNormalization(entry.New(), cd, CDExcludes) Expect(err).To(Succeed()) Expect(entries.ToString("")).To(StringEqualTrimmedWithContext(` @@ -964,7 +959,6 @@ resources: }) It("Normalizes cd", func() { - entries, err := signing.PrepareNormalization(jcs.New(), cd, CDExcludes) Expect(err).To(Succeed()) Expect(entries.String()).To(StringEqualTrimmedWithContext(` diff --git a/pkg/signing/types.go b/pkg/signing/types.go index 7875530aeb..47e84ac46a 100644 --- a/pkg/signing/types.go +++ b/pkg/signing/types.go @@ -50,7 +50,7 @@ func (d *DefaultSigningContext) GetIssuer() *pkix.Name { return d.Issuer } -type Signature struct { //nolint: musttag // only for string output +type Signature struct { Value string MediaType string Algorithm string @@ -58,7 +58,7 @@ type Signature struct { //nolint: musttag // only for string output } func (s *Signature) String() string { - data, err := json.Marshal(s) + data, err := json.Marshal(s) //nolint:musttag // only for string output if err != nil { logrus.Error(err) } diff --git a/pkg/testutils/signing_test.go b/pkg/testutils/signing_test.go index d03a40bde0..abfe337f4d 100644 --- a/pkg/testutils/signing_test.go +++ b/pkg/testutils/signing_test.go @@ -9,7 +9,6 @@ import ( ) var _ = Describe("normalization", func() { - It("compares with substitution variables", func() { exp := "A ${TEST}." res := "A testcase." diff --git a/pkg/toi/install/action_test.go b/pkg/toi/install/action_test.go index cf52b0a280..3c896af82b 100644 --- a/pkg/toi/install/action_test.go +++ b/pkg/toi/install/action_test.go @@ -22,8 +22,10 @@ import ( "github.com/open-component-model/ocm/pkg/toi/install" ) -const COMPONENT = "acme.org/test" -const VERSION = "0.1.0" +const ( + COMPONENT = "acme.org/test" + VERSION = "0.1.0" +) type Driver struct { install.Driver @@ -289,5 +291,4 @@ creds: [] testparam: value `)) }) - }) diff --git a/pkg/utils/panics/panics_test.go b/pkg/utils/panics/panics_test.go index 5df55a1609..d68dbb5499 100644 --- a/pkg/utils/panics/panics_test.go +++ b/pkg/utils/panics/panics_test.go @@ -55,5 +55,4 @@ panic.* Expect(err).To(HaveOccurred()) Expect(err.Error()).To(Equal("exception")) }) - }) diff --git a/pkg/utils/pkgutils/package_test.go b/pkg/utils/pkgutils/package_test.go index d8f95ad7e2..d3568920f9 100644 --- a/pkg/utils/pkgutils/package_test.go +++ b/pkg/utils/pkgutils/package_test.go @@ -1,13 +1,16 @@ package pkgutils_test import ( - "github.com/mandelsoft/goutils/generics" + "reflect" + . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + + "github.com/mandelsoft/goutils/generics" + me "github.com/open-component-model/ocm/pkg/utils/pkgutils" "github.com/open-component-model/ocm/pkg/utils/pkgutils/testpackage" - "reflect" ) type typ struct{} diff --git a/pkg/utils/tarutils/pack_test.go b/pkg/utils/tarutils/pack_test.go index fa4014e590..6acc25c544 100644 --- a/pkg/utils/tarutils/pack_test.go +++ b/pkg/utils/tarutils/pack_test.go @@ -55,5 +55,4 @@ var _ = Describe("tar utils mapping", func() { Expect(err.Error()).To(ContainSubstring("no such file or directory")) } }) - }) diff --git a/pkg/utils/template/template_test.go b/pkg/utils/template/template_test.go index f25695ebd2..5deca5edd6 100644 --- a/pkg/utils/template/template_test.go +++ b/pkg/utils/template/template_test.go @@ -19,9 +19,7 @@ func TestConfig(t *testing.T) { } var _ = Describe("Template", func() { - Context("Parse Arguments", func() { - It("should parse one argument after a '--'", func() { opts := template.Options{} Expect(opts.Complete(nil)).To(Succeed()) diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go index 8618c8e871..262fcacd6f 100644 --- a/pkg/utils/utils_test.go +++ b/pkg/utils/utils_test.go @@ -12,9 +12,7 @@ import ( ) var _ = Describe("utils", func() { - Context("WriteFileToTARArchive", func() { - It("should write file", func() { fname := "testfile" content := []byte("testcontent") @@ -37,7 +35,6 @@ var _ = Describe("utils", func() { _, err = tr.Next() Expect(err).To(Equal(io.EOF)) - }) It("should write empty file", func() { @@ -78,7 +75,5 @@ var _ = Describe("utils", func() { contentReader := bytes.NewReader([]byte{}) Expect(utils.WriteFileToTARArchive("testfile", contentReader, nil)).To(MatchError("archiveWriter must not be nil")) }) - }) - })