diff --git a/api/v1alpha1/clusterextension_types.go b/api/v1alpha1/clusterextension_types.go index b763cb60a..0d7f0b83d 100644 --- a/api/v1alpha1/clusterextension_types.go +++ b/api/v1alpha1/clusterextension_types.go @@ -122,9 +122,9 @@ func init() { // ClusterExtensionStatus defines the observed state of ClusterExtension type ClusterExtensionStatus struct { // +optional - InstalledBundleResource string `json:"installedBundleResource,omitempty"` + InstalledBundle *BundleMetadata `json:"installedBundle,omitempty"` // +optional - ResolvedBundleResource string `json:"resolvedBundleResource,omitempty"` + ResolvedBundle *BundleMetadata `json:"resolvedBundle,omitempty"` // +patchMergeKey=type // +patchStrategy=merge diff --git a/api/v1alpha1/extension_types.go b/api/v1alpha1/extension_types.go index 4da6e00b9..24c5b2f69 100644 --- a/api/v1alpha1/extension_types.go +++ b/api/v1alpha1/extension_types.go @@ -90,9 +90,9 @@ type ExtensionStatus struct { Paused bool `json:"paused"` // +optional - InstalledBundleResource string `json:"installedBundleResource,omitempty"` + InstalledBundle *BundleMetadata `json:"installedBundle,omitempty"` // +optional - ResolvedBundleResource string `json:"resolvedBundleResource,omitempty"` + ResolvedBundle *BundleMetadata `json:"resolvedBundle,omitempty"` // +patchMergeKey=type // +patchStrategy=merge @@ -101,6 +101,11 @@ type ExtensionStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` } +type BundleMetadata struct { + Name string `json:"name"` + Version string `json:"version"` +} + //+kubebuilder:object:root=true //+kubebuilder:subresource:status //+kubebuilder:printcolumn:name="Paused",type=string,JSONPath=`.status.paused`,description="The current reconciliation state of this extension" diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index fbebacf2d..6b29fd81f 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -26,6 +26,21 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BundleMetadata) DeepCopyInto(out *BundleMetadata) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BundleMetadata. +func (in *BundleMetadata) DeepCopy() *BundleMetadata { + if in == nil { + return nil + } + out := new(BundleMetadata) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterExtension) DeepCopyInto(out *ClusterExtension) { *out = *in @@ -108,6 +123,16 @@ func (in *ClusterExtensionSpec) DeepCopy() *ClusterExtensionSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterExtensionStatus) DeepCopyInto(out *ClusterExtensionStatus) { *out = *in + if in.InstalledBundle != nil { + in, out := &in.InstalledBundle, &out.InstalledBundle + *out = new(BundleMetadata) + **out = **in + } + if in.ResolvedBundle != nil { + in, out := &in.ResolvedBundle, &out.ResolvedBundle + *out = new(BundleMetadata) + **out = **in + } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]v1.Condition, len(*in)) @@ -240,6 +265,16 @@ func (in *ExtensionSpec) DeepCopy() *ExtensionSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ExtensionStatus) DeepCopyInto(out *ExtensionStatus) { *out = *in + if in.InstalledBundle != nil { + in, out := &in.InstalledBundle, &out.InstalledBundle + *out = new(BundleMetadata) + **out = **in + } + if in.ResolvedBundle != nil { + in, out := &in.ResolvedBundle, &out.ResolvedBundle + *out = new(BundleMetadata) + **out = **in + } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]v1.Condition, len(*in)) diff --git a/config/crd/bases/olm.operatorframework.io_clusterextensions.yaml b/config/crd/bases/olm.operatorframework.io_clusterextensions.yaml index 6e649ad07..792e99759 100644 --- a/config/crd/bases/olm.operatorframework.io_clusterextensions.yaml +++ b/config/crd/bases/olm.operatorframework.io_clusterextensions.yaml @@ -144,10 +144,26 @@ spec: x-kubernetes-list-map-keys: - type x-kubernetes-list-type: map - installedBundleResource: - type: string - resolvedBundleResource: - type: string + installedBundle: + properties: + name: + type: string + version: + type: string + required: + - name + - version + type: object + resolvedBundle: + properties: + name: + type: string + version: + type: string + required: + - name + - version + type: object type: object type: object served: true diff --git a/config/crd/bases/olm.operatorframework.io_extensions.yaml b/config/crd/bases/olm.operatorframework.io_extensions.yaml index b6394dc0b..199845e56 100644 --- a/config/crd/bases/olm.operatorframework.io_extensions.yaml +++ b/config/crd/bases/olm.operatorframework.io_extensions.yaml @@ -180,14 +180,30 @@ spec: x-kubernetes-list-map-keys: - type x-kubernetes-list-type: map - installedBundleResource: - type: string + installedBundle: + properties: + name: + type: string + version: + type: string + required: + - name + - version + type: object paused: description: paused indicates the current reconciliation state of this extension type: boolean - resolvedBundleResource: - type: string + resolvedBundle: + properties: + name: + type: string + version: + type: string + required: + - name + - version + type: object required: - paused type: object diff --git a/internal/controllers/clusterextension_controller.go b/internal/controllers/clusterextension_controller.go index d79a0437b..b1900a834 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -118,9 +118,9 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp // gather vars for resolution vars, err := r.variables(ctx) if err != nil { - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionUnknown(&ext.Status.Conditions, "installation has not been attempted due to failure to gather data for resolution", ext.GetGeneration()) - ext.Status.ResolvedBundleResource = "" + ext.Status.ResolvedBundle = nil setResolvedStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted due to failure to gather data for resolution", ext.GetGeneration()) @@ -130,9 +130,9 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp // run resolution selection, err := r.Resolver.Solve(vars) if err != nil { - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionUnknown(&ext.Status.Conditions, "installation has not been attempted as resolution failed", ext.GetGeneration()) - ext.Status.ResolvedBundleResource = "" + ext.Status.ResolvedBundle = nil setResolvedStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as resolution failed", ext.GetGeneration()) @@ -143,9 +143,9 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp // ClusterExtension's desired package name. bundle, err := r.bundleFromSolution(selection, ext.Spec.PackageName) if err != nil { - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionUnknown(&ext.Status.Conditions, "installation has not been attempted as resolution failed", ext.GetGeneration()) - ext.Status.ResolvedBundleResource = "" + ext.Status.ResolvedBundle = nil setResolvedStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as resolution failed", ext.GetGeneration()) @@ -153,7 +153,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp } // Now we can set the Resolved Condition, and the resolvedBundleSource field to the bundle.Image value. - ext.Status.ResolvedBundleResource = bundle.Image + ext.Status.ResolvedBundle = bundleMetadataFor(bundle) setResolvedStatusConditionSuccess(&ext.Status.Conditions, fmt.Sprintf("resolved to %q", bundle.Image), ext.GetGeneration()) // TODO: Question - Should we set the deprecation statuses after we have successfully resolved instead of after a successful installation? @@ -175,7 +175,7 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp dep := r.GenerateExpectedBundleDeployment(*ext, bundle.Image, bundleProvisioner) if err := r.ensureBundleDeployment(ctx, dep); err != nil { // originally Reason: ocv1alpha1.ReasonInstallationFailed - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration()) return ctrl.Result{}, err @@ -185,15 +185,15 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp existingTypedBundleDeployment := &rukpakv1alpha2.BundleDeployment{} if err := runtime.DefaultUnstructuredConverter.FromUnstructured(dep.UnstructuredContent(), existingTypedBundleDeployment); err != nil { // originally Reason: ocv1alpha1.ReasonInstallationStatusUnknown - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionUnknown(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration()) return ctrl.Result{}, err } - // Let's set the proper Installed condition and InstalledBundleResource field based on the + // Let's set the proper Installed condition and InstalledBundle field based on the // existing BundleDeployment object status. - mapBDStatusToInstalledCondition(existingTypedBundleDeployment, ext) + mapBDStatusToInstalledCondition(existingTypedBundleDeployment, ext, bundle) SetDeprecationStatus(ext, bundle) @@ -218,16 +218,16 @@ func (r *ClusterExtensionReconciler) variables(ctx context.Context) ([]deppy.Var return GenerateVariables(allBundles, clusterExtensionList.Items, bundleDeploymentList.Items) } -func mapBDStatusToInstalledCondition(existingTypedBundleDeployment *rukpakv1alpha2.BundleDeployment, ext *ocv1alpha1.ClusterExtension) { +func mapBDStatusToInstalledCondition(existingTypedBundleDeployment *rukpakv1alpha2.BundleDeployment, ext *ocv1alpha1.ClusterExtension, bundle *catalogmetadata.Bundle) { bundleDeploymentReady := apimeta.FindStatusCondition(existingTypedBundleDeployment.Status.Conditions, rukpakv1alpha2.TypeInstalled) if bundleDeploymentReady == nil { - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionUnknown(&ext.Status.Conditions, "bundledeployment status is unknown", ext.GetGeneration()) return } if bundleDeploymentReady.Status != metav1.ConditionTrue { - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionFailed( &ext.Status.Conditions, fmt.Sprintf("bundledeployment not ready: %s", bundleDeploymentReady.Message), @@ -236,25 +236,25 @@ func mapBDStatusToInstalledCondition(existingTypedBundleDeployment *rukpakv1alph return } + installedBundle := bundleMetadataFor(bundle) bundleDeploymentSource := existingTypedBundleDeployment.Spec.Source switch bundleDeploymentSource.Type { case rukpakv1alpha2.SourceTypeImage: - ext.Status.InstalledBundleResource = bundleDeploymentSource.Image.Ref + ext.Status.InstalledBundle = installedBundle setInstalledStatusConditionSuccess( &ext.Status.Conditions, fmt.Sprintf("installed from %q", bundleDeploymentSource.Image.Ref), ext.GetGeneration(), ) case rukpakv1alpha2.SourceTypeGit: + ext.Status.InstalledBundle = installedBundle resource := bundleDeploymentSource.Git.Repository + "@" + bundleDeploymentSource.Git.Ref.Commit - ext.Status.InstalledBundleResource = resource setInstalledStatusConditionSuccess( &ext.Status.Conditions, fmt.Sprintf("installed from %q", resource), ext.GetGeneration(), ) default: - ext.Status.InstalledBundleResource = "" setInstalledStatusConditionUnknown( &ext.Status.Conditions, fmt.Sprintf("unknown bundledeployment source type %q", bundleDeploymentSource.Type), diff --git a/internal/controllers/clusterextension_controller_test.go b/internal/controllers/clusterextension_controller_test.go index 08c208c2e..d32e98e7a 100644 --- a/internal/controllers/clusterextension_controller_test.go +++ b/internal/controllers/clusterextension_controller_test.go @@ -66,8 +66,8 @@ func TestClusterExtensionNonExistentPackage(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Empty(t, clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Empty(t, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -108,8 +108,8 @@ func TestClusterExtensionNonExistentVersion(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Empty(t, clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Empty(t, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -159,11 +159,11 @@ func TestClusterExtensionBundleDeploymentDoesNotExist(t *testing.T) { require.NotNil(t, bd.Spec.Source.Image) require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", bd.Spec.Source.Image.Ref) - t.Log("It sets the resolvedBundleResource status field") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", clusterExtension.Status.ResolvedBundleResource) + t.Log("It sets the ResolvedBundle status field") + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, clusterExtension.Status.ResolvedBundle) - t.Log("It sets the InstalledBundleResource status field") - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + t.Log("It sets the InstalledBundle status field") + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("It sets the status on the cluster extension") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -248,8 +248,8 @@ func TestClusterExtensionBundleDeploymentOutOfDate(t *testing.T) { require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", bd.Spec.Source.Image.Ref) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected status conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -328,8 +328,8 @@ func TestClusterExtensionBundleDeploymentUpToDate(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, ext)) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", ext.Status.ResolvedBundleResource) - require.Empty(t, ext.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, ext.Status.ResolvedBundle) + require.Empty(t, ext.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(ext.Status.Conditions, ocv1alpha1.TypeResolved) @@ -364,8 +364,8 @@ func TestClusterExtensionBundleDeploymentUpToDate(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, ext)) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", ext.Status.ResolvedBundleResource) - require.Equal(t, "", ext.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, ext.Status.ResolvedBundle) + require.Nil(t, ext.Status.InstalledBundle) t.Log("By checking the expected conditions") cond = apimeta.FindStatusCondition(ext.Status.Conditions, ocv1alpha1.TypeResolved) @@ -401,8 +401,8 @@ func TestClusterExtensionBundleDeploymentUpToDate(t *testing.T) { require.NoError(t, err) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", ext.Status.ResolvedBundleResource) - require.Empty(t, ext.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, ext.Status.ResolvedBundle) + require.Empty(t, ext.Status.InstalledBundle) t.Log("By checking the expected conditions") cond = apimeta.FindStatusCondition(ext.Status.Conditions, ocv1alpha1.TypeResolved) @@ -438,8 +438,8 @@ func TestClusterExtensionBundleDeploymentUpToDate(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, ext)) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", ext.Status.ResolvedBundleResource) - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", ext.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, ext.Status.ResolvedBundle) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, ext.Status.InstalledBundle) t.Log("By checking the expected conditions") cond = apimeta.FindStatusCondition(ext.Status.Conditions, ocv1alpha1.TypeResolved) @@ -481,8 +481,8 @@ func TestClusterExtensionBundleDeploymentUpToDate(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, ext)) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", ext.Status.ResolvedBundleResource) - require.Empty(t, ext.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, ext.Status.ResolvedBundle) + require.Nil(t, ext.Status.InstalledBundle) t.Log("By checking the expected conditions") cond = apimeta.FindStatusCondition(ext.Status.Conditions, ocv1alpha1.TypeResolved) @@ -518,8 +518,8 @@ func TestClusterExtensionBundleDeploymentUpToDate(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, ext)) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", ext.Status.ResolvedBundleResource) - require.Empty(t, ext.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, ext.Status.ResolvedBundle) + require.Nil(t, ext.Status.InstalledBundle) t.Log("By cchecking the expected conditions") cond = apimeta.FindStatusCondition(ext.Status.Conditions, ocv1alpha1.TypeResolved) @@ -584,11 +584,11 @@ func TestClusterExtensionExpectedBundleDeployment(t *testing.T) { require.NotNil(t, bd.Spec.Source.Image) require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", bd.Spec.Source.Image.Ref) - t.Log("It sets the resolvedBundleResource status field") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", clusterExtension.Status.ResolvedBundleResource) + t.Log("It sets the ResolvedBundle status field") + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, clusterExtension.Status.ResolvedBundle) - t.Log("It sets the InstalledBundleResource status field") - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + t.Log("It sets the InstalledBundle status field") + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("It sets resolution to unknown status") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -637,8 +637,8 @@ func TestClusterExtensionDuplicatePackage(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Empty(t, clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Empty(t, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -689,8 +689,8 @@ func TestClusterExtensionChannelVersionExists(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake1.0.0", clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/1.0.0", Version: "1.0.0"}, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -746,8 +746,8 @@ func TestClusterExtensionChannelExistsNoVersion(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -804,8 +804,8 @@ func TestClusterExtensionVersionNoChannel(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Empty(t, clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Empty(t, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -853,8 +853,8 @@ func TestClusterExtensionNoChannel(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Empty(t, clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Empty(t, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -903,8 +903,8 @@ func TestClusterExtensionNoVersion(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Empty(t, clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Empty(t, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -953,8 +953,8 @@ func TestClusterExtensionPlainV0Bundle(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhub/plain@sha256:plain", clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/plain/0.1.0", Version: "0.1.0"}, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) require.NotNil(t, cond) @@ -1011,8 +1011,8 @@ func TestClusterExtensionBadBundleMediaType(t *testing.T) { require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) t.Log("By checking the status fields") - require.Equal(t, "quay.io/operatorhub/badmedia@sha256:badmedia", clusterExtension.Status.ResolvedBundleResource) - require.Empty(t, clusterExtension.Status.InstalledBundleResource) + require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/badmedia/0.1.0", Version: "0.1.0"}, clusterExtension.Status.ResolvedBundle) + require.Empty(t, clusterExtension.Status.InstalledBundle) t.Log("By checking the expected conditions") cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1140,7 +1140,7 @@ func TestClusterExtensionUpgrade(t *testing.T) { require.NoError(t, err) // Checking the status fields - assert.Equal(t, "quay.io/operatorhubio/prometheus@fake1.0.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/1.0.0", Version: "1.0.0"}, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1165,7 +1165,7 @@ func TestClusterExtensionUpgrade(t *testing.T) { // Checking the status fields // TODO: https://github.com/operator-framework/operator-controller/issues/320 - assert.Equal(t, "", clusterExtension.Status.ResolvedBundleResource) + assert.Nil(t, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1190,7 +1190,7 @@ func TestClusterExtensionUpgrade(t *testing.T) { require.NoError(t, err) // Checking the status fields - assert.Equal(t, "quay.io/operatorhubio/prometheus@fake1.2.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/1.2.0", Version: "1.2.0"}, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1233,7 +1233,7 @@ func TestClusterExtensionUpgrade(t *testing.T) { require.NoError(t, err) // Checking the status fields - assert.Equal(t, "quay.io/operatorhubio/prometheus@fake1.0.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/1.0.0", Version: "1.0.0"}, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1258,7 +1258,7 @@ func TestClusterExtensionUpgrade(t *testing.T) { // Checking the status fields // TODO: https://github.com/operator-framework/operator-controller/issues/320 - assert.Equal(t, "", clusterExtension.Status.ResolvedBundleResource) + assert.Nil(t, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1283,7 +1283,7 @@ func TestClusterExtensionUpgrade(t *testing.T) { require.NoError(t, err) // Checking the status fields - assert.Equal(t, "quay.io/operatorhubio/prometheus@fake1.0.1", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/1.0.1", Version: "1.0.1"}, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1338,7 +1338,7 @@ func TestClusterExtensionUpgrade(t *testing.T) { require.NoError(t, err) // Checking the status fields - assert.Equal(t, "quay.io/operatorhubio/prometheus@fake1.0.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/1.0.0", Version: "1.0.0"}, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1364,7 +1364,7 @@ func TestClusterExtensionUpgrade(t *testing.T) { require.NoError(t, err) // Checking the status fields - assert.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1425,7 +1425,7 @@ func TestClusterExtensionDowngrade(t *testing.T) { require.NoError(t, err) // Checking the status fields - assert.Equal(t, "quay.io/operatorhubio/prometheus@fake1.0.1", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/1.0.1", Version: "1.0.1"}, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1450,7 +1450,7 @@ func TestClusterExtensionDowngrade(t *testing.T) { // Checking the status fields // TODO: https://github.com/operator-framework/operator-controller/issues/320 - assert.Equal(t, "", clusterExtension.Status.ResolvedBundleResource) + assert.Nil(t, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1508,7 +1508,7 @@ func TestClusterExtensionDowngrade(t *testing.T) { require.NoError(t, err) // Checking the status fields - assert.Equal(t, "quay.io/operatorhubio/prometheus@fake2.0.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/2.0.0", Version: "2.0.0"}, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) @@ -1532,7 +1532,7 @@ func TestClusterExtensionDowngrade(t *testing.T) { require.NoError(t, err) // Checking the status fields - assert.Equal(t, "quay.io/operatorhubio/prometheus@fake1.0.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/prometheus/beta/1.0.0", Version: "1.0.0"}, clusterExtension.Status.ResolvedBundle) // checking the expected conditions cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) diff --git a/internal/controllers/extension_controller.go b/internal/controllers/extension_controller.go index 04310164c..e15bc3a72 100644 --- a/internal/controllers/extension_controller.go +++ b/internal/controllers/extension_controller.go @@ -24,6 +24,7 @@ import ( "strings" mmsemver "github.com/Masterminds/semver/v3" + bsemver "github.com/blang/semver/v4" "github.com/go-logr/logr" catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1" "github.com/operator-framework/operator-registry/alpha/declcfg" @@ -43,11 +44,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" - catalogsort "github.com/operator-framework/operator-controller/internal/catalogmetadata/sort" - ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" "github.com/operator-framework/operator-controller/internal/catalogmetadata" catalogfilter "github.com/operator-framework/operator-controller/internal/catalogmetadata/filter" + catalogsort "github.com/operator-framework/operator-controller/internal/catalogmetadata/sort" "github.com/operator-framework/operator-controller/pkg/features" ) @@ -127,11 +127,11 @@ func (r *ExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.Ext // Set the TypeInstalled condition to Unknown to indicate that the resolution // hasn't been attempted yet, due to the spec being invalid. - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionUnknown(&ext.Status.Conditions, "extension feature is disabled", ext.GetGeneration()) // Set the TypeResolved condition to Unknown to indicate that the resolution // hasn't been attempted yet, due to the spec being invalid. - ext.Status.ResolvedBundleResource = "" + ext.Status.ResolvedBundle = nil setResolvedStatusConditionUnknown(&ext.Status.Conditions, "extension feature is disabled", ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "extension feature is disabled", ext.GetGeneration()) @@ -146,10 +146,10 @@ func (r *ExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.Ext } if !r.HasKappApis { - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionFailed(&ext.Status.Conditions, errkappAPIUnavailable.Error(), ext.GetGeneration()) - ext.Status.ResolvedBundleResource = "" + ext.Status.ResolvedBundle = nil setResolvedStatusConditionUnknown(&ext.Status.Conditions, "kapp apis are unavailable", ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "kapp apis are unavailable", ext.GetGeneration()) @@ -159,16 +159,16 @@ func (r *ExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.Ext // TODO: Improve the resolution logic. bundle, err := r.resolve(ctx, *ext) if err != nil { - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionUnknown(&ext.Status.Conditions, "installation has not been attempted as resolution failed", ext.GetGeneration()) - ext.Status.ResolvedBundleResource = "" + ext.Status.ResolvedBundle = nil setResolvedStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as resolution failed", ext.GetGeneration()) return ctrl.Result{}, err } // Now we can set the Resolved Condition, and the resolvedBundleSource field to the bundle.Image value. - ext.Status.ResolvedBundleResource = bundle.Image + ext.Status.ResolvedBundle = bundleMetadataFor(bundle) setResolvedStatusConditionSuccess(&ext.Status.Conditions, fmt.Sprintf("resolved to %q", bundle.Image), ext.GetGeneration()) mediaType, err := bundle.MediaType() @@ -183,7 +183,7 @@ func (r *ExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.Ext if mediaType != catalogmetadata.MediaTypePlain { // Set the TypeInstalled condition to Unknown to indicate that the resolution // hasn't been attempted yet, due to the spec being invalid. - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionUnknown(&ext.Status.Conditions, fmt.Sprintf("bundle type %s not supported currently", mediaType), ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration()) return ctrl.Result{}, nil @@ -192,7 +192,7 @@ func (r *ExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.Ext app := r.GenerateExpectedApp(*ext, bundle.Image) if err := r.ensureApp(ctx, app); err != nil { // originally Reason: ocv1alpha1.ReasonInstallationFailed - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) return ctrl.Result{}, err } @@ -201,13 +201,13 @@ func (r *ExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.Ext existingTypedApp := &kappctrlv1alpha1.App{} if err := runtime.DefaultUnstructuredConverter.FromUnstructured(app.UnstructuredContent(), existingTypedApp); err != nil { // originally Reason: ocv1alpha1.ReasonInstallationStatusUnknown - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionUnknown(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration()) return ctrl.Result{}, err } - mapAppStatusToInstalledCondition(existingTypedApp, ext, bundle.Image) + mapAppStatusToInstalledCondition(existingTypedApp, ext, bundle) SetDeprecationStatusInExtension(ext, bundle) return ctrl.Result{}, nil @@ -233,16 +233,16 @@ func (r *ExtensionReconciler) SetupWithManager(mgr ctrl.Manager) error { // TODO: follow up with mapping of all the available App statuses: https://github.com/carvel-dev/kapp-controller/blob/855063edee53315811a13ee8d5df1431ba258ede/pkg/apis/kappctrl/v1alpha1/status.go#L28-L35 // mapAppStatusToInstalledCondition currently maps only the installed condition. -func mapAppStatusToInstalledCondition(existingApp *kappctrlv1alpha1.App, ext *ocv1alpha1.Extension, bundleImage string) { +func mapAppStatusToInstalledCondition(existingApp *kappctrlv1alpha1.App, ext *ocv1alpha1.Extension, bundle *catalogmetadata.Bundle) { appReady := findStatusCondition(existingApp.Status.GenericStatus.Conditions, kappctrlv1alpha1.ReconcileSucceeded) if appReady == nil { - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionUnknown(&ext.Status.Conditions, "install status unknown", ext.Generation) return } if appReady.Status != corev1.ConditionTrue { - ext.Status.InstalledBundleResource = "" + ext.Status.InstalledBundle = nil setInstalledStatusConditionFailed( &ext.Status.Conditions, appReady.Message, @@ -251,9 +251,7 @@ func mapAppStatusToInstalledCondition(existingApp *kappctrlv1alpha1.App, ext *oc return } - // InstalledBundleResource this should be converted into a slice as App allows fetching - // from multiple sources. - ext.Status.InstalledBundleResource = bundleImage + ext.Status.InstalledBundle = bundleMetadataFor(bundle) setInstalledStatusConditionSuccess(&ext.Status.Conditions, appReady.Message, ext.Generation) } @@ -505,3 +503,19 @@ func (r *ExtensionReconciler) resolve(ctx context.Context, extension ocv1alpha1. }) return resultSet[0], nil } + +// bundleMetadataFor returns a BundleMetadata for the given bundle. If the provided bundle is nil, +// this function panics. It is up to the caller to ensure that the bundle is non-nil. +func bundleMetadataFor(bundle *catalogmetadata.Bundle) *ocv1alpha1.BundleMetadata { + if bundle == nil { + panic("programmer error: provided bundle must be non-nil to create BundleMetadata") + } + ver, err := bundle.Version() + if err != nil { + ver = &bsemver.Version{} + } + return &ocv1alpha1.BundleMetadata{ + Name: bundle.Name, + Version: ver.String(), + } +} diff --git a/internal/controllers/extension_controller_test.go b/internal/controllers/extension_controller_test.go index 0d59995a9..24ddb2fc9 100644 --- a/internal/controllers/extension_controller_test.go +++ b/internal/controllers/extension_controller_test.go @@ -45,8 +45,8 @@ func TestExtensionReconcile(t *testing.T) { assert.Equal(t, ctrl.Result{}, res) assert.NoError(t, err) verifyExtensionInvariants(t, ext) - assert.Empty(t, ext.Status.InstalledBundleResource) - assert.Empty(t, ext.Status.ResolvedBundleResource) + assert.Empty(t, ext.Status.InstalledBundle) + assert.Empty(t, ext.Status.ResolvedBundle) for _, cond := range ext.Status.Conditions { assert.Equal(t, metav1.ConditionUnknown, cond.Status) assert.Equal(t, "extension feature is disabled", cond.Message) @@ -62,8 +62,8 @@ func TestExtensionReconcile(t *testing.T) { assert.NoError(t, err) verifyExtensionInvariants(t, ext) assert.False(t, ext.Status.Paused) - assert.Empty(t, ext.Status.InstalledBundleResource) - assert.Empty(t, ext.Status.ResolvedBundleResource) + assert.Empty(t, ext.Status.InstalledBundle) + assert.Empty(t, ext.Status.ResolvedBundle) for _, cond := range ext.Status.Conditions { assert.Equal(t, metav1.ConditionUnknown, cond.Status) assert.Equal(t, "the Extension interface is not fully implemented", cond.Message) diff --git a/test/e2e/cluster_extension_install_test.go b/test/e2e/cluster_extension_install_test.go index 37502deb5..2c3e0f49e 100644 --- a/test/e2e/cluster_extension_install_test.go +++ b/test/e2e/cluster_extension_install_test.go @@ -89,7 +89,7 @@ func TestClusterExtensionInstallRegistry(t *testing.T) { assert.Equal(ct, metav1.ConditionTrue, cond.Status) assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") - assert.Equal(ct, "localhost/testdata/bundles/registry-v1/prometheus-operator:v2.0.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(ct, &ocv1alpha1.BundleMetadata{Name: "prometheus-operator.2.0.0", Version: "2.0.0"}, clusterExtension.Status.ResolvedBundle) }, pollDuration, pollInterval) t.Log("By eventually installing the package successfully") @@ -102,7 +102,7 @@ func TestClusterExtensionInstallRegistry(t *testing.T) { assert.Equal(ct, metav1.ConditionTrue, cond.Status) assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "installed from") - assert.NotEmpty(ct, clusterExtension.Status.InstalledBundleResource) + assert.NotEmpty(ct, clusterExtension.Status.InstalledBundle) bd := rukpakv1alpha2.BundleDeployment{} assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtensionName}, &bd)) @@ -145,7 +145,7 @@ func TestClusterExtensionInstallPlain(t *testing.T) { assert.Equal(ct, metav1.ConditionTrue, cond.Status) assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") - assert.NotEmpty(ct, clusterExtension.Status.ResolvedBundleResource) + assert.NotEmpty(ct, clusterExtension.Status.ResolvedBundle) }, pollDuration, pollInterval) t.Log("By eventually installing the package successfully") @@ -158,7 +158,7 @@ func TestClusterExtensionInstallPlain(t *testing.T) { assert.Equal(ct, metav1.ConditionTrue, cond.Status) assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "installed from") - assert.NotEmpty(ct, clusterExtension.Status.InstalledBundleResource) + assert.NotEmpty(ct, clusterExtension.Status.InstalledBundle) bd := rukpakv1alpha2.BundleDeployment{} assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtensionName}, &bd)) @@ -259,7 +259,7 @@ func TestClusterExtensionInstallNonSuccessorVersion(t *testing.T) { } assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") - assert.Equal(ct, "localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(ct, &ocv1alpha1.BundleMetadata{Name: "prometheus-operator.1.0.0", Version: "1.0.0"}, clusterExtension.Status.ResolvedBundle) }, pollDuration, pollInterval) t.Log("It does not allow to upgrade the ClusterExtension to a non-successor version") @@ -277,7 +277,7 @@ func TestClusterExtensionInstallNonSuccessorVersion(t *testing.T) { assert.Equal(ct, ocv1alpha1.ReasonResolutionFailed, cond.Reason) assert.Contains(ct, cond.Message, "constraints not satisfiable") assert.Contains(ct, cond.Message, "installed package prometheus requires at least one of test-catalog-prometheus-prometheus-operator.1.2.0, test-catalog-prometheus-prometheus-operator.1.0.1, test-catalog-prometheus-prometheus-operator.1.0.0") - assert.Empty(ct, clusterExtension.Status.ResolvedBundleResource) + assert.Empty(ct, clusterExtension.Status.ResolvedBundle) }, pollDuration, pollInterval) } @@ -303,7 +303,7 @@ func TestClusterExtensionInstallSuccessorVersion(t *testing.T) { } assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") - assert.Equal(ct, "localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(ct, &ocv1alpha1.BundleMetadata{Name: "prometheus-operator.1.0.0", Version: "1.0.0"}, clusterExtension.Status.ResolvedBundle) }, pollDuration, pollInterval) t.Log("It does allow to upgrade the ClusterExtension to any of the successor versions within non-zero major version") @@ -320,7 +320,7 @@ func TestClusterExtensionInstallSuccessorVersion(t *testing.T) { } assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) assert.Contains(ct, cond.Message, "resolved to") - assert.Equal(ct, "localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0", clusterExtension.Status.ResolvedBundleResource) + assert.Equal(ct, &ocv1alpha1.BundleMetadata{Name: "prometheus-operator.1.2.0", Version: "1.2.0"}, clusterExtension.Status.ResolvedBundle) }, pollDuration, pollInterval) }