Skip to content

Commit

Permalink
Merge branch 'main' into http/proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
hilmarf authored Nov 8, 2024
2 parents a8b6003 + 2ea69c7 commit b531bb1
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 25 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.17.0-dev
0.18.0-dev
12 changes: 11 additions & 1 deletion api/credentials/internal/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,32 @@ 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)
if err != nil {
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
}
Expand Down
15 changes: 15 additions & 0 deletions api/credentials/internal/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})
44 changes: 29 additions & 15 deletions api/oci/ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)),
},
},
})
})
Expand Down Expand Up @@ -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)),
},
},
})
})
Expand Down Expand Up @@ -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)),
},
},
})
})
Expand Down Expand Up @@ -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)),
},
},
})
})
Expand Down Expand Up @@ -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)),
},
},
})
})
Expand Down Expand Up @@ -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{
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion api/ocm/extensions/accessmethods/ociartifact/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions api/ocm/extensions/download/config/registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cmds/ocm/commands/verbs/install/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ocm.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ by a certificate delivered with the signature.
* [ocm <b>execute</b>](ocm_execute.md) &mdash; Execute an element.
* [ocm <b>get</b>](ocm_get.md) &mdash; Get information about artifacts and components
* [ocm <b>hash</b>](ocm_hash.md) &mdash; Hash and normalization operations
* [ocm <b>install</b>](ocm_install.md) &mdash; Install elements.
* [ocm <b>install</b>](ocm_install.md) &mdash; Install new OCM CLI components
* [ocm <b>list</b>](ocm_list.md) &mdash; List information about components
* [ocm <b>set</b>](ocm_set.md) &mdash; Set information about OCM repositories
* [ocm <b>show</b>](ocm_show.md) &mdash; Show tags or versions
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ocm_install.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## ocm install &mdash; Install Elements.
## ocm install &mdash; Install New OCM CLI Components

### Synopsis

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ocm_install_plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ $ ocm install plugin -r demo

#### Parents

* [ocm install](ocm_install.md) &mdash; Install elements.
* [ocm install](ocm_install.md) &mdash; Install new OCM CLI components
* [ocm](ocm.md) &mdash; Open Component Model command line client

0 comments on commit b531bb1

Please sign in to comment.