diff --git a/VERSION b/VERSION index a0073758b8..498b6fb3d5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.17.0-dev +0.18.0-dev diff --git a/api/credentials/internal/identity.go b/api/credentials/internal/identity.go index d8b3e84d91..6743754550 100644 --- a/api/credentials/internal/identity.go +++ b/api/credentials/internal/identity.go @@ -93,6 +93,10 @@ func orMatcher(list []IdentityMatcher) IdentityMatcher { // ConsumerIdentity describes the identity of a credential consumer. type ConsumerIdentity map[string]string +// UnmarshalJSON allows a yaml specification containing a data type other +// string, e.g. a hostpath spec with a port. Previously, it would error if the +// user specified `port: 5000` and instead, the user had to specify +// `port: "5000"`. func (c *ConsumerIdentity) UnmarshalJSON(data []byte) error { var m map[string]interface{} err := runtime.DefaultJSONEncoding.Unmarshal(data, &m) @@ -100,15 +104,21 @@ func (c *ConsumerIdentity) UnmarshalJSON(data []byte) error { return err } + if len(m) == 0 { + return nil + } *c = make(map[string]string, len(m)) for k, v := range m { switch v.(type) { + case nil: + (*c)[k] = "" case map[string]interface{}: return fmt.Errorf("cannot unmarshal complex type into consumer identity") case []interface{}: return fmt.Errorf("cannot unmarshal complex type into consumer identity") + default: + (*c)[k] = fmt.Sprintf("%v", v) } - (*c)[k] = fmt.Sprintf("%v", v) } return nil } diff --git a/api/credentials/internal/identity_test.go b/api/credentials/internal/identity_test.go index 990a19997a..66633df813 100644 --- a/api/credentials/internal/identity_test.go +++ b/api/credentials/internal/identity_test.go @@ -70,4 +70,19 @@ port: cid := internal.ConsumerIdentity{} Expect(yaml.Unmarshal([]byte(data), &cid)).NotTo(Succeed()) }) + It("with nil", func() { + data := ` +scheme: http +hostname: 127.0.0.1 +port: +` + id := internal.ConsumerIdentity{ + "scheme": "http", + "hostname": "127.0.0.1", + "port": "", + } + cid := internal.ConsumerIdentity{} + Expect(yaml.Unmarshal([]byte(data), &cid)).To(Succeed()) + Expect(cid).To(Equal(id)) + }) }) diff --git a/api/oci/ref_test.go b/api/oci/ref_test.go index f0d27516c5..c95850ef03 100644 --- a/api/oci/ref_test.go +++ b/api/oci/ref_test.go @@ -3,11 +3,11 @@ package oci_test import ( "strings" - "github.com/mandelsoft/goutils/generics" . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/mandelsoft/goutils/generics" godigest "github.com/opencontainers/go-digest" "ocm.software/ocm/api/oci" @@ -255,8 +255,10 @@ var _ = Describe("ref parsing", func() { }, ArtSpec: oci.ArtSpec{ Repository: r, - ArtVersion: oci.ArtVersion{Tag: Pointer([]byte(uv)), - Digest: Dig([]byte(ud))}, + ArtVersion: oci.ArtVersion{ + Tag: Pointer([]byte(uv)), + Digest: Dig([]byte(ud)), + }, }, }) }) @@ -293,8 +295,10 @@ var _ = Describe("ref parsing", func() { }, ArtSpec: oci.ArtSpec{ Repository: r, - ArtVersion: oci.ArtVersion{Tag: Pointer([]byte(uv)), - Digest: Dig([]byte(ud))}, + ArtVersion: oci.ArtVersion{ + Tag: Pointer([]byte(uv)), + Digest: Dig([]byte(ud)), + }, }, }) }) @@ -343,8 +347,10 @@ var _ = Describe("ref parsing", func() { }, ArtSpec: oci.ArtSpec{ Repository: r, - ArtVersion: oci.ArtVersion{Tag: Pointer([]byte(uv)), - Digest: Dig([]byte(ud))}, + ArtVersion: oci.ArtVersion{ + Tag: Pointer([]byte(uv)), + Digest: Dig([]byte(ud)), + }, }, }) }) @@ -382,8 +388,10 @@ var _ = Describe("ref parsing", func() { }, ArtSpec: oci.ArtSpec{ Repository: "library/" + r, - ArtVersion: oci.ArtVersion{Tag: Pointer([]byte(uv)), - Digest: Dig([]byte(ud))}, + ArtVersion: oci.ArtVersion{ + Tag: Pointer([]byte(uv)), + Digest: Dig([]byte(ud)), + }, }, }) }) @@ -418,8 +426,10 @@ var _ = Describe("ref parsing", func() { }, ArtSpec: oci.ArtSpec{ Repository: r, - ArtVersion: oci.ArtVersion{Tag: Pointer([]byte(uv)), - Digest: Dig([]byte(ud))}, + ArtVersion: oci.ArtVersion{ + Tag: Pointer([]byte(uv)), + Digest: Dig([]byte(ud)), + }, }, }) }) @@ -596,8 +606,10 @@ var _ = Describe("ref parsing", func() { }, ArtSpec: oci.ArtSpec{ Repository: "repo/repo", - ArtVersion: oci.ArtVersion{Tag: &tag, - Digest: &digest}, + ArtVersion: oci.ArtVersion{ + Tag: &tag, + Digest: &digest, + }, }, }) CheckRef("http://127.0.0.1:443/repo/repo:v1@"+digest.String(), &oci.RefSpec{ @@ -609,8 +621,10 @@ var _ = Describe("ref parsing", func() { }, ArtSpec: oci.ArtSpec{ Repository: "repo/repo", - ArtVersion: oci.ArtVersion{Tag: &tag, - Digest: &digest}, + ArtVersion: oci.ArtVersion{ + Tag: &tag, + Digest: &digest, + }, }, }) CheckRef("directory::a/b", &oci.RefSpec{ diff --git a/api/ocm/extensions/accessmethods/ociartifact/method.go b/api/ocm/extensions/accessmethods/ociartifact/method.go index a8cb908410..38fef2b5ef 100644 --- a/api/ocm/extensions/accessmethods/ociartifact/method.go +++ b/api/ocm/extensions/accessmethods/ociartifact/method.go @@ -227,7 +227,7 @@ func (m *accessMethod) eval(relto oci.Repository) error { ocictx := m.ctx.OCIContext() spec := ocictx.GetAlias(ref.Host) if spec == nil { - spec = ocireg.NewRepositorySpec(ref.Host) + spec = ocireg.NewRepositorySpec(ref.RepositoryRef()) } repo, err := ocictx.RepositoryForSpec(spec) if err != nil { diff --git a/api/ocm/extensions/download/config/registration_test.go b/api/ocm/extensions/download/config/registration_test.go index e2f81a3f40..f68f6efb41 100644 --- a/api/ocm/extensions/download/config/registration_test.go +++ b/api/ocm/extensions/download/config/registration_test.go @@ -6,17 +6,16 @@ import ( . "github.com/mandelsoft/goutils/testutils" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "ocm.software/ocm/api/ocm" "ocm.software/ocm/api/ocm/extensions/download" + me "ocm.software/ocm/api/ocm/extensions/download/config" "ocm.software/ocm/api/ocm/ocmutils" "ocm.software/ocm/api/tech/helm" - - me "ocm.software/ocm/api/ocm/extensions/download/config" ) var _ = Describe("Download Handler regigistration", func() { It("register by ocm config", func() { - ctx := ocm.New() cfg := me.New() diff --git a/cmds/ocm/commands/verbs/install/cmd.go b/cmds/ocm/commands/verbs/install/cmd.go index ea1ca8661f..87cbb3dbb3 100644 --- a/cmds/ocm/commands/verbs/install/cmd.go +++ b/cmds/ocm/commands/verbs/install/cmd.go @@ -12,7 +12,7 @@ import ( // NewCommand creates a new command. func NewCommand(ctx clictx.Context) *cobra.Command { cmd := utils.MassageCommand(&cobra.Command{ - Short: "Install elements.", + Short: "Install new OCM CLI components ", }, verbs.Install) cmd.AddCommand(plugins.NewCommand(ctx)) return cmd diff --git a/docs/reference/ocm.md b/docs/reference/ocm.md index c88be56806..f99a049602 100644 --- a/docs/reference/ocm.md +++ b/docs/reference/ocm.md @@ -369,7 +369,7 @@ by a certificate delivered with the signature. * [ocm execute](ocm_execute.md) — Execute an element. * [ocm get](ocm_get.md) — Get information about artifacts and components * [ocm hash](ocm_hash.md) — Hash and normalization operations -* [ocm install](ocm_install.md) — Install elements. +* [ocm install](ocm_install.md) — Install new OCM CLI components * [ocm list](ocm_list.md) — List information about components * [ocm set](ocm_set.md) — Set information about OCM repositories * [ocm show](ocm_show.md) — Show tags or versions diff --git a/docs/reference/ocm_install.md b/docs/reference/ocm_install.md index fc01db3356..3646334332 100644 --- a/docs/reference/ocm_install.md +++ b/docs/reference/ocm_install.md @@ -1,4 +1,4 @@ -## ocm install — Install Elements. +## ocm install — Install New OCM CLI Components ### Synopsis diff --git a/docs/reference/ocm_install_plugins.md b/docs/reference/ocm_install_plugins.md index 9e501520c0..9c20720c97 100644 --- a/docs/reference/ocm_install_plugins.md +++ b/docs/reference/ocm_install_plugins.md @@ -87,6 +87,6 @@ $ ocm install plugin -r demo #### Parents -* [ocm install](ocm_install.md) — Install elements. +* [ocm install](ocm_install.md) — Install new OCM CLI components * [ocm](ocm.md) — Open Component Model command line client