Skip to content

Commit

Permalink
Merge branch 'main' into pubsub
Browse files Browse the repository at this point in the history
  • Loading branch information
mandelsoft authored Jul 25, 2024
2 parents 6632def + 91d5ed5 commit 2829a1b
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 18 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.0-dev
0.13.0-dev
1 change: 0 additions & 1 deletion cmds/demoplugin/valuesets/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var _ = Describe("demoplugin", func() {
var plugins TempPluginDir

BeforeEach(func() {

env = NewBuilder(TestData())
plugins = Must(ConfigureTestPlugins(env, "testdata"))

Expand Down
24 changes: 24 additions & 0 deletions docs/releasenotes/v0.12.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Release v0.12.0

- Extend version regexp to support semver (#834)
- fix broken links (#837)
- fix duplicate command argument for plugin command execution (#831)
- fix plugin error propagation (#830)
- rework source info access for plugin clients (#829)
- Bump github.com/hashicorp/go-retryablehttp from 0.7.6 to 0.7.7 in the go\_modules group (#827)
- Support for CLI Extensions by OCM Plugins (#815)
- Bump github.com/docker/docker from 26.1.4+incompatible to 27.0.0+incompatible (#817)
- cleanup unused (#828)
- close() writer, before trying to rename (#824)
- enhance the auto update of the flake vendor hash (#826)
- Bump the go group with 7 updates (#825)
- Update README.md (#822)
- fix https://github.com/open-component-model/ocm-project/issues/196 (#819)
- Bump the go group with 8 updates (#816)
- Fix make cmds (#810)
- Adjust action (#813)
- adjust github action definition (#811)
- restruct blobaccess (#804)
- auto update \`flake.nix\` vendor hash incl. singed commit (#809)
- Simplify Pull Request Template (#808)

5 changes: 3 additions & 2 deletions pkg/cobrautils/logopts/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"fmt"

. "github.com/mandelsoft/goutils/testutils"
"github.com/mandelsoft/logging"
"github.com/mandelsoft/logging/config"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/mandelsoft/logging"
"github.com/mandelsoft/logging/config"
"sigs.k8s.io/yaml"

"github.com/open-component-model/ocm/pkg/contexts/clictx"
Expand Down
2 changes: 1 addition & 1 deletion pkg/contexts/ocm/accessmethods/plugin/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/contexts/ocm/plugin/plugins"
. "github.com/open-component-model/ocm/pkg/contexts/ocm/plugin/testutils"
. "github.com/open-component-model/ocm/pkg/env"

Expand All @@ -15,6 +14,7 @@ import (
"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/plugin/plugins"
"github.com/open-component-model/ocm/pkg/contexts/ocm/registration"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/contexts/ocm/grammar/grammar.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (

VersionRegexp = Sequence(Optional(Literal("v")), Numeric, Repetition(0, 2, Literal("."), Numeric),
Optional(Literal("-"), Repeated(CharSet("0-9A-Za-z-")), OptionalRepeated(Literal("."), Repeated(CharSet("0-9A-Za-z-")))),
Optional(Literal("+"), Repeated(CharSet("0-9A-Za-z-"))),
Optional(Literal("+"), Repeated(CharSet("0-9A-Za-z-"))), OptionalRepeated(Literal("."), Repeated(CharSet("0-9A-Za-z-"))),
)

// AnchoredRepositoryRegexp parses a uniform repository spec.
Expand Down
34 changes: 28 additions & 6 deletions pkg/contexts/ocm/grammar/grammar_test.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package grammar

import (
"fmt"
"regexp"
"testing"

. "github.com/mandelsoft/goutils/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/Masterminds/semver/v3"
gr "github.com/mandelsoft/goutils/regexutils"
)

func TestConfig(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "OCI Test Suite")
}

func CheckRef(ref string, parts ...string) {
CheckWithOffset(1, ref, AnchoredReferenceRegexp, parts...)
}
Expand Down Expand Up @@ -91,6 +88,31 @@ var _ = Describe("ref matching", func() {
Expect(VersionRegexp.MatchString("v1-rc.1")).To(BeTrue())
Expect(VersionRegexp.MatchString("1.1.1-rc.1")).To(BeTrue())
})

It("matches complex semver", func() {
Expect(VersionRegexp.MatchString("0.2.3+2024.T06b")).To(BeTrue())
})

It("matches complex semver with v prefix", func() {
Expect(VersionRegexp.MatchString("v0.2.3+2024.T06b")).To(BeTrue())
})

for _, pre := range []string{"", "alpha1", "alpha.1.2", "alpha-1"} {
for _, build := range []string{"", "2024", "2024.1.T2b", "2024.1-T2b"} {
suf := ""
if pre != "" {
suf += "-" + pre
}
if build != "" {
suf += "+" + build
}
It(fmt.Sprintf("handles semver %s", suf), func() {
v := "v0.2.3" + suf
Must(semver.NewVersion(v))
Expect(VersionRegexp.MatchString(v)).To(BeTrue())
})
}
}
})

Context("complete refs", func() {
Expand Down
13 changes: 13 additions & 0 deletions pkg/contexts/ocm/grammar/suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package grammar

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestConfig(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "OCM grammar Test Suite")
}
58 changes: 58 additions & 0 deletions pkg/docker/errors/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package errors

import (
"fmt"
"io"
"net/http"
)

var _ error = ErrUnexpectedStatus{}

// ErrUnexpectedStatus is returned if a registry API request returned with unexpected HTTP status
type ErrUnexpectedStatus struct {
Status string
StatusCode int
Body []byte
RequestURL, RequestMethod string
}

func (e ErrUnexpectedStatus) Error() string {
if len(e.Body) > 0 {
return fmt.Sprintf("unexpected status from %s request to %s: %s: %s", e.RequestMethod, e.RequestURL, e.Status, string(e.Body))
}
return fmt.Sprintf("unexpected status from %s request to %s: %s", e.RequestMethod, e.RequestURL, e.Status)
}

// NewUnexpectedStatusErr creates an ErrUnexpectedStatus from HTTP response
func NewUnexpectedStatusErr(resp *http.Response) error {
var b []byte
if resp.Body != nil {
b, _ = io.ReadAll(io.LimitReader(resp.Body, 64000)) // 64KB
}
err := ErrUnexpectedStatus{
Body: b,
Status: resp.Status,
StatusCode: resp.StatusCode,
RequestMethod: resp.Request.Method,
}
if resp.Request.URL != nil {
err.RequestURL = resp.Request.URL.String()
}
return err
}
2 changes: 1 addition & 1 deletion pkg/docker/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/remotes"
remoteserrors "github.com/containerd/containerd/remotes/errors"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/open-component-model/ocm/pkg/common/accessio"
remoteserrors "github.com/open-component-model/ocm/pkg/docker/errors"
"github.com/open-component-model/ocm/pkg/docker/resolve"
)

Expand Down
3 changes: 1 addition & 2 deletions pkg/filelock/lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
. "github.com/onsi/gomega"

"github.com/mandelsoft/filepath/pkg/filepath"

"github.com/open-component-model/ocm/pkg/filelock"
)

var _ = Describe("lock identity", func() {
It("identity", func() {

l1 := Must(filelock.MutexFor("testdata/lock"))
l2 := Must(filelock.MutexFor("testdata/../testdata/lock"))
Expect(l1).To(BeIdenticalTo(l2))
Expand All @@ -32,5 +32,4 @@ var _ = Describe("lock identity", func() {
Expect(c).NotTo(BeNil())
c.Close()
})

})
6 changes: 3 additions & 3 deletions pkg/signing/handlers/rsa/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (h *Handler) Sign(cctx credentials.Context, digest string, sctx signing.Sig
return nil, errors.Wrapf(err, "public key certificate")
}
media = MediaTypePEM
value = string(signutils.SignatureBytesToPem(Algorithm, sig, certs...))
value = string(signutils.SignatureBytesToPem(h.Algorithm(), sig, certs...))
iss = certs[0].Subject.String()
} else {
pubKey, _, err = GetPublicKey(pub)
Expand All @@ -113,7 +113,7 @@ func (h *Handler) Sign(cctx credentials.Context, digest string, sctx signing.Sig
return &signing.Signature{
Value: value,
MediaType: media,
Algorithm: Algorithm,
Algorithm: h.Algorithm(),
Issuer: iss,
}, nil
}
Expand All @@ -138,7 +138,7 @@ func (h *Handler) Verify(digest string, signature *signing.Signature, sctx signi
if err != nil {
return fmt.Errorf("unable to get signature from pem: %w", err)
}
if algo != "" && algo != Algorithm {
if algo != "" && algo != h.Algorithm() {
return errors.ErrInvalid(signutils.KIND_SIGN_ALGORITHM, algo)
}
signatureBytes = sig
Expand Down

0 comments on commit 2829a1b

Please sign in to comment.