diff --git a/pkg/components/components_test.go b/pkg/components/components_test.go index e20b0a810..4af21806c 100644 --- a/pkg/components/components_test.go +++ b/pkg/components/components_test.go @@ -171,8 +171,6 @@ var _ = Describe("facade implementation compatibility tests", func() { Expect(oRaForCnudieCv.GetComponentDescriptor()).To(Equal(oRaForOcmCv.GetComponentDescriptor())) - Expect(oRaForCnudieCv.GetRepositoryContext()).To(Equal(oRaForOcmCv.GetRepositoryContext())) - Expect(oRaForCnudieCv.GetComponentReferences()).To(Equal(oRaForOcmCv.GetComponentReferences())) Expect(oRaForCnudieCv.GetComponentReference(REFERENCED_COMPONENT_NAME)).To(Equal(oRaForOcmCv.GetComponentReference(REFERENCED_COMPONENT_NAME))) diff --git a/pkg/components/model/componentversion.go b/pkg/components/model/componentversion.go index 41ee144fb..150250436 100644 --- a/pkg/components/model/componentversion.go +++ b/pkg/components/model/componentversion.go @@ -25,14 +25,6 @@ type ComponentVersion interface { // Cannot be nil GetComponentDescriptor() *types.ComponentDescriptor - // GetRepositoryContext return the current repository context, - // i.e. the last entry in the list of repository contexts. - // TODO: Remove this method - // ocm-spec specifies that the Repository Context is supposed to be informational about the transport history. The - // spec does not mandate to set this property and therefore, we should not program against it. - // Cannot be nil as component versions without repository context cannot be created (for now). - GetRepositoryContext() *types.UnstructuredTypedObject - // GetComponentReferences returns the list of component references of the present component version. // (not transitively; only the references of the present component version) GetComponentReferences() []types.ComponentReference diff --git a/pkg/components/model/componentversion_refs.go b/pkg/components/model/componentversion_refs.go index b3f608d6b..e495e6224 100644 --- a/pkg/components/model/componentversion_refs.go +++ b/pkg/components/model/componentversion_refs.go @@ -6,7 +6,6 @@ package model import ( "context" - "errors" "fmt" "github.com/gardener/landscaper/controller-utils/pkg/logging" @@ -75,11 +74,6 @@ func getTransitiveComponentReferencesRecursively(ctx context.Context, } cds[cid] = cd - cdRepositoryContext := cd.GetRepositoryContext() - if cdRepositoryContext == nil { - return errors.New("component descriptor must at least contain one repository context with a base url") - } - cdComponentReferences := cd.GetComponentReferences() for _, compRef := range cdComponentReferences { diff --git a/pkg/components/ocmlib/componentversion.go b/pkg/components/ocmlib/componentversion.go index a62a11916..85f51690c 100644 --- a/pkg/components/ocmlib/componentversion.go +++ b/pkg/components/ocmlib/componentversion.go @@ -42,10 +42,6 @@ func (c *ComponentVersion) GetComponentDescriptor() *types.ComponentDescriptor { return &c.componentDescriptorV2 } -func (c *ComponentVersion) GetRepositoryContext() *types.UnstructuredTypedObject { - return c.componentDescriptorV2.GetEffectiveRepositoryContext() -} - func (c *ComponentVersion) GetComponentReferences() []types.ComponentReference { return c.componentDescriptorV2.ComponentReferences } diff --git a/pkg/components/testutils/componentversion.go b/pkg/components/testutils/componentversion.go index 1374815f0..c66a15585 100644 --- a/pkg/components/testutils/componentversion.go +++ b/pkg/components/testutils/componentversion.go @@ -50,14 +50,6 @@ func (t *TestComponentVersion) GetComponentDescriptor() *types.ComponentDescript return t.componentDescriptor } -func (t *TestComponentVersion) GetRepositoryContext() *types.UnstructuredTypedObject { - context := t.componentDescriptor.GetEffectiveRepositoryContext() - if context == nil { - return nil - } - return context -} - func (t *TestComponentVersion) GetComponentReferences() []types.ComponentReference { return t.componentDescriptor.ComponentReferences } diff --git a/pkg/landscaper/blueprints/resolve.go b/pkg/landscaper/blueprints/resolve.go index 08479679e..c9bf8b3d7 100644 --- a/pkg/landscaper/blueprints/resolve.go +++ b/pkg/landscaper/blueprints/resolve.go @@ -141,9 +141,6 @@ func Resolve( if cdRef == nil { return nil, fmt.Errorf("no component descriptor reference defined") } - if cdRef.RepositoryContext == nil { - return nil, fmt.Errorf("no respository context defined") - } if registryAccess == nil { return nil, fmt.Errorf("did not get a working component descriptor resolver") } diff --git a/pkg/landscaper/installations/context.go b/pkg/landscaper/installations/context.go index 3bc249321..bb22214f3 100644 --- a/pkg/landscaper/installations/context.go +++ b/pkg/landscaper/installations/context.go @@ -9,19 +9,18 @@ import ( "errors" "fmt" - "github.com/gardener/landscaper/pkg/utils" - + cdv2 "github.com/gardener/component-spec/bindings-go/apis/v2" apierrors "k8s.io/apimachinery/pkg/api/errors" "sigs.k8s.io/controller-runtime/pkg/client" + lsv1alpha1 "github.com/gardener/landscaper/apis/core/v1alpha1" + lsv1alpha1helper "github.com/gardener/landscaper/apis/core/v1alpha1/helper" lserrors "github.com/gardener/landscaper/apis/errors" kutil "github.com/gardener/landscaper/controller-utils/pkg/kubernetes" "github.com/gardener/landscaper/controller-utils/pkg/logging" - "github.com/gardener/landscaper/pkg/components/model/componentoverwrites" - - lsv1alpha1 "github.com/gardener/landscaper/apis/core/v1alpha1" - lsv1alpha1helper "github.com/gardener/landscaper/apis/core/v1alpha1/helper" lc "github.com/gardener/landscaper/controller-utils/pkg/logging/constants" + "github.com/gardener/landscaper/pkg/components/model/componentoverwrites" + "github.com/gardener/landscaper/pkg/utils" "github.com/gardener/landscaper/pkg/utils/read_write_layer" ) @@ -133,6 +132,9 @@ type ExternalContext struct { ComponentName string // ComponentVersion defines the version of the component. ComponentVersion string + // ResultingRepositoryContext is the repository context, taking into account the repository context in the + // installation, the repository context in the context resource, and the overwriter. + ResultingRepositoryContext *cdv2.UnstructuredTypedObject // Overwriter is the component version overwriter used for this installation. Overwriter componentoverwrites.Overwriter } @@ -143,7 +145,7 @@ func (c *ExternalContext) ComponentDescriptorRef() *lsv1alpha1.ComponentDescript return nil } ref := &lsv1alpha1.ComponentDescriptorReference{} - ref.RepositoryContext = c.RepositoryContext + ref.RepositoryContext = c.ResultingRepositoryContext ref.ComponentName = c.ComponentName ref.Version = c.ComponentVersion return ref @@ -232,15 +234,6 @@ func GetParent(ctx context.Context, kubeClient client.Client, inst *lsv1alpha1.I return parent, nil } -// GetInstallationContextName returns the name of the context of an installation. -// The context name is basically the name of the parent component. -func GetInstallationContextName(inst *lsv1alpha1.Installation) string { - if IsRootInstallation(inst) { - return "" - } - return lsv1alpha1helper.DataObjectSourceFromInstallationName(GetParentInstallationName(inst)) -} - // IsRoot returns if the current component is a root component func (o *Operation) IsRoot() bool { return o.Context().Parent == nil @@ -287,6 +280,9 @@ func GetExternalContext(ctx context.Context, kubeClient client.Client, inst *lsv }, nil } + // Avoid that component overwrite modifies the installation + cdRef = cdRef.DeepCopy() + cond, err := ApplyComponentOverwrite(ctx, inst, overwriter, lsCtx, cdRef) if err != nil { return ExternalContext{}, lserrors.NewWrappedError(err, @@ -295,15 +291,12 @@ func GetExternalContext(ctx context.Context, kubeClient client.Client, inst *lsv if cond != nil { inst.Status.Conditions = lsv1alpha1helper.MergeConditions(inst.Status.Conditions, *cond) } - if cdRef.RepositoryContext == nil { - return ExternalContext{}, MissingRepositoryContextError - } - lsCtx.RepositoryContext = cdRef.RepositoryContext return ExternalContext{ - Context: *lsCtx, - ComponentName: cdRef.ComponentName, - ComponentVersion: cdRef.Version, - Overwriter: overwriter, + Context: *lsCtx, + ComponentName: cdRef.ComponentName, + ComponentVersion: cdRef.Version, + ResultingRepositoryContext: cdRef.RepositoryContext, + Overwriter: overwriter, }, nil } diff --git a/pkg/landscaper/installations/context_test.go b/pkg/landscaper/installations/context_test.go index a3ab3c3d4..ac4ca2bd7 100644 --- a/pkg/landscaper/installations/context_test.go +++ b/pkg/landscaper/installations/context_test.go @@ -7,26 +7,22 @@ package installations_test import ( "context" - testutils2 "github.com/gardener/landscaper/pkg/components/testutils" - - "github.com/open-component-model/ocm/pkg/contexts/datacontext" - "github.com/open-component-model/ocm/pkg/contexts/ocm" - - "github.com/gardener/landscaper/controller-utils/pkg/logging" - - "github.com/gardener/landscaper/apis/config" - cdv2 "github.com/gardener/component-spec/bindings-go/apis/v2" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gstruct" + "github.com/open-component-model/ocm/pkg/contexts/datacontext" + "github.com/open-component-model/ocm/pkg/contexts/ocm" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/gardener/landscaper/apis/config" lsv1alpha1 "github.com/gardener/landscaper/apis/core/v1alpha1" + "github.com/gardener/landscaper/controller-utils/pkg/logging" "github.com/gardener/landscaper/pkg/api" "github.com/gardener/landscaper/pkg/components/model/componentoverwrites" "github.com/gardener/landscaper/pkg/components/registries" + testutils2 "github.com/gardener/landscaper/pkg/components/testutils" "github.com/gardener/landscaper/pkg/landscaper/installations" lsoperation "github.com/gardener/landscaper/pkg/landscaper/operation" testutils "github.com/gardener/landscaper/test/utils" @@ -175,29 +171,7 @@ var _ = Describe("Context", func() { extCtx, err := installations.GetExternalContext(ctx, testenv.Client, inst) Expect(err).ToNot(HaveOccurred()) Expect(inst.Spec.ComponentDescriptor.Reference.RepositoryContext.Raw).To(MatchJSON(repoCtx.Raw)) - Expect(extCtx.RepositoryContext.Raw).To(MatchJSON(repoCtx.Raw)) - }) - - It("should throw an error if a component name and version is defined but no repository context", func() { - state, err := testenv.InitState(ctx) - Expect(err).ToNot(HaveOccurred()) - - lsCtx := &lsv1alpha1.Context{} - lsCtx.Name = "test" - lsCtx.Namespace = state.Namespace - Expect(state.Create(ctx, lsCtx)).To(Succeed()) - - inst := &lsv1alpha1.Installation{} - inst.Namespace = state.Namespace - inst.Spec.Context = "test" - inst.Spec.ComponentDescriptor = &lsv1alpha1.ComponentDescriptorDefinition{ - Reference: &lsv1alpha1.ComponentDescriptorReference{ - ComponentName: "abc", - }, - } - - _, err = installations.GetExternalContext(ctx, testenv.Client, inst) - Expect(err).To(HaveOccurred()) + Expect(extCtx.ResultingRepositoryContext.Raw).To(MatchJSON(repoCtx.Raw)) }) Context("ComponentVersionOverwrite", func() { @@ -243,8 +217,10 @@ var _ = Describe("Context", func() { extCtx, err := installations.GetExternalContext(ctx, testenv.Client, inst) Expect(err).ToNot(HaveOccurred()) - Expect(cdv2.UnstructuredTypesEqual(inst.Spec.ComponentDescriptor.Reference.RepositoryContext, repoCtx)).To(BeTrue()) - Expect(cdv2.UnstructuredTypesEqual(extCtx.RepositoryContext, repoCtx)).To(BeTrue()) + // the installation should remain unchanged + Expect(cdv2.UnstructuredTypesEqual(inst.Spec.ComponentDescriptor.Reference.RepositoryContext, testutils.ExampleRepositoryContext())).To(BeTrue()) + // the resulting repository context should contain the result of the overwriting + Expect(cdv2.UnstructuredTypesEqual(extCtx.ResultingRepositoryContext, repoCtx)).To(BeTrue()) }) It("should overwrite a repository context defined by the external context", func() { @@ -288,8 +264,10 @@ var _ = Describe("Context", func() { extCtx, err := installations.GetExternalContext(ctx, testenv.Client, inst) Expect(err).ToNot(HaveOccurred()) - Expect(cdv2.UnstructuredTypesEqual(inst.Spec.ComponentDescriptor.Reference.RepositoryContext, repoCtx)).To(BeTrue()) - Expect(cdv2.UnstructuredTypesEqual(extCtx.RepositoryContext, repoCtx)).To(BeTrue()) + // the installation should remain unchanged + Expect(inst.Spec.ComponentDescriptor.Reference.RepositoryContext).To(BeNil()) + // the resulting repository context should contain the result of the overwriting + Expect(cdv2.UnstructuredTypesEqual(extCtx.ResultingRepositoryContext, repoCtx)).To(BeTrue()) }) }) @@ -315,20 +293,16 @@ var _ = Describe("Context", func() { Context("InjectComponentDescriptorRef", func() { It("should inject the component ref", func() { extCtx := installations.ExternalContext{ - Context: lsv1alpha1.Context{ - ContextConfiguration: lsv1alpha1.ContextConfiguration{ - RepositoryContext: testutils.ExampleRepositoryContext(), - }, - }, - ComponentName: "example.com/a", - ComponentVersion: "0.0.1", + ResultingRepositoryContext: testutils.ExampleRepositoryContext(), + ComponentName: "example.com/a", + ComponentVersion: "0.0.1", } inst := &lsv1alpha1.Installation{} extCtx.InjectComponentDescriptorRef(inst) Expect(inst.Spec.ComponentDescriptor).ToNot(BeNil()) Expect(inst.Spec.ComponentDescriptor.Reference).To(gstruct.PointTo(gstruct.MatchAllFields(gstruct.Fields{ - "RepositoryContext": Equal(extCtx.RepositoryContext), + "RepositoryContext": Equal(extCtx.ResultingRepositoryContext), "ComponentName": Equal("example.com/a"), "Version": Equal("0.0.1"), }))) @@ -336,13 +310,9 @@ var _ = Describe("Context", func() { It("should overwrite the component ref", func() { extCtx := installations.ExternalContext{ - Context: lsv1alpha1.Context{ - ContextConfiguration: lsv1alpha1.ContextConfiguration{ - RepositoryContext: testutils.ExampleRepositoryContext(), - }, - }, - ComponentName: "example.com/a", - ComponentVersion: "0.0.1", + ResultingRepositoryContext: testutils.ExampleRepositoryContext(), + ComponentName: "example.com/a", + ComponentVersion: "0.0.1", } inst := &lsv1alpha1.Installation{} @@ -355,7 +325,7 @@ var _ = Describe("Context", func() { extCtx.InjectComponentDescriptorRef(inst) Expect(inst.Spec.ComponentDescriptor).ToNot(BeNil()) Expect(inst.Spec.ComponentDescriptor.Reference).To(gstruct.PointTo(gstruct.MatchAllFields(gstruct.Fields{ - "RepositoryContext": Equal(extCtx.RepositoryContext), + "RepositoryContext": Equal(extCtx.ResultingRepositoryContext), "ComponentName": Equal("example.com/a"), "Version": Equal("0.0.1"), }))) diff --git a/pkg/landscaper/installations/executions/operation.go b/pkg/landscaper/installations/executions/operation.go index c31cd5268..4cfafb842 100644 --- a/pkg/landscaper/installations/executions/operation.go +++ b/pkg/landscaper/installations/executions/operation.go @@ -71,7 +71,7 @@ func (o *ExecutionOperation) RenderDeployItemTemplates(ctx context.Context, executions, err := tmpl.TemplateDeployExecutions( template.NewDeployExecutionOptions( template.NewBlueprintExecutionOptions( - o.Context().External.InjectComponentDescriptorRef(inst.GetInstallation()), + o.Context().External.InjectComponentDescriptorRef(inst.GetInstallation().DeepCopy()), inst.GetBlueprint(), o.ComponentVersion, o.ResolvedComponentDescriptorList, diff --git a/pkg/landscaper/installations/executions/operation_test.go b/pkg/landscaper/installations/executions/operation_test.go index 39ffdddac..7decb369f 100644 --- a/pkg/landscaper/installations/executions/operation_test.go +++ b/pkg/landscaper/installations/executions/operation_test.go @@ -83,13 +83,9 @@ var _ = Describe("Execution Operation", func() { Name: "default", Parent: nil, External: installations.ExternalContext{ - Context: lsv1alpha1.Context{ - ContextConfiguration: lsv1alpha1.ContextConfiguration{ - RepositoryContext: &repositoryContext, - }, - }, - ComponentName: "example.com/root", - ComponentVersion: "v1.0.0", + ResultingRepositoryContext: &repositoryContext, + ComponentName: "example.com/root", + ComponentVersion: "v1.0.0", }, } diff --git a/pkg/landscaper/installations/imports/constructor.go b/pkg/landscaper/installations/imports/constructor.go index ad54c18ba..e9a9cb475 100644 --- a/pkg/landscaper/installations/imports/constructor.go +++ b/pkg/landscaper/installations/imports/constructor.go @@ -354,7 +354,7 @@ func (c *Constructor) RenderImportExecutions() error { spiff.New(templateStateHandler, targetResolver)) errors, bindings, err := tmpl.TemplateImportExecutions( template.NewBlueprintExecutionOptions( - c.Operation.Context().External.InjectComponentDescriptorRef(c.Operation.Inst.GetInstallation()), + c.Operation.Context().External.InjectComponentDescriptorRef(c.Operation.Inst.GetInstallation().DeepCopy()), c.Operation.Inst.GetBlueprint(), c.Operation.ComponentVersion, c.Operation.ResolvedComponentDescriptorList, diff --git a/pkg/landscaper/installations/subinstallations/helper.go b/pkg/landscaper/installations/subinstallations/helper.go index 8187f65b4..7f27953ff 100644 --- a/pkg/landscaper/installations/subinstallations/helper.go +++ b/pkg/landscaper/installations/subinstallations/helper.go @@ -49,6 +49,7 @@ func GetBlueprintDefinitionFromInstallationTemplate( } // resolve component descriptor list + // TODO: why is the overwriter not relevant here? _, res, err := uri.Get(componentVersion, repositoryContext) if err != nil { return nil, nil, fmt.Errorf("unable to resolve blueprint ref in component descriptor %s: %w", componentVersion.GetName(), err) @@ -85,7 +86,16 @@ func GetBlueprintDefinitionFromInstallationTemplate( if cdDef.Inline == nil { cdDef = &lsv1alpha1.ComponentDescriptorDefinition{ - Reference: subInstCdRef, + Reference: &lsv1alpha1.ComponentDescriptorReference{ + ComponentName: subInstCdRef.ComponentName, + Version: subInstCdRef.Version, + }, + } + + // Usually, the repository context of the parent installation is specified in the context resource or ocm config. + // Only if it is specified directly in the parent installation, we specify the same repository context in the subinstallation. + if inst.Spec.ComponentDescriptor != nil && inst.Spec.ComponentDescriptor.Reference != nil { + cdDef.Reference.RepositoryContext = inst.Spec.ComponentDescriptor.Reference.RepositoryContext } } diff --git a/pkg/landscaper/installations/subinstallations/subinstallations.go b/pkg/landscaper/installations/subinstallations/subinstallations.go index 39773dd59..67837aefd 100644 --- a/pkg/landscaper/installations/subinstallations/subinstallations.go +++ b/pkg/landscaper/installations/subinstallations/subinstallations.go @@ -274,7 +274,7 @@ func (o *Operation) createOrUpdateNewInstallation(ctx context.Context, subBlueprint, subCdDef, err := GetBlueprintDefinitionFromInstallationTemplate(inst, subInstTmpl, o.ComponentVersion, - o.Context().External.RepositoryContext, + o.Context().External.ResultingRepositoryContext, o.Context().External.Overwriter) if err != nil { return nil, err diff --git a/pkg/landscaper/installations/subinstallations/subinstallations_test.go b/pkg/landscaper/installations/subinstallations/subinstallations_test.go index d03834be7..425ac54ae 100644 --- a/pkg/landscaper/installations/subinstallations/subinstallations_test.go +++ b/pkg/landscaper/installations/subinstallations/subinstallations_test.go @@ -172,8 +172,9 @@ var _ = Describe("SubInstallation", func() { Expect(subinsts[0].Spec.ComponentDescriptor.Reference.ComponentName).To(Equal("example.com/root")) Expect(subinsts[0].Spec.ComponentDescriptor.Reference.Version).To(Equal("1.0.0")) - Expect(subinsts[0].Spec.ComponentDescriptor.Reference.RepositoryContext.Object["baseUrl"]).To(Equal("./testdata/registry")) - Expect(subinsts[0].Spec.ComponentDescriptor.Reference.RepositoryContext.Object["type"]).To(Equal("ociRegistry")) + // expecting the same repository context as in the root installation + Expect(subinsts[0].Spec.ComponentDescriptor.Reference.RepositoryContext.Object["baseUrl"]).To(Equal("../testdata/registry")) + Expect(subinsts[0].Spec.ComponentDescriptor.Reference.RepositoryContext.Object["type"]).To(Equal("local")) Expect(subinsts[0].Spec.Blueprint.Reference.ResourceName).To(Equal("def-1")) diff --git a/pkg/landscaper/jsonschema/reference.go b/pkg/landscaper/jsonschema/reference.go index 9334f51c9..90e7746e3 100644 --- a/pkg/landscaper/jsonschema/reference.go +++ b/pkg/landscaper/jsonschema/reference.go @@ -204,15 +204,14 @@ func (rr *ReferenceResolver) handleComponentDescriptorReference(uri *url.URL, cu if rr.RegistryAccess == nil { return nil, errors.New("no component reference resolver defined to resolve the ref") } + if rr.RepositoryContext == nil { + return nil, errors.New("no repository context defined to resolve the ref") + } cdUri, err := cdutils.ParseURI(uri.String()) if err != nil { return nil, err } - repositoryContext := rr.RepositoryContext - if repositoryContext == nil { - repositoryContext = rr.ComponentVersion.GetRepositoryContext() - } - cd, resource, err := cdUri.GetResource(rr.ComponentVersion, repositoryContext) + cd, resource, err := cdUri.GetResource(rr.ComponentVersion, rr.RepositoryContext) if err != nil { return nil, err } diff --git a/pkg/landscaper/registry/components/cdutils/uri.go b/pkg/landscaper/registry/components/cdutils/uri.go index f98f33e10..8684bcafd 100644 --- a/pkg/landscaper/registry/components/cdutils/uri.go +++ b/pkg/landscaper/registry/components/cdutils/uri.go @@ -132,13 +132,11 @@ func (u *URI) Get(cd model.ComponentVersion, repositoryContext *types.Unstructur func (u *URI) GetComponent(cd model.ComponentVersion, repositoryContext *types.UnstructuredTypedObject, overwriter componentoverwrites.Overwriter) (model.ComponentVersion, *lsv1alpha1.ComponentDescriptorReference, error) { - cdRepositoryContext := cd.GetRepositoryContext() - var ( ctx = context.Background() component = cd cdRef = &lsv1alpha1.ComponentDescriptorReference{ - RepositoryContext: cdRepositoryContext, + RepositoryContext: repositoryContext, ComponentName: cd.GetName(), Version: cd.GetVersion(), } diff --git a/pkg/landscaper/registry/components/cdutils/uri_test.go b/pkg/landscaper/registry/components/cdutils/uri_test.go index fa9cefaa7..b23cec6d5 100644 --- a/pkg/landscaper/registry/components/cdutils/uri_test.go +++ b/pkg/landscaper/registry/components/cdutils/uri_test.go @@ -154,8 +154,7 @@ var _ = Describe("URI", func() { It("should resolve a direct local resource", func() { uri, err := cdutils.ParseURI("cd://resources/r1") Expect(err).ToNot(HaveOccurred()) - repoContext := componentVersion.GetRepositoryContext() - kind, res, err := uri.Get(componentVersion, repoContext) + kind, res, err := uri.Get(componentVersion, repositoryContext) Expect(err).ToNot(HaveOccurred()) Expect(kind).To(Equal(lsv1alpha1.ResourceKind)) resource, ok := res.(model.Resource) @@ -171,8 +170,6 @@ var _ = Describe("URI", func() { It("should return an error if a resource is unknown", func() { uri, err := cdutils.ParseURI("cd://resources/r3") Expect(err).ToNot(HaveOccurred()) - //repoContext, err := componentVersion.GetRepositoryContext() - //Expect(err).NotTo(HaveOccurred()) _, _, err = uri.Get(componentVersion, repositorySpec) Expect(err).To(HaveOccurred()) }) @@ -180,8 +177,6 @@ var _ = Describe("URI", func() { It("should return an error if a keyword is unknown", func() { uri, err := cdutils.ParseURI("cd://fail/r1") Expect(err).ToNot(HaveOccurred()) - //repoContext, err := componentVersion.GetRepositoryContext() - //Expect(err).NotTo(HaveOccurred()) _, _, err = uri.Get(componentVersion, repositorySpec) Expect(err).To(HaveOccurred()) }) @@ -189,8 +184,6 @@ var _ = Describe("URI", func() { It("should resolve a component reference", func() { uri, err := cdutils.ParseURI("cd://componentReferences/comp1") Expect(err).ToNot(HaveOccurred()) - //repoContext, err := componentVersion.GetRepositoryContext() - //Expect(err).NotTo(HaveOccurred()) kind, res, err := uri.Get(componentVersion, repositorySpec) Expect(err).ToNot(HaveOccurred()) Expect(kind).To(Equal(lsv1alpha1.ComponentResourceKind)) @@ -208,8 +201,6 @@ var _ = Describe("URI", func() { It("should resolve a resource in a component reference", func() { uri, err := cdutils.ParseURI("cd://componentReferences/comp1/resources/r2") Expect(err).ToNot(HaveOccurred()) - //repoContext, err := componentVersion.GetRepositoryContext() - //Expect(err).NotTo(HaveOccurred()) kind, res, err := uri.Get(componentVersion, repositorySpec) Expect(err).ToNot(HaveOccurred()) Expect(kind).To(Equal(lsv1alpha1.ResourceKind)) diff --git a/pkg/utils/landscaper/blueprint.go b/pkg/utils/landscaper/blueprint.go index ddf75a7ea..bd60b3c2c 100644 --- a/pkg/utils/landscaper/blueprint.go +++ b/pkg/utils/landscaper/blueprint.go @@ -468,7 +468,6 @@ func (r *BlueprintRenderer) validateImports(input *ResolvedInstallation, imports // The priority is as following: // 1. explicitly user defined repository context // 2. repository context defined in the installation -// 3. effective repository context defined in the component descriptor. func (r *BlueprintRenderer) getRepositoryContext(input *ResolvedInstallation) (*types.UnstructuredTypedObject, error) { if r.repositoryContext != nil { return r.repositoryContext, nil @@ -483,12 +482,6 @@ func (r *BlueprintRenderer) getRepositoryContext(input *ResolvedInstallation) (* } } - if input.ComponentVersion != nil { - repositoryContext := input.ComponentVersion.GetRepositoryContext() - - return repositoryContext, nil - } - return nil, nil }