From 600f585d767aeaef3f5a6cfdd25b1db337d29b3e Mon Sep 17 00:00:00 2001 From: Uwe Krueger Date: Wed, 24 Apr 2024 09:50:12 +0200 Subject: [PATCH] eliminate lib to cli dependencies (#741) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description There are dependencies from the library (package pkg) to the cli (cmds). This is because of - using command executions in plugin tests - using some parsing provided by cli in some app support - using cli based test environment in lib tests The cli based test environment can be replaced by the lib test environment, it was just accidently used. The parsing support has been moved to a cli support package in the lib. The plugin tests based on command executions have been moved to a plugin test package in the top-level cli package. Additionally, the lib now tests the pure lib version of the plugin usage without command executions. ## What type of PR is this? (check all applicable) - [ ] 🍕 Feature - [x] 🎇 Restructuring - [ ] 🐛 Bug Fix - [ ] 📝 Documentation Update - [ ] 🎨 Style - [ ] 🧑‍💻 Code Refactor - [ ] 🔥 Performance Improvements - [x] ✅ Test - [x] 🤖 Build - [ ] 🔁 CI - [ ] 📦 Chore (Release) - [ ] ⏩ Revert ## Related Tickets & Documents - Related Issue # (issue) - Closes # (issue) - Fixes # (issue) > Remove if not applicable ## Screenshots ## Added tests? - [ ] 👍 yes - [ ] 🙅 no, because they aren't needed - [ ] 🙋 no, because I need help - [ ] Separate ticket for tests # (issue/pr) Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration ## Added to documentation? - [ ] 📜 README.md - [ ] 🙅 no documentation needed ## Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --- .github/pull_request_template.md | 1 + cmds/ocm/app/app.go | 2 +- .../ocmcmds/componentarchive/create/cmd.go | 6 +- .../plugins/tests/accessmethods/cmd_test.go | 79 ++++++++++++++++++ .../plugins/tests/accessmethods/suite_test.go | 23 +++++ .../plugins/tests/accessmethods/testdata/test | 83 +++++++++++++++++++ .../plugins/tests/routingslips/cmd_test.go | 69 +++++++++++++++ .../plugins/tests/routingslips/suite_test.go | 17 ++++ .../plugins/tests/routingslips/testdata/test | 78 +++++++++++++++++ go.mod | 47 ++++++----- go.sum | 2 + .../common => pkg/clisupport}/labels.go | 4 +- .../ocm/accessmethods/plugin/cmd_test.go | 79 +++++++++--------- .../genericaccess/resource_test.go | 10 +-- .../routingslip/types/plugin/cmd_test.go | 62 +++++++------- .../routingslip/types/plugin/entry_test.go | 6 +- .../ocm/repositories/virtual/repo_test.go | 9 +- pkg/contexts/ocm/utils/check/check_test.go | 6 +- pkg/toi/support/app.go | 4 +- 19 files changed, 474 insertions(+), 113 deletions(-) create mode 100644 cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/cmd_test.go create mode 100644 cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/suite_test.go create mode 100755 cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/testdata/test create mode 100644 cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/cmd_test.go create mode 100644 cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/suite_test.go create mode 100755 cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/testdata/test rename {cmds/ocm/commands/ocmcmds/common => pkg/clisupport}/labels.go (96%) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b9d61c3e89..d370119fee 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -11,6 +11,7 @@ Please include a summary of the changes and the related issue. Please also inclu ## What type of PR is this? (check all applicable) - [ ] 🍕 Feature +- [ ] 🎇 Restructuring - [ ] 🐛 Bug Fix - [ ] 📝 Documentation Update - [ ] 🎨 Style diff --git a/cmds/ocm/app/app.go b/cmds/ocm/app/app.go index 3f479b79c9..c598c9aba5 100644 --- a/cmds/ocm/app/app.go +++ b/cmds/ocm/app/app.go @@ -11,6 +11,7 @@ import ( "strings" "unicode" + common2 "github.com/open-component-model/ocm/pkg/clisupport" _ "github.com/open-component-model/ocm/pkg/contexts/clictx/config" _ "github.com/open-component-model/ocm/pkg/contexts/ocm/attrs" @@ -24,7 +25,6 @@ import ( creds "github.com/open-component-model/ocm/cmds/ocm/commands/misccmds/credentials" "github.com/open-component-model/ocm/cmds/ocm/commands/ocicmds" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds" - common2 "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/componentarchive" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/components" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/plugins" diff --git a/cmds/ocm/commands/ocmcmds/componentarchive/create/cmd.go b/cmds/ocm/commands/ocmcmds/componentarchive/create/cmd.go index 7d93479bef..6954114acb 100644 --- a/cmds/ocm/commands/ocmcmds/componentarchive/create/cmd.go +++ b/cmds/ocm/commands/ocmcmds/componentarchive/create/cmd.go @@ -9,11 +9,11 @@ import ( "strings" "github.com/mandelsoft/vfs/pkg/vfs" + "github.com/open-component-model/ocm/pkg/clisupport" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/open-component-model/ocm/cmds/ocm/commands/common/options/formatoption" - "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/options/fileoption" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common/options/schemaoption" "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/names" @@ -91,7 +91,7 @@ func (o *Command) Complete(args []string) error { o.Version = args[1] for _, a := range args[2:] { - o.Labels, err = common.AddParsedLabel(o.FileSystem(), o.Labels, a) + o.Labels, err = clisupport.AddParsedLabel(o.FileSystem(), o.Labels, a) if err != nil { return err } @@ -104,7 +104,7 @@ func (o *Command) Complete(args []string) error { o.Provider = a continue } - o.ProviderLabels, err = common.AddParsedLabel(o.FileSystem(), o.ProviderLabels, a) + o.ProviderLabels, err = clisupport.AddParsedLabel(o.FileSystem(), o.ProviderLabels, a) if err != nil { return err } diff --git a/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/cmd_test.go b/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/cmd_test.go new file mode 100644 index 0000000000..9557131805 --- /dev/null +++ b/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/cmd_test.go @@ -0,0 +1,79 @@ +// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors. +// +// SPDX-License-Identifier: Apache-2.0 + +package accessmethods_test + +import ( + "encoding/json" + + . "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/testutils" + + "github.com/open-component-model/ocm/pkg/contexts/ocm" + "github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/plugincacheattr" + "github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/plugindirattr" + "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/cpi" + "github.com/open-component-model/ocm/pkg/contexts/ocm/plugin/plugins" + "github.com/open-component-model/ocm/pkg/contexts/ocm/registration" + "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/comparch" +) + +const CA = "/tmp/ca" +const VERSION = "v1" + +var _ = Describe("Add with new access method", func() { + var env *TestEnv + var ctx ocm.Context + var registry plugins.Set + + BeforeEach(func() { + env = NewTestEnv(TestData()) + ctx = env.OCMContext() + + plugindirattr.Set(ctx, "testdata") + registry = plugincacheattr.Get(ctx) + Expect(registration.RegisterExtensions(ctx)).To(Succeed()) + p := registry.Get("test") + Expect(p).NotTo(BeNil()) + + Expect(env.Execute("create", "ca", "-ft", "directory", "test.de/x", VERSION, "--provider", "mandelsoft", "--file", CA)).To(Succeed()) + }) + + AfterEach(func() { + env.Cleanup() + }) + + It("adds external resource by options", func() { + Expect(env.Execute("add", "resources", CA, + "--type", "testContent", + "--name", "text", + "--version", "v0.1.0", + "--accessType", "test", + "--accessPath", "textfile", + "--mediaType", "text/plain")).To(Succeed()) + data := Must(env.ReadFile(env.Join(CA, comparch.ComponentDescriptorFileName))) + cd := Must(compdesc.Decode(data)) + Expect(len(cd.Resources)).To(Equal(1)) + + r := Must(cd.GetResourceByIdentity(metav1.NewIdentity("text"))) + Expect(r.Type).To(Equal("testContent")) + Expect(r.Version).To(Equal("v0.1.0")) + Expect(r.Relation).To(Equal(metav1.ResourceRelation("external"))) + + Expect(r.Access.GetType()).To(Equal("test")) + acc := Must(env.OCMContext().AccessSpecForSpec(r.Access)) + var myacc AccessSpec + + MustBeSuccessful(json.Unmarshal(Must(json.Marshal(acc)), &myacc)) + Expect(myacc).To(Equal(AccessSpec{Type: "test", Path: "textfile", MediaType: "text/plain"})) + + m := Must(acc.AccessMethod(&cpi.DummyComponentVersionAccess{env.OCMContext()})) + data = Must(m.Get()) + Expect(string(data)).To(Equal("test content\n{\"mediaType\":\"text/plain\",\"path\":\"textfile\",\"type\":\"test\"}\n")) + }) +}) diff --git a/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/suite_test.go b/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/suite_test.go new file mode 100644 index 0000000000..29a58e6af1 --- /dev/null +++ b/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/suite_test.go @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Open Component Model contributors. +// +// SPDX-License-Identifier: Apache-2.0 + +package accessmethods_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +type AccessSpec struct { + Type string `json:"type"` + Path string `json:"path"` + MediaType string `json:"mediaType"` +} + +func TestConfig(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Access Methods Plugin Test Suite") +} diff --git a/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/testdata/test b/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/testdata/test new file mode 100755 index 0000000000..566e080ff1 --- /dev/null +++ b/cmds/ocm/commands/ocmcmds/plugins/tests/accessmethods/testdata/test @@ -0,0 +1,83 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors. +# +# SPDX-License-Identifier: Apache-2.0 + +NAME="$(basename "$0")" + +Error() { + echo '{ "error": "'$1'" }' >&2 + exit 1 +} + +extract() { + v="$(echo "$2" | sed 's/.*"'"$1"'": *"\([^"]*\)".*/\1/')" + if [ "$v" != "$2" ]; then + echo "$v" + fi +} + +setfield() { + local v + s="$(echo "$2" | sed 's/\//\\\//g')" + v="$(echo "$BASE" | sed 's/"'"$1"'": *"[^"]*"/"'"$1"'":"'"$s"'"/')" + if [ "$v" == "$BASE" ]; then + v="$(echo "$BASE" | sed 's/^{"/{"'"$1"'":"'"$s"'","/')" + fi + if [ "$v" == "$BASE" ]; then + v="$(echo "$BASE" | sed 's/^{/{"'"$1"'":"'"$s"'"/')" + fi + BASE="$v" +} + +setopt() { + local v + v="$(extract "$1" "$OPTS")" + if [ -n "$v" ]; then + setfield "$2" "$v" + fi +} + +Info() { + PATHOPT='{"name":"accessPath","type":"string","description":"file path"}' + MEDIAOPT='{"name":"mediaType"}' + OPTS='['$PATHOPT','$MEDIAOPT']' + echo '{"version":"v1","pluginName":"'$NAME'","pluginVersion":"v1","shortDescription":"a test plugin","description":"a test plugin with access method test","accessMethods":[{"name":"test","shortDescription":"test access","description":"","options":'$OPTS'},{"name":"test","version":"v1","shortDescription":"test access","description":""}]} +' +} + +Get() { + echo "test content" + for arg; do + echo "$arg" + done +} + +Validate() { + echo '{"short":"a test","mediaType":"plain/text","description":"","hint":"testfile","consumerId":{"hostname":"localhost","type":"test"}}' +} + +Compose() { + BASE="$3" + OPTS="$2" + + setopt accessPath path + setopt mediaType mediaType + echo "$BASE" +} + +AccessMethod() { + case "$1" in + get) Get "${@:2}";; + validate) Validate "${@:2}";; + compose) Compose "${@:2}";; + *) Error "invalid accessmethod command $1";; + esac +} + +case "$1" in + info) Info;; + accessmethod) AccessMethod "${@:2}";; + *) Error "invalid command $1";; +esac diff --git a/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/cmd_test.go b/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/cmd_test.go new file mode 100644 index 0000000000..12812e0d8d --- /dev/null +++ b/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/cmd_test.go @@ -0,0 +1,69 @@ +// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors. +// +// SPDX-License-Identifier: Apache-2.0 + +package routingslips_test + +import ( + "bytes" + + . "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/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/ocm/attrs/plugincacheattr" + "github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/plugindirattr" + "github.com/open-component-model/ocm/pkg/contexts/ocm/labels/routingslip" + "github.com/open-component-model/ocm/pkg/contexts/ocm/registration" + "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" + +var _ = Describe("Test Environment", func() { + var env *TestEnv + + BeforeEach(func() { + env = NewTestEnv() + env.OCMCommonTransport(ARCH, accessio.FormatDirectory, func() { + env.Component(COMP, func() { + env.Version(VERSION, func() { + env.Provider(PROVIDER) + }) + }) + }) + env.RSAKeyPair(PROVIDER) + + ctx := env.OCMContext() + plugindirattr.Set(ctx, "testdata") + registry := plugincacheattr.Get(ctx) + Expect(registration.RegisterExtensions(ctx)).To(Succeed()) + p := registry.Get("test") + Expect(p).NotTo(BeNil()) + }) + + AfterEach(func() { + env.Cleanup() + }) + + It("adds entry by plugin option", func() { + buf := bytes.NewBuffer(nil) + Expect(env.CatchOutput(buf).Execute("add", "routingslip", ARCH, PROVIDER, "test", "--accessPath", "some path", "--mediaType", "media type")).To(Succeed()) + Expect(buf.String()).To(StringEqualTrimmedWithContext( + ` +`)) + repo := Must(ctf.Open(env, accessobj.ACC_READONLY, ARCH, 0, env)) + defer Close(repo, "repo") + cv := Must(repo.LookupComponentVersion(COMP, VERSION)) + defer Close(cv, "cv") + slip := Must(routingslip.GetSlip(cv, PROVIDER)) + Expect(slip.Len()).To(Equal(1)) + Expect(Must(slip.Get(0).Payload.Evaluate(env.OCMContext())).Describe(env.OCMContext())).To(Equal("a test")) + }) +}) diff --git a/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/suite_test.go b/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/suite_test.go new file mode 100644 index 0000000000..025f19b67a --- /dev/null +++ b/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/suite_test.go @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Open Component Model contributors. +// +// SPDX-License-Identifier: Apache-2.0 + +package routingslips_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestConfig(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Routing Slips Plugin Test Suite") +} diff --git a/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/testdata/test b/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/testdata/test new file mode 100755 index 0000000000..3162fb01f3 --- /dev/null +++ b/cmds/ocm/commands/ocmcmds/plugins/tests/routingslips/testdata/test @@ -0,0 +1,78 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors. +# +# SPDX-License-Identifier: Apache-2.0 + +NAME="$(basename "$0")" + +set -e + +Error() { + echo '{ "error": "'$1'" }' >&2 + exit 1 +} + +extract() { + v="$(echo "$2" | sed 's/.*"'"$1"'": *"\([^"]*\)".*/\1/')" + if [ "$v" != "$2" ]; then + echo "$v" + fi +} + +setfield() { + local v + v="$(echo "$BASE" | sed 's/"'"$1"'": *"[^"]*"/"'""$1""'":"'"${2//\//\\\/}"'"/')" + if [ "$v" == "$BASE" ]; then + v="$(echo "$BASE" | sed 's/^{"/{"'"$1"'":"'"${2//\//\\\/}"'","/')" + fi + if [ "$v" == "$BASE" ]; then + v="$(echo "$BASE" | sed 's/^{/{"'"$1"'":"'"${2//\//\\\/}"'"/')" + fi + BASE="$v" +} + +setopt() { + local v + v="$(extract "$1" "$OPTS")" + if [ -n "$v" ]; then + setfield "$2" "$v" + fi +} + +Info() { + PATHOPT='{"name":"accessPath","type":"string","description":"file path"}' + MEDIAOPT='{"name":"mediaType"}' + OPTS='['$PATHOPT','$MEDIAOPT']' + echo '{"version":"v1","pluginName":"'$NAME'","pluginVersion":"v1","shortDescription":"a test plugin","description":"a test plugin with valueset test","valuesets":[{"name":"test","purposes":["routingslip"],"shortDescription":"test set","description":"","options":'$OPTS'},{"name":"test","purposes":["routingslip"],"version":"v1","shortDescription":"test set","description":""}]} +' +} + +Compose() { + BASE="$4" + OPTS="$3" + + setopt accessPath path + setopt mediaType mediaType + echo "$BASE" +} + +Validate() { + echo '{"description":"a test"}' +} + + +ValueSet() { + case "$1" in + get) Get "${@:2}";; + compose) Compose "${@:2}";; + validate) Validate "${@:2}";; + *) Error "invalid valueset command $1";; + esac +} + +case "$1" in + info) Info;; + valueset) ValueSet "${@:2}";; + *) Error "invalid command $1";; +esac diff --git a/go.mod b/go.mod index a51d6b9e32..3bc988c938 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,9 @@ go 1.22 replace github.com/spf13/cobra => github.com/open-component-model/cobra v0.0.0-20230329075350-b1fd876abfb9 require ( + github.com/DataDog/gostackparse v0.7.0 + github.com/InfiniteLoopSpace/go_S-MIME v0.0.0-20181221134359-3f58f9a4b2b6 + github.com/Masterminds/semver/v3 v3.2.1 github.com/aws/aws-sdk-go-v2 v1.26.1 github.com/aws/aws-sdk-go-v2/config v1.27.11 github.com/aws/aws-sdk-go-v2/credentials v1.17.11 @@ -15,7 +18,6 @@ require ( github.com/containerd/log v0.1.0 github.com/containers/image/v5 v5.30.0 github.com/cyberphone/json-canonicalization v0.0.0-20231217050601-ba74d44ecf5f - github.com/DataDog/gostackparse v0.7.0 github.com/distribution/reference v0.6.0 github.com/docker/cli v25.0.5+incompatible github.com/docker/docker v25.0.5+incompatible @@ -34,15 +36,14 @@ require ( github.com/google/go-github/v45 v45.2.0 github.com/hashicorp/vault-client-go v0.4.3 github.com/imdario/mergo v0.3.16 - github.com/InfiniteLoopSpace/go_S-MIME v0.0.0-20181221134359-3f58f9a4b2b6 github.com/klauspost/compress v1.17.7 github.com/klauspost/pgzip v1.2.6 github.com/mandelsoft/filepath v0.0.0-20240223090642-3e2777258aa3 + github.com/mandelsoft/goutils v0.0.0-20240422120338-5e35748a0391 github.com/mandelsoft/logging v0.0.0-20240201091719-67180059d6bf github.com/mandelsoft/spiff v1.7.0-beta-5 github.com/mandelsoft/vfs v0.4.3 github.com/marstr/guid v1.1.0 - github.com/Masterminds/semver/v3 v3.2.1 github.com/mitchellh/copystructure v1.2.0 github.com/mittwald/go-helm-client v0.12.9 github.com/modern-go/reflect2 v1.0.2 @@ -83,6 +84,26 @@ require ( cloud.google.com/go/compute/metadata v0.2.3 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect + github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/alibabacloudsdkgo/helper v0.2.0 // indirect + github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect + github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect + github.com/Azure/go-autorest v14.2.0+incompatible // indirect + github.com/Azure/go-autorest/autorest v0.11.29 // indirect + github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect + github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 // indirect + github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 // indirect + github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect + github.com/Azure/go-autorest/logger v0.2.1 // indirect + github.com/Azure/go-autorest/tracing v0.6.0 // indirect + github.com/BurntSushi/toml v1.3.2 // indirect + github.com/MakeNowJust/heredoc v1.0.0 // indirect + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/sprig/v3 v3.2.3 // indirect + github.com/Masterminds/squirrel v1.5.4 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/hcsshim v0.12.0-rc.3 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect + github.com/ThalesIgnite/crypto11 v1.2.5 // indirect github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 // indirect github.com/alibabacloud-go/cr-20160607 v1.0.1 // indirect github.com/alibabacloud-go/cr-20181201 v1.0.10 // indirect @@ -94,7 +115,6 @@ require ( github.com/alibabacloud-go/tea-utils v1.4.5 // indirect github.com/alibabacloud-go/tea-xml v1.1.3 // indirect github.com/aliyun/credentials-go v1.3.1 // indirect - github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/alibabacloudsdkgo/helper v0.2.0 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 // indirect @@ -112,23 +132,12 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 // indirect github.com/aws/smithy-go v1.20.2 // indirect github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20231024185945-8841054dbdb8 // indirect - github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect - github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect - github.com/Azure/go-autorest v14.2.0+incompatible // indirect - github.com/Azure/go-autorest/autorest v0.11.29 // indirect - github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect - github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 // indirect - github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 // indirect - github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect - github.com/Azure/go-autorest/logger v0.2.1 // indirect - github.com/Azure/go-autorest/tracing v0.6.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver v3.5.1+incompatible // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/buildkite/agent/v3 v3.62.0 // indirect github.com/buildkite/go-pipeline v0.3.2 // indirect github.com/buildkite/interpolate v0.0.0-20200526001904-07f35b4ae251 // indirect - github.com/BurntSushi/toml v1.3.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect github.com/chrismellard/docker-credential-acr-env v0.0.0-20230304212654-82a0ddb27589 // indirect @@ -221,15 +230,9 @@ require ( github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/MakeNowJust/heredoc v1.0.0 // indirect - github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/sprig/v3 v3.2.3 // indirect - github.com/Masterminds/squirrel v1.5.4 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/Microsoft/hcsshim v0.12.0-rc.3 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect @@ -258,7 +261,6 @@ require ( github.com/prometheus/client_model v0.6.0 // indirect github.com/prometheus/common v0.51.1 // indirect github.com/prometheus/procfs v0.12.0 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/rubenv/sql-migrate v1.6.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect @@ -281,7 +283,6 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/thales-e-security/pool v0.0.2 // indirect - github.com/ThalesIgnite/crypto11 v1.2.5 // indirect github.com/theupdateframework/go-tuf v0.7.0 // indirect github.com/theupdateframework/notary v0.7.0 // indirect github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect diff --git a/go.sum b/go.sum index 17911edf25..4eca05d991 100644 --- a/go.sum +++ b/go.sum @@ -667,6 +667,8 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mandelsoft/filepath v0.0.0-20240223090642-3e2777258aa3 h1:oo9nIgnyiBgYPbcZslRT4y29siuL5EoNJ/t1tr0xEVQ= github.com/mandelsoft/filepath v0.0.0-20240223090642-3e2777258aa3/go.mod h1:LxhqC7khDoRENwooP6f/vWvia9ivj6TqLYrR39zqkN0= +github.com/mandelsoft/goutils v0.0.0-20240422120338-5e35748a0391 h1:6etBMMPXMD4ti9OJbyNyH45qm6NvnzIOoGzZnkIRiD4= +github.com/mandelsoft/goutils v0.0.0-20240422120338-5e35748a0391/go.mod h1:EbNqk9JceSMq7MJuALB/vlOpoD4MAGE0TenM9TR+C0o= github.com/mandelsoft/logging v0.0.0-20240201091719-67180059d6bf h1:WEmgzeArDbp6Aw34jmziMIE5ygo2zpl/atXRq3D7lSw= github.com/mandelsoft/logging v0.0.0-20240201091719-67180059d6bf/go.mod h1:uO460C1lIB3IOOgrbXhAlz3AKsOv4T2K6ALBn3PwuSg= github.com/mandelsoft/spiff v1.7.0-beta-5 h1:3kC10nTviDQhL8diSxp7i4IC2iSiDg6KPbH1CAq7Lfw= diff --git a/cmds/ocm/commands/ocmcmds/common/labels.go b/pkg/clisupport/labels.go similarity index 96% rename from cmds/ocm/commands/ocmcmds/common/labels.go rename to pkg/clisupport/labels.go index 1983c3e450..57bd059200 100644 --- a/cmds/ocm/commands/ocmcmds/common/labels.go +++ b/pkg/clisupport/labels.go @@ -1,8 +1,8 @@ -// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors. +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Open Component Model contributors. // // SPDX-License-Identifier: Apache-2.0 -package common +package clisupport import ( "encoding/json" diff --git a/pkg/contexts/ocm/accessmethods/plugin/cmd_test.go b/pkg/contexts/ocm/accessmethods/plugin/cmd_test.go index b6aa15176e..231ece0f07 100644 --- a/pkg/contexts/ocm/accessmethods/plugin/cmd_test.go +++ b/pkg/contexts/ocm/accessmethods/plugin/cmd_test.go @@ -5,34 +5,34 @@ package plugin_test import ( - "encoding/json" - . "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/env" . "github.com/open-component-model/ocm/pkg/testutils" + "github.com/mandelsoft/goutils/sliceutils" + "github.com/mandelsoft/goutils/transformer" + "github.com/spf13/pflag" + + "github.com/open-component-model/ocm/pkg/cobrautils/flagsets" "github.com/open-component-model/ocm/pkg/contexts/ocm" + "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/options" "github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/plugincacheattr" "github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/plugindirattr" - "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/cpi" "github.com/open-component-model/ocm/pkg/contexts/ocm/plugin/plugins" "github.com/open-component-model/ocm/pkg/contexts/ocm/registration" - "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/comparch" ) const CA = "/tmp/ca" const VERSION = "v1" var _ = Describe("Add with new access method", func() { - var env *TestEnv + var env *Environment var ctx ocm.Context var registry plugins.Set BeforeEach(func() { - env = NewTestEnv(TestData()) + env = NewEnvironment(TestData()) ctx = env.OCMContext() plugindirattr.Set(ctx, "testdata") @@ -40,40 +40,43 @@ var _ = Describe("Add with new access method", func() { Expect(registration.RegisterExtensions(ctx)).To(Succeed()) p := registry.Get("test") Expect(p).NotTo(BeNil()) - - Expect(env.Execute("create", "ca", "-ft", "directory", "test.de/x", VERSION, "--provider", "mandelsoft", "--file", CA)).To(Succeed()) }) AfterEach(func() { env.Cleanup() }) - It("adds external resource by options", func() { - Expect(env.Execute("add", "resources", CA, - "--type", "testContent", - "--name", "text", - "--version", "v0.1.0", - "--accessType", "test", - "--accessPath", "textfile", - "--mediaType", "text/plain")).To(Succeed()) - data := Must(env.ReadFile(env.Join(CA, comparch.ComponentDescriptorFileName))) - cd := Must(compdesc.Decode(data)) - Expect(len(cd.Resources)).To(Equal(1)) - - r := Must(cd.GetResourceByIdentity(metav1.NewIdentity("text"))) - Expect(r.Type).To(Equal("testContent")) - Expect(r.Version).To(Equal("v0.1.0")) - Expect(r.Relation).To(Equal(metav1.ResourceRelation("external"))) - - Expect(r.Access.GetType()).To(Equal("test")) - acc := Must(env.OCMContext().AccessSpecForSpec(r.Access)) - var myacc AccessSpec - - MustBeSuccessful(json.Unmarshal(Must(json.Marshal(acc)), &myacc)) - Expect(myacc).To(Equal(AccessSpec{Type: "test", Path: "textfile", MediaType: "text/plain"})) - - m := Must(acc.AccessMethod(&cpi.DummyComponentVersionAccess{env.OCMContext()})) - data = Must(m.Get()) - Expect(string(data)).To(Equal("test content\n{\"mediaType\":\"text/plain\",\"path\":\"textfile\",\"type\":\"test\"}\n")) + It("handles resource options", func() { + at := ctx.AccessMethods().GetType("test") + Expect(at).NotTo(BeNil()) + + h := at.ConfigOptionTypeSetHandler() + Expect(h).NotTo(BeNil()) + Expect(h.GetName()).To(Equal("test")) + + ot := h.OptionTypes() + Expect(len(ot)).To(Equal(2)) + + opts := h.CreateOptions() + Expect(sliceutils.Transform(opts.Options(), transformer.GetName[flagsets.Option, string])).To(ConsistOf( + "mediaType", "accessPath")) + + fs := &pflag.FlagSet{} + fs.SortFlags = true + opts.AddFlags(fs) + + Expect("\n" + fs.FlagUsages()).To(Equal(` + --accessPath string file path + --mediaType string media type for artifact blob representation +`)) + + MustBeSuccessful(fs.Parse([]string{"--accessPath", "filepath", "--" + options.MediatypeOption.GetName(), "yaml"})) + + cfg := flagsets.Config{} + MustBeSuccessful(h.ApplyConfig(opts, cfg)) + Expect(cfg).To(YAMLEqual(` +mediaType: yaml +path: filepath +`)) }) }) diff --git a/pkg/contexts/ocm/elements/artifactaccess/genericaccess/resource_test.go b/pkg/contexts/ocm/elements/artifactaccess/genericaccess/resource_test.go index 34b7f4bb46..ad960184f5 100644 --- a/pkg/contexts/ocm/elements/artifactaccess/genericaccess/resource_test.go +++ b/pkg/contexts/ocm/elements/artifactaccess/genericaccess/resource_test.go @@ -7,8 +7,8 @@ package genericaccess_test 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/oci/testhelper" + . "github.com/open-component-model/ocm/pkg/env/builder" . "github.com/open-component-model/ocm/pkg/testutils" "github.com/open-component-model/ocm/pkg/common/accessio" @@ -25,15 +25,15 @@ const OCIPATH = "/tmp/oci" const OCIHOST = "alias" var _ = Describe("dir tree resource access", func() { - var env *TestEnv + var env *Builder BeforeEach(func() { - env = NewTestEnv() + env = NewBuilder() - FakeOCIRepo(env.Builder, OCIPATH, OCIHOST) + FakeOCIRepo(env, OCIPATH, OCIHOST) env.OCICommonTransport(OCIPATH, accessio.FormatDirectory, func() { - OCIManifest1(env.Builder) + OCIManifest1(env) }) }) 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 334bf1109a..f2a68fd6d6 100644 --- a/pkg/contexts/ocm/labels/routingslip/types/plugin/cmd_test.go +++ b/pkg/contexts/ocm/labels/routingslip/types/plugin/cmd_test.go @@ -5,20 +5,20 @@ package plugin_test import ( - "bytes" - + "github.com/mandelsoft/goutils/sliceutils" + "github.com/mandelsoft/goutils/transformer" . "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/registration" + . "github.com/open-component-model/ocm/pkg/env" . "github.com/open-component-model/ocm/pkg/testutils" + "github.com/spf13/pflag" - "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/cobrautils/flagsets" + "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/options" "github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/plugincacheattr" "github.com/open-component-model/ocm/pkg/contexts/ocm/attrs/plugindirattr" "github.com/open-component-model/ocm/pkg/contexts/ocm/labels/routingslip" - "github.com/open-component-model/ocm/pkg/contexts/ocm/registration" - "github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ctf" ) const ARCH = "/tmp/ca" @@ -27,18 +27,10 @@ const COMP = "test.de/x" const PROVIDER = "acme.org" var _ = Describe("Test Environment", func() { - var env *TestEnv + var env *Environment BeforeEach(func() { - env = NewTestEnv() - env.OCMCommonTransport(ARCH, accessio.FormatDirectory, func() { - env.Component(COMP, func() { - env.Version(VERSION, func() { - env.Provider(PROVIDER) - }) - }) - }) - env.RSAKeyPair(PROVIDER) + env = NewEnvironment(TestData()) ctx := env.OCMContext() plugindirattr.Set(ctx, "testdata") @@ -52,18 +44,30 @@ var _ = Describe("Test Environment", func() { env.Cleanup() }) - It("adds entry by plugin option", func() { - buf := bytes.NewBuffer(nil) - Expect(env.CatchOutput(buf).Execute("add", "routingslip", ARCH, PROVIDER, "test", "--accessPath", "some path", "--mediaType", "media type")).To(Succeed()) - Expect(buf.String()).To(StringEqualTrimmedWithContext( - ` + It("handles plugin based entry type", func() { + prov := routingslip.For(env.OCMContext()).CreateConfigTypeSetConfigProvider().(flagsets.ExplicitlyTypedConfigTypeOptionSetConfigProvider) + configopts := prov.CreateOptions() + Expect(sliceutils.Transform(configopts.Options(), transformer.GetName[flagsets.Option, string])).To(ConsistOf( + "entry", "comment", // default settings + "mediaType", "accessPath", // by plugin + )) + + fs := &pflag.FlagSet{} + fs.SortFlags = true + configopts.AddFlags(fs) + Expect("\n" + fs.FlagUsages()).To(Equal(` + --accessPath string file path + --comment string comment field value + --entry YAML routing slip entry specification (YAML) + --mediaType string media type for artifact blob representation +`)) + MustBeSuccessful(fs.Parse([]string{"--accessPath", "some path", "--" + options.MediatypeOption.GetName(), "media type"})) + prov.SetTypeName("test") + data := Must(prov.GetConfigFor(configopts)) + Expect(data).To(YAMLEqual(` +type: test +mediaType: media type +path: some path `)) - repo := Must(ctf.Open(env, accessobj.ACC_READONLY, ARCH, 0, env)) - defer Close(repo, "repo") - cv := Must(repo.LookupComponentVersion(COMP, VERSION)) - defer Close(cv, "cv") - slip := Must(routingslip.GetSlip(cv, PROVIDER)) - Expect(slip.Len()).To(Equal(1)) - Expect(Must(slip.Get(0).Payload.Evaluate(env.OCMContext())).Describe(env.OCMContext())).To(Equal("a test")) }) }) 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 b6e998361e..3b2b183ea0 100644 --- a/pkg/contexts/ocm/labels/routingslip/types/plugin/entry_test.go +++ b/pkg/contexts/ocm/labels/routingslip/types/plugin/entry_test.go @@ -20,16 +20,16 @@ import ( "github.com/open-component-model/ocm/pkg/contexts/ocm/labels/routingslip/spi" "github.com/open-component-model/ocm/pkg/contexts/ocm/plugin/plugins" "github.com/open-component-model/ocm/pkg/contexts/ocm/registration" - env2 "github.com/open-component-model/ocm/pkg/env" + . "github.com/open-component-model/ocm/pkg/env" ) var _ = Describe("setup plugin cache", func() { var ctx ocm.Context var registry plugins.Set - var env *env2.Environment + var env *Environment BeforeEach(func() { - env = env2.NewEnvironment() + env = NewEnvironment() ctx = env.OCMContext() plugindirattr.Set(ctx, "testdata") registry = plugincacheattr.Get(ctx) diff --git a/pkg/contexts/ocm/repositories/virtual/repo_test.go b/pkg/contexts/ocm/repositories/virtual/repo_test.go index c069be8437..e8dd0ce36f 100644 --- a/pkg/contexts/ocm/repositories/virtual/repo_test.go +++ b/pkg/contexts/ocm/repositories/virtual/repo_test.go @@ -7,7 +7,8 @@ package virtual_test 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/env" + . "github.com/open-component-model/ocm/pkg/env/builder" . "github.com/open-component-model/ocm/pkg/testutils" "github.com/mandelsoft/vfs/pkg/layerfs" @@ -30,7 +31,7 @@ import ( ) var _ = Describe("virtual repo", func() { - var env *TestEnv + var env *Builder var repo ocm.Repository var access *example.Access @@ -43,7 +44,7 @@ var _ = Describe("virtual repo", func() { Context("readonly", func() { BeforeEach(func() { - env = NewTestEnv(TestData()) + env = NewBuilder(TestData()) access = Must(example.NewAccess(Must(projectionfs.New(env, "testdata")), true)) repo = virtual.NewRepository(env.OCMContext(), access) }) @@ -74,7 +75,7 @@ var _ = Describe("virtual repo", func() { Context("modifiable", func() { BeforeEach(func() { - env = NewTestEnv(TestData()) + env = NewBuilder(TestData()) fs := Must(projectionfs.New(env, "testdata")) fs = layerfs.New(memoryfs.New(), fs) diff --git a/pkg/contexts/ocm/utils/check/check_test.go b/pkg/contexts/ocm/utils/check/check_test.go index 33c7b99b53..259adf82f2 100644 --- a/pkg/contexts/ocm/utils/check/check_test.go +++ b/pkg/contexts/ocm/utils/check/check_test.go @@ -9,7 +9,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/env/builder" . "github.com/open-component-model/ocm/pkg/testutils" "github.com/open-component-model/ocm/pkg/common" @@ -30,10 +30,10 @@ const COMP3 = "test.de/z" const COMP4 = "test.de/a" var _ = Describe("Test Environment", func() { - var env *TestEnv + var env *Builder BeforeEach(func() { - env = NewTestEnv() + env = NewBuilder() }) AfterEach(func() { diff --git a/pkg/toi/support/app.go b/pkg/toi/support/app.go index 6875774f1c..0b1886f67e 100644 --- a/pkg/toi/support/app.go +++ b/pkg/toi/support/app.go @@ -13,7 +13,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - common2 "github.com/open-component-model/ocm/cmds/ocm/commands/ocmcmds/common" + "github.com/open-component-model/ocm/pkg/clisupport" "github.com/open-component-model/ocm/pkg/cobrautils" "github.com/open-component-model/ocm/pkg/cobrautils/logopts" "github.com/open-component-model/ocm/pkg/common" @@ -135,7 +135,7 @@ func (o *BootstrapperCLIOptions) Complete() error { return errors.Newf("empty credential attribute set for %s", id.String()) } - set, err := common2.ParseLabels(vfsattr.Get(o.Context), o.Settings, "attribute setting") + set, err := clisupport.ParseLabels(vfsattr.Get(o.Context), o.Settings, "attribute setting") if err == nil && len(set) > 0 { ctx := o.Context.ConfigContext() spec := datactg.New()