Skip to content

Commit

Permalink
Merge branch 'dee0sap_main' into ocm-issue-179-block-in-config-yields…
Browse files Browse the repository at this point in the history
…-invalid-xml
  • Loading branch information
dee0sap committed May 2, 2024
2 parents 09b9cb2 + 53f3617 commit 5a2fc4e
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 23 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/buildcomponents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
packages: write
repository-projects: read
steps:
- name: Self Hosted Runner Post Job Cleanup Action
uses: TooMuch4U/[email protected]

- name: Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -63,4 +66,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ocm.ctf
path: gen/ctf
path: gen/ctf
7 changes: 7 additions & 0 deletions .github/workflows/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
run: |
cd components/ocmcli
PATH=$PATH:$(go env GOPATH)/bin make ctf
build-helminstaller:
name: Build HelmInstaller
runs-on: large_runner
Expand All @@ -65,6 +66,7 @@ jobs:
run: |
cd components/helminstaller
PATH=$PATH:$(go env GOPATH)/bin make ctf
build-helmdemo:
name: Build HelmDemo
runs-on: large_runner
Expand All @@ -91,6 +93,7 @@ jobs:
run: |
cd components/helmdemo
PATH=$PATH:$(go env GOPATH)/bin make ctf
build-subchartsdemo:
name: Build Helm SubChartsDemo
runs-on: large_runner
Expand All @@ -117,10 +120,14 @@ jobs:
run: |
cd components/subchartsdemo
PATH=$PATH:$(go env GOPATH)/bin make ctf
build-ecrplugin:
name: Build ECR Plugin
runs-on: large_runner
steps:
- name: Self Hosted Runner Post Job Cleanup Action
uses: TooMuch4U/[email protected]

- name: Checkout
uses: actions/checkout@v4
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/lint_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
run: |
PATH=$PATH:$(go env GOPATH)/bin make build
PATH=$PATH:$(go env GOPATH)/bin make test
lint:
name: Lint
runs-on: large_runner
Expand Down Expand Up @@ -71,10 +72,14 @@ jobs:
- name: Lint
run: |
PATH=$PATH:$(go env GOPATH)/bin make check
generate:
name: DeepCopy verification
runs-on: large_runner
steps:
- name: Self Hosted Runner Post Job Cleanup Action
uses: TooMuch4U/[email protected]

- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -99,3 +104,4 @@ jobs:
- name: Check for diff
run: |
git diff --exit-code --shortstat
2 changes: 2 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ jobs:
id-token: write
packages: write
steps:
- name: Self Hosted Runner Post Job Cleanup Action
uses: TooMuch4U/[email protected]
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
Expand Down
22 changes: 13 additions & 9 deletions pkg/contexts/ocm/repositories/genericocireg/component.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package genericocireg

import (
Expand Down Expand Up @@ -73,12 +69,12 @@ func (c *componentAccessImpl) GetName() string {

////////////////////////////////////////////////////////////////////////////////

func toTag(v string) string {
func toTag(v string) (string, error) {
_, err := semver.NewVersion(v)
if err != nil {
panic(errors.Wrapf(err, "%s is no semver version", v))
return "", err
}
return strings.ReplaceAll(v, "+", META_SEPARATOR)
return strings.ReplaceAll(v, "+", META_SEPARATOR), nil
}

func toVersion(t string) string {
Expand Down Expand Up @@ -132,7 +128,11 @@ func (c *componentAccessImpl) HasVersion(vers string) (bool, error) {
}

func (c *componentAccessImpl) LookupVersion(version string) (*repocpi.ComponentVersionAccessInfo, error) {
acc, err := c.namespace.GetArtifact(toTag(version))
tag, err := toTag(version)
if err != nil {
return nil, err
}
acc, err := c.namespace.GetArtifact(tag)
if err != nil {
if errors.IsErrNotFound(err) {
return nil, cpi.ErrComponentVersionNotFoundWrap(err, c.name, version)
Expand All @@ -151,7 +151,11 @@ func (c *componentAccessImpl) NewVersion(version string, overrides ...bool) (*re
return nil, accessio.ErrReadOnly
}
override := utils.Optional(overrides...)
acc, err := c.namespace.GetArtifact(toTag(version))
tag, err := toTag(version)
if err != nil {
return nil, err
}
acc, err := c.namespace.GetArtifact(tag)
if err == nil {
if override {
return newComponentVersionAccess(accessobj.ACC_CREATE, c, version, acc, false)
Expand Down
10 changes: 5 additions & 5 deletions pkg/contexts/ocm/repositories/genericocireg/componentversion.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package genericocireg

import (
Expand Down Expand Up @@ -222,7 +218,11 @@ func (c *ComponentVersionContainer) Update() error {
}

logger.Debug("add oci artifact")
if _, err := c.comp.namespace.AddArtifact(c.manifest, toTag(c.version)); err != nil {
tag, err := toTag(c.version)
if err != nil {
return err
}
if _, err := c.comp.namespace.AddArtifact(c.manifest, tag); err != nil {
return fmt.Errorf("unable to add artifact: %w", err)
}
}
Expand Down
20 changes: 12 additions & 8 deletions pkg/contexts/ocm/repositories/genericocireg/repo_test.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package genericocireg_test

import (
"fmt"
"path"
"reflect"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/open-component-model/ocm/pkg/testutils"

"github.com/mandelsoft/vfs/pkg/osfs"
"github.com/mandelsoft/vfs/pkg/vfs"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/opencontainers/go-digest"

"github.com/open-component-model/ocm/pkg/blobaccess"
Expand Down Expand Up @@ -50,6 +44,7 @@ import (
"github.com/open-component-model/ocm/pkg/finalizer"
"github.com/open-component-model/ocm/pkg/mime"
"github.com/open-component-model/ocm/pkg/signing/hasher/sha256"
. "github.com/open-component-model/ocm/pkg/testutils"
)

var DefaultContext = ocm.New()
Expand Down Expand Up @@ -79,6 +74,15 @@ var _ = Describe("component repository mapping", func() {
vfs.Cleanup(tempfs)
})

It("Don't Panik! When it's not a semver.org conform version. #756", func() {
repo := Must(DefaultContext.RepositoryForSpec(spec))
comp := Must(repo.LookupComponent(COMPONENT))
cva, err := comp.NewVersion("v1.two.zeo-2")
Expect(err).To(HaveOccurred())
Expect(cva).To(BeNil())
Expect(err.Error()).To(Equal("Invalid Semantic Version"))
})

It("creates a dummy component", func() {
var finalize finalizer.Finalizer
defer Defer(finalize.Finalize)
Expand Down

0 comments on commit 5a2fc4e

Please sign in to comment.