From f318e7ef8e3c02c3d785e7d22d08d14532e4d7f7 Mon Sep 17 00:00:00 2001 From: Mikalai Radchuk Date: Mon, 16 Oct 2023 13:06:43 +0100 Subject: [PATCH] Update not found error message wording Signed-off-by: Mikalai Radchuk --- internal/controllers/operator_controller_test.go | 12 ++++++------ .../resolution/variablesources/required_package.go | 8 ++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/internal/controllers/operator_controller_test.go b/internal/controllers/operator_controller_test.go index 1f75c0518..c8266015f 100644 --- a/internal/controllers/operator_controller_test.go +++ b/internal/controllers/operator_controller_test.go @@ -114,7 +114,7 @@ var _ = Describe("Operator Controller Test", func() { By("running reconcile") res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey}) Expect(res).To(Equal(ctrl.Result{})) - Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '0.50.0' not found", pkgName))) + Expect(err).To(MatchError(fmt.Sprintf("package '%s' matching version '0.50.0' not found", pkgName))) By("fetching updated operator after reconcile") Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred()) @@ -128,7 +128,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) - Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '0.50.0' not found", pkgName))) + Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' matching version '0.50.0' not found", pkgName))) cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) @@ -760,7 +760,7 @@ var _ = Describe("Operator Controller Test", func() { By("running reconcile") res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey}) Expect(res).To(Equal(ctrl.Result{})) - Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan))) + Expect(err).To(MatchError(fmt.Sprintf("package '%s' matching version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan))) By("fetching updated operator after reconcile") Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred()) @@ -774,7 +774,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) - Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan))) + Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' matching version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan))) cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) @@ -849,7 +849,7 @@ var _ = Describe("Operator Controller Test", func() { By("running reconcile") res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey}) Expect(res).To(Equal(ctrl.Result{})) - Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan))) + Expect(err).To(MatchError(fmt.Sprintf("package '%s' matching version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan))) By("fetching updated operator after reconcile") Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred()) @@ -863,7 +863,7 @@ var _ = Describe("Operator Controller Test", func() { Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionFalse)) Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed)) - Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan))) + Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' matching version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan))) cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled) Expect(cond).NotTo(BeNil()) Expect(cond.Status).To(Equal(metav1.ConditionUnknown)) diff --git a/internal/resolution/variablesources/required_package.go b/internal/resolution/variablesources/required_package.go index 568a7ebfa..178eae671 100644 --- a/internal/resolution/variablesources/required_package.go +++ b/internal/resolution/variablesources/required_package.go @@ -91,15 +91,11 @@ func (r *RequiredPackageVariableSource) GetVariables(ctx context.Context) ([]dep } func (r *RequiredPackageVariableSource) notFoundError() error { - // TODO: update this error message when/if we decide to support version ranges as opposed to fixing the version - // context: we originally wanted to support version ranges and take the highest version that satisfies the range - // during the upstream call on the 2023-04-11 we decided to pin the version instead. But, we'll keep version range - // support under the covers in case we decide to pivot back. if r.versionRange != "" && r.channelName != "" { - return fmt.Errorf("package '%s' at version '%s' in channel '%s' not found", r.packageName, r.versionRange, r.channelName) + return fmt.Errorf("package '%s' matching version '%s' in channel '%s' not found", r.packageName, r.versionRange, r.channelName) } if r.versionRange != "" { - return fmt.Errorf("package '%s' at version '%s' not found", r.packageName, r.versionRange) + return fmt.Errorf("package '%s' matching version '%s' not found", r.packageName, r.versionRange) } if r.channelName != "" { return fmt.Errorf("package '%s' in channel '%s' not found", r.packageName, r.channelName)