Skip to content

Commit

Permalink
removed a LOT of deprecated functions from the interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso committed Sep 10, 2024
1 parent cc77e46 commit 3b7e1cd
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 1,170 deletions.
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
156 changes: 0 additions & 156 deletions api/ocm/compdesc/deprecated.go

This file was deleted.

15 changes: 2 additions & 13 deletions api/ocm/compdesc/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package compdesc

import (
"bytes"
"fmt"

"github.com/mandelsoft/goutils/errors"

Expand All @@ -12,7 +11,6 @@ import (
"ocm.software/ocm/api/ocm/selectors/rscsel"
"ocm.software/ocm/api/ocm/selectors/srcsel"
"ocm.software/ocm/api/utils/runtime"
"ocm.software/ocm/api/utils/selector"
)

// GetEffectiveRepositoryContext returns the currently active repository context.
Expand Down Expand Up @@ -94,20 +92,11 @@ func (cd *ComponentDescriptor) GetResourceIndexByIdentity(id v1.Identity) int {

// GetResourceByJSONScheme returns resources that match the given selectors.
func (cd *ComponentDescriptor) GetResourceByJSONScheme(src interface{}) (Resources, error) {
sel, err := selector.NewJSONSchemaSelectorFromGoStruct(src)
sel, err := selectors.NewJSONSchemaSelectorFromGoStruct(src)
if err != nil {
return nil, err
}
return cd.GetResourcesByIdentitySelectors(sel)
}

// GetResourceByDefaultSelector returns resources that match the given selectors.
func (cd *ComponentDescriptor) GetResourceByDefaultSelector(sel interface{}) (Resources, error) {
identitySelector, err := selector.ParseDefaultSelector(sel)
if err != nil {
return nil, fmt.Errorf("unable to parse selector: %w", err)
}
return cd.GetResourcesByIdentitySelectors(identitySelector)
return cd.SelectResources(sel)
}

// GetResourceIndex returns the index of a given resource.
Expand Down
91 changes: 0 additions & 91 deletions api/ocm/compdesc/op.go

This file was deleted.

Loading

0 comments on commit 3b7e1cd

Please sign in to comment.