Skip to content

Commit

Permalink
Merge branch 'main' into release-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ikhandamirov authored Jan 14, 2025
2 parents a6a6d37 + f0103a8 commit 28a4ea4
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 27 deletions.
2 changes: 2 additions & 0 deletions api/oci/ociutils/ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
. "github.com/mandelsoft/goutils/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/opencontainers/go-digest"

"ocm.software/ocm/api/oci/ociutils"
"ocm.software/ocm/api/oci/testhelper"
)
Expand Down
2 changes: 1 addition & 1 deletion api/ocm/extensions/accessmethods/git/method_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (

_ "embed"

"github.com/go-git/go-git/v5/plumbing"
. "github.com/mandelsoft/goutils/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/mandelsoft/filepath/pkg/filepath"
"github.com/mandelsoft/vfs/pkg/cwdfs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ func (c *ComponentVersionContainer) SetReadOnly() {

func (c *ComponentVersionContainer) Check() error {
if c.version != c.GetDescriptor().Version {
// check if version contained '+' which has been replaced by META_SEPARATOR to create OCI compliant tag
if replaced, _ := toTag(c.GetDescriptor().Version); replaced != c.GetDescriptor().Version && replaced == c.version {
Logger(c.GetContext()).Warn(fmt.Sprintf(
"checked version %q contains %q, this is discouraged and you should prefer the original component version %q", c.version, META_SEPARATOR, c.GetDescriptor().Version))
return nil
}
return errors.ErrInvalid("component version", c.GetDescriptor().Version)
}
if c.comp.name != c.GetDescriptor().Name {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package genericocireg

import (
"testing"

"github.com/stretchr/testify/assert"

"ocm.software/ocm/api/ocm/internal"
"ocm.software/ocm/api/utils/accessobj"
)

func TestComponentVersionContainer_Check(t *testing.T) {
// Setup
state, err := accessobj.NewBlobStateForBlob(accessobj.ACC_READONLY, nil, NewStateHandler("mock.test.com/state_handler", "1.0.0"))
assert.NoError(t, err)
repo := &RepositoryImpl{ctx: internal.DefaultContext}
comp := &componentAccessImpl{repo: repo}
cvc := &ComponentVersionContainer{state: state, comp: comp}

// Test cases
tests := []struct {
name string
setup func()
expectErr bool
}{
{
name: "valid version and name",
setup: func() {
cvc.version = "1.0.0"
cvc.GetDescriptor().Version = "1.0.0"
cvc.comp.name = "test-component"
cvc.GetDescriptor().Name = "test-component"
},
expectErr: false,
},
{
name: "half valid version - containing META_SEPARATOR = " + META_SEPARATOR,
setup: func() {
cvc.version = "0.0.1-20250108132333.build-af79499"
cvc.GetDescriptor().Version = "0.0.1-20250108132333+af79499"
cvc.comp.name = "test-component"
cvc.GetDescriptor().Name = "test-component"
},
expectErr: false,
},
{
name: "valid version - containing '+'",
setup: func() {
cvc.version = "0.0.1-20250108132333+af79499"
cvc.GetDescriptor().Version = "0.0.1-20250108132333+af79499"
cvc.comp.name = "test-component"
cvc.GetDescriptor().Name = "test-component"
},
expectErr: false,
},
{
name: "invalid version",
setup: func() {
cvc.version = "1.0.0"
cvc.GetDescriptor().Version = "2.0.0"
},
expectErr: true,
},
{
name: "invalid name",
setup: func() {
cvc.comp.name = "test-component"
cvc.GetDescriptor().Name = "invalid-component"
},
expectErr: true,
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
test.setup()
err := cvc.Check()
if test.expectErr {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
})
}
}
5 changes: 3 additions & 2 deletions api/ocm/extensions/repositories/genericocireg/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import (
. "github.com/mandelsoft/goutils/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"ocm.software/ocm/api/datacontext"
"ocm.software/ocm/api/ocm/extensions/repositories/genericocireg/config"

"github.com/mandelsoft/goutils/finalizer"
"github.com/mandelsoft/vfs/pkg/osfs"
"github.com/mandelsoft/vfs/pkg/vfs"

"ocm.software/ocm/api/datacontext"
"ocm.software/ocm/api/oci"
"ocm.software/ocm/api/oci/extensions/repositories/ctf"
"ocm.software/ocm/api/ocm"
"ocm.software/ocm/api/ocm/cpi/repocpi"
"ocm.software/ocm/api/ocm/extensions/repositories/genericocireg"
"ocm.software/ocm/api/ocm/extensions/repositories/genericocireg/config"
"ocm.software/ocm/api/utils/accessio"
"ocm.software/ocm/api/utils/accessobj"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import (
common "ocm.software/ocm/api/utils/misc"
)

const COMPAT_ARCH = "/testdata/v0.18.0"
const COMPAT_COMP = "github.com/mandelsoft/test1"
const COMPAT_VERS = "1.0.0"
const (
COMPAT_ARCH = "/testdata/v0.18.0"
COMPAT_COMP = "github.com/mandelsoft/test1"
COMPAT_VERS = "1.0.0"
)

var _ = Describe("Transfer Test Environment", func() {
Context("extraid compatibility transfer", func() {

var env *TestEnv

BeforeEach(func() {
Expand Down
3 changes: 2 additions & 1 deletion api/tech/git/identity/identity_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package identity_test

import (
"github.com/mandelsoft/goutils/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "ocm.software/ocm/api/tech/git/identity"

"github.com/mandelsoft/goutils/testutils"

"ocm.software/ocm/api/credentials"
"ocm.software/ocm/api/datacontext"
"ocm.software/ocm/api/oci"
Expand Down
8 changes: 4 additions & 4 deletions api/tech/git/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import (
"os"
"time"

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

"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/mandelsoft/filepath/pkg/filepath"
. "github.com/mandelsoft/goutils/testutils"
"github.com/mandelsoft/vfs/pkg/cwdfs"
"github.com/mandelsoft/vfs/pkg/osfs"
"github.com/mandelsoft/vfs/pkg/projectionfs"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"ocm.software/ocm/api/datacontext/attrs/tmpcache"
"ocm.software/ocm/api/datacontext/attrs/vfsattr"
Expand Down Expand Up @@ -107,6 +108,5 @@ var _ = Describe("standard tests with local file repo", func() {

file := Must(tempVFS.Stat("file_in_repo"))
Expect(file.Size()).To(Equal(int64(len(expectedBlobContent))))

})
})
11 changes: 6 additions & 5 deletions api/utils/blobaccess/git/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ package git_test

import (
"embed"
_ "embed"
"fmt"
"io"
"os"
"time"

_ "embed"

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

"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/mandelsoft/filepath/pkg/filepath"
. "github.com/mandelsoft/goutils/testutils"
"github.com/mandelsoft/vfs/pkg/osfs"
"github.com/mandelsoft/vfs/pkg/projectionfs"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"ocm.software/ocm/api/datacontext/attrs/tmpcache"
"ocm.software/ocm/api/datacontext/attrs/vfsattr"
Expand Down Expand Up @@ -100,7 +102,6 @@ var _ = Describe("git Blob Access", func() {
files := Must(tarutils.ListArchiveContentFromReader(Must(b.Reader())))
Expect(files).To(ConsistOf("file_in_repo"))
})

})

Context("git http repository", func() {
Expand Down
4 changes: 2 additions & 2 deletions api/utils/logging/roundtripper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"net/http"
"net/http/httptest"

logcfg "github.com/mandelsoft/logging/config"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/tonglil/buflogr"

"github.com/mandelsoft/logging"
logcfg "github.com/mandelsoft/logging/config"
"github.com/tonglil/buflogr"

local "ocm.software/ocm/api/utils/logging"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
. "github.com/mandelsoft/goutils/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "ocm.software/ocm/cmds/ocm/testhelper"

"ocm.software/ocm/api/datacontext/attrs/vfsattr"
"ocm.software/ocm/api/ocm"
"ocm.software/ocm/api/ocm/extensions/repositories/ctf"
"ocm.software/ocm/api/utils/accessio"
. "ocm.software/ocm/cmds/ocm/testhelper"
)

const (
Expand Down Expand Up @@ -78,7 +78,6 @@ resources:
})

It("add git repo described by cli options through blob access via input described in file", func() {

constructor := fmt.Sprintf(`---
name: test.de/x
version: %s
Expand Down
3 changes: 2 additions & 1 deletion cmds/ocm/commands/ocmcmds/components/add/cmd_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package add_test

import (
"github.com/mandelsoft/goutils/general"
. "github.com/mandelsoft/goutils/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "ocm.software/ocm/api/oci/testhelper"
. "ocm.software/ocm/cmds/ocm/testhelper"

"github.com/mandelsoft/goutils/general"

"ocm.software/ocm/api/oci"
"ocm.software/ocm/api/oci/artdesc"
"ocm.software/ocm/api/ocm"
Expand Down
1 change: 0 additions & 1 deletion cmds/ocm/commands/ocmcmds/components/hash/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
. "github.com/mandelsoft/goutils/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "ocm.software/ocm/cmds/ocm/testhelper"

"ocm.software/ocm/api/ocm/compdesc"
Expand Down
3 changes: 1 addition & 2 deletions cmds/ocm/commands/ocmcmds/components/sign/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import (
. "github.com/mandelsoft/goutils/testutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "ocm.software/ocm/api/oci/testhelper"
"ocm.software/ocm/api/ocm/compdesc"
. "ocm.software/ocm/api/ocm/testhelper"
. "ocm.software/ocm/cmds/ocm/testhelper"

"github.com/mandelsoft/vfs/pkg/vfs"

"ocm.software/ocm/api/datacontext"
"ocm.software/ocm/api/oci"
"ocm.software/ocm/api/ocm/compdesc"
metav1 "ocm.software/ocm/api/ocm/compdesc/meta/v1"
"ocm.software/ocm/api/ocm/extensions/accessmethods/ociartifact"
resourcetypes "ocm.software/ocm/api/ocm/extensions/artifacttypes"
Expand Down
5 changes: 3 additions & 2 deletions examples/lib/tour/07-resource-management/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/mandelsoft/goutils/errors"

"ocm.software/ocm/api/ocm"
metav1 "ocm.software/ocm/api/ocm/compdesc/meta/v1"
"ocm.software/ocm/api/ocm/extensions/repositories/ocireg"
Expand Down Expand Up @@ -80,8 +81,7 @@ func (r *resource) Close() error {
// --- begin caching factory ---
// CachingFactory provides resource inmplementations
// using the original access as cache.
type CachingFactory struct {
}
type CachingFactory struct{}

func (c CachingFactory) Create(id metav1.Identity, typ string) Resource {
return &resource{
Expand All @@ -95,6 +95,7 @@ func (c CachingFactory) Create(id metav1.Identity, typ string) Resource {
func (r *resource) GetIdentity() metav1.Identity {
return r.Identity
}

func (r *resource) GetType() string {
return r.ArtifactType
}
Expand Down

0 comments on commit 28a4ea4

Please sign in to comment.