Skip to content

Commit

Permalink
Revert "feat: remove deprecated functions (#915)"
Browse files Browse the repository at this point in the history
This reverts commit cfcbb47.
  • Loading branch information
Skarlso authored Sep 11, 2024
1 parent cfcbb47 commit 373fff2
Show file tree
Hide file tree
Showing 40 changed files with 2,127 additions and 49 deletions.
29 changes: 14 additions & 15 deletions api/ocm/add_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"
"ocm.software/ocm/api/ocm/selectors"
. "ocm.software/ocm/api/ocm/testhelper"

"ocm.software/ocm/api/datacontext"
Expand Down Expand Up @@ -39,7 +38,7 @@ var _ = Describe("add resources", func() {
meta := ocm.NewResourceMeta("test", resourcetypes.PLAIN_TEXT, metav1.ExternalRelation)
MustBeSuccessful(cv.SetResourceBlob(meta.WithVersion("v1"),
blobaccess.ForString(mime.MIME_TEXT, S_TESTDATA), "", nil))
Expect(Must(cv.SelectResources(selectors.Name("test")))[0].Meta().Digest).To(Equal(DS_TESTDATA))
Expect(Must(cv.GetResourcesByName("test"))[0].Meta().Digest).To(Equal(DS_TESTDATA))
})

It("replaces resource", func() {
Expand All @@ -49,7 +48,7 @@ var _ = Describe("add resources", func() {

MustBeSuccessful(cv.SetResourceBlob(meta.WithVersion("v1"),
blobaccess.ForString(mime.MIME_TEXT, S_OTHERDATA), "", nil))
Expect(Must(cv.SelectResources(selectors.Name("test")))[0].Meta().Digest).To(Equal(DS_OTHERDATA))
Expect(Must(cv.GetResourcesByName("test"))[0].Meta().Digest).To(Equal(DS_OTHERDATA))
})

It("replaces resource (enforced)", func() {
Expand All @@ -59,11 +58,11 @@ var _ = Describe("add resources", func() {

MustBeSuccessful(cv.SetResourceBlob(meta.WithVersion("v1"),
blobaccess.ForString(mime.MIME_TEXT, S_OTHERDATA), "", nil, ocm.UpdateElement))
Expect(Must(cv.SelectResources(selectors.Name("test")))[0].Meta().Digest).To(Equal(DS_OTHERDATA))
Expect(Must(cv.GetResourcesByName("test"))[0].Meta().Digest).To(Equal(DS_OTHERDATA))

MustBeSuccessful(cv.SetResourceBlob(meta.WithVersion("v2"),
blobaccess.ForString(mime.MIME_TEXT, S_OTHERDATA), "", nil, ocm.UpdateElement))
Expect(Must(cv.SelectResources(selectors.Name("test")))[0].Meta().Digest).To(Equal(DS_OTHERDATA))
Expect(Must(cv.GetResourcesByName("test"))[0].Meta().Digest).To(Equal(DS_OTHERDATA))
})

It("fails replace non-existent resource)", func() {
Expand All @@ -82,9 +81,9 @@ var _ = Describe("add resources", func() {
blobaccess.ForString(mime.MIME_TEXT, S_TESTDATA), "", nil))
MustBeSuccessful(cv.SetResourceBlob(meta.WithVersion("v2"),
blobaccess.ForString(mime.MIME_TEXT, S_OTHERDATA), "", nil, ocm.AppendElement))
Expect(len(Must(cv.SelectResources(selectors.Name("test"))))).To(Equal(2))
Expect(Must(cv.SelectResources(selectors.Name("test")))[0].Meta().Digest).To(Equal(DS_TESTDATA))
Expect(Must(cv.SelectResources(selectors.Name("test")))[1].Meta().Digest).To(Equal(DS_OTHERDATA))
Expect(len(Must(cv.GetResourcesByName("test")))).To(Equal(2))
Expect(Must(cv.GetResourcesByName("test"))[0].Meta().Digest).To(Equal(DS_TESTDATA))
Expect(Must(cv.GetResourcesByName("test"))[1].Meta().Digest).To(Equal(DS_OTHERDATA))
})

It("rejects duplicate resource with same version", func() {
Expand Down Expand Up @@ -121,7 +120,7 @@ var _ = Describe("add resources", func() {

MustBeSuccessful(cv.SetSourceBlob(meta.WithVersion("v1"),
blobaccess.ForString(mime.MIME_TEXT, S_OTHERDATA), "", nil))
Expect(len(Must(cv.SelectSources(selectors.Name("test"))))).To(Equal(1))
Expect(len(Must(cv.GetSourcesByName("test")))).To(Equal(1))
})

It("replaces source (enforced)", func() {
Expand All @@ -131,11 +130,11 @@ var _ = Describe("add resources", func() {

MustBeSuccessful(cv.SetSourceBlob(meta.WithVersion("v1"),
blobaccess.ForString(mime.MIME_TEXT, S_OTHERDATA), "", nil, ocm.UpdateElement))
Expect(len(Must(cv.SelectSources(selectors.Name("test"))))).To(Equal(1))
Expect(len(Must(cv.GetSourcesByName("test")))).To(Equal(1))

MustBeSuccessful(cv.SetSourceBlob(meta.WithVersion("v2"),
blobaccess.ForString(mime.MIME_TEXT, S_OTHERDATA), "", nil, ocm.UpdateElement))
Expect(len(Must(cv.SelectSources(selectors.Name("test"))))).To(Equal(1))
Expect(len(Must(cv.GetSourcesByName("test")))).To(Equal(1))
})

It("fails replace non-existent source)", func() {
Expand All @@ -154,7 +153,7 @@ var _ = Describe("add resources", func() {
blobaccess.ForString(mime.MIME_TEXT, S_TESTDATA), "", nil))
MustBeSuccessful(cv.SetSourceBlob(meta.WithVersion("v2"),
blobaccess.ForString(mime.MIME_TEXT, S_OTHERDATA), "", nil, ocm.AppendElement))
Expect(len(Must(cv.SelectSources(selectors.Name("test"))))).To(Equal(2))
Expect(len(Must(cv.GetSourcesByName("test")))).To(Equal(2))
})

It("rejects duplicate source with same version", func() {
Expand Down Expand Up @@ -188,15 +187,15 @@ var _ = Describe("add resources", func() {
MustBeSuccessful(cv.SetReference(ref))

MustBeSuccessful(cv.SetReference(ref.WithVersion("v1")))
Expect(len(Must(cv.SelectReferences(selectors.Name("test"))))).To(Equal(1))
Expect(len(Must(cv.GetReferencesByName("test")))).To(Equal(1))
})

It("replaces source (enforced)", func() {
ref := ocm.NewComponentReference("test", COMPONENT+"/sub", "v1")
MustBeSuccessful(cv.SetReference(ref))

MustBeSuccessful(cv.SetReference(ref.WithVersion("v2")))
Expect(len(Must(cv.SelectReferences(selectors.Name("test"))))).To(Equal(1))
Expect(len(Must(cv.GetReferencesByName("test")))).To(Equal(1))
})

It("fails replace non-existent source)", func() {
Expand All @@ -211,7 +210,7 @@ var _ = Describe("add resources", func() {
ref := ocm.NewComponentReference("test", COMPONENT+"/sub", "v1")
MustBeSuccessful(cv.SetReference(ref))
MustBeSuccessful(cv.SetReference(ref.WithVersion("v2"), ocm.AppendElement))
Expect(len(Must(cv.SelectReferences(selectors.Name("test"))))).To(Equal(2))
Expect(len(Must(cv.GetReferencesByName("test")))).To(Equal(2))
})

It("rejects duplicate reference with same version", func() {
Expand Down
3 changes: 3 additions & 0 deletions api/ocm/compdesc/componentdescriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@ type Reference struct {
Digest *metav1.DigestSpec `json:"digest,omitempty"`
}

// Deprecated: use Reference.
type ComponentReference = Reference

func NewComponentReference(name, componentName, version string, extraIdentity metav1.Identity) *Reference {
return &Reference{
ElementMeta: ElementMeta{
Expand Down
Loading

0 comments on commit 373fff2

Please sign in to comment.