Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove deprecated code - v2 #919

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions api/ocm/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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 @@ -38,7 +39,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.GetResourcesByName("test"))[0].Meta().Digest).To(Equal(DS_TESTDATA))
Expect(Must(cv.SelectResources(selectors.Name("test")))[0].Meta().Digest).To(Equal(DS_TESTDATA))
})

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

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

It("replaces resource (enforced)", func() {
Expand All @@ -58,11 +59,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.GetResourcesByName("test"))[0].Meta().Digest).To(Equal(DS_OTHERDATA))
Expect(Must(cv.SelectResources(selectors.Name("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.GetResourcesByName("test"))[0].Meta().Digest).To(Equal(DS_OTHERDATA))
Expect(Must(cv.SelectResources(selectors.Name("test")))[0].Meta().Digest).To(Equal(DS_OTHERDATA))
})

It("fails replace non-existent resource)", func() {
Expand All @@ -81,9 +82,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.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))
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))
})

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

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

It("replaces source (enforced)", func() {
Expand All @@ -130,11 +131,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.GetSourcesByName("test")))).To(Equal(1))
Expect(len(Must(cv.SelectSources(selectors.Name("test"))))).To(Equal(1))

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

It("fails replace non-existent source)", func() {
Expand All @@ -153,7 +154,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.GetSourcesByName("test")))).To(Equal(2))
Expect(len(Must(cv.SelectSources(selectors.Name("test"))))).To(Equal(2))
})

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

MustBeSuccessful(cv.SetReference(ref.WithVersion("v1")))
Expect(len(Must(cv.GetReferencesByName("test")))).To(Equal(1))
Expect(len(Must(cv.SelectReferences(selectors.Name("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.GetReferencesByName("test")))).To(Equal(1))
Expect(len(Must(cv.SelectReferences(selectors.Name("test"))))).To(Equal(1))
})

It("fails replace non-existent source)", func() {
Expand All @@ -210,7 +211,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.GetReferencesByName("test")))).To(Equal(2))
Expect(len(Must(cv.SelectReferences(selectors.Name("test"))))).To(Equal(2))
})

It("rejects duplicate reference with same version", func() {
Expand Down
3 changes: 0 additions & 3 deletions api/ocm/compdesc/componentdescriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,6 @@ 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