Skip to content

Commit c9d387e

Browse files
authored
Update not found error message wording (#463)
Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent 7020ae2 commit c9d387e

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

internal/controllers/operator_controller_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var _ = Describe("Operator Controller Test", func() {
7878
By("running reconcile")
7979
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
8080
Expect(res).To(Equal(ctrl.Result{}))
81-
Expect(err).To(MatchError(fmt.Sprintf("package '%s' not found", pkgName)))
81+
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' found", pkgName)))
8282

8383
By("fetching updated operator after reconcile")
8484
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
@@ -92,7 +92,7 @@ var _ = Describe("Operator Controller Test", func() {
9292
Expect(cond).NotTo(BeNil())
9393
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
9494
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
95-
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' not found", pkgName)))
95+
Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' found", pkgName)))
9696
})
9797
})
9898
When("the operator specifies a version that does not exist", func() {
@@ -114,7 +114,7 @@ var _ = Describe("Operator Controller Test", func() {
114114
By("running reconcile")
115115
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
116116
Expect(res).To(Equal(ctrl.Result{}))
117-
Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '0.50.0' not found", pkgName)))
117+
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' matching version '0.50.0' found", pkgName)))
118118

119119
By("fetching updated operator after reconcile")
120120
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
@@ -128,7 +128,7 @@ var _ = Describe("Operator Controller Test", func() {
128128
Expect(cond).NotTo(BeNil())
129129
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
130130
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
131-
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '0.50.0' not found", pkgName)))
131+
Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' matching version '0.50.0' found", pkgName)))
132132
cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled)
133133
Expect(cond).NotTo(BeNil())
134134
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
@@ -760,7 +760,7 @@ var _ = Describe("Operator Controller Test", func() {
760760
By("running reconcile")
761761
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
762762
Expect(res).To(Equal(ctrl.Result{}))
763-
Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan)))
763+
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' matching version '%s' found in channel '%s'", pkgName, pkgVer, pkgChan)))
764764

765765
By("fetching updated operator after reconcile")
766766
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
@@ -774,7 +774,7 @@ var _ = Describe("Operator Controller Test", func() {
774774
Expect(cond).NotTo(BeNil())
775775
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
776776
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
777-
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan)))
777+
Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' matching version '%s' found in channel '%s'", pkgName, pkgVer, pkgChan)))
778778
cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled)
779779
Expect(cond).NotTo(BeNil())
780780
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
@@ -803,7 +803,7 @@ var _ = Describe("Operator Controller Test", func() {
803803
By("running reconcile")
804804
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
805805
Expect(res).To(Equal(ctrl.Result{}))
806-
Expect(err).To(MatchError(fmt.Sprintf("package '%s' in channel '%s' not found", pkgName, pkgChan)))
806+
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' found in channel '%s'", pkgName, pkgChan)))
807807

808808
By("fetching updated operator after reconcile")
809809
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
@@ -817,7 +817,7 @@ var _ = Describe("Operator Controller Test", func() {
817817
Expect(cond).NotTo(BeNil())
818818
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
819819
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
820-
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' in channel '%s' not found", pkgName, pkgChan)))
820+
Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' found in channel '%s'", pkgName, pkgChan)))
821821
cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled)
822822
Expect(cond).NotTo(BeNil())
823823
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))
@@ -849,7 +849,7 @@ var _ = Describe("Operator Controller Test", func() {
849849
By("running reconcile")
850850
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
851851
Expect(res).To(Equal(ctrl.Result{}))
852-
Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan)))
852+
Expect(err).To(MatchError(fmt.Sprintf("no package '%s' matching version '%s' found in channel '%s'", pkgName, pkgVer, pkgChan)))
853853

854854
By("fetching updated operator after reconcile")
855855
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
@@ -863,7 +863,7 @@ var _ = Describe("Operator Controller Test", func() {
863863
Expect(cond).NotTo(BeNil())
864864
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
865865
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
866-
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '%s' in channel '%s' not found", pkgName, pkgVer, pkgChan)))
866+
Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' matching version '%s' found in channel '%s'", pkgName, pkgVer, pkgChan)))
867867
cond = apimeta.FindStatusCondition(operator.Status.Conditions, operatorsv1alpha1.TypeInstalled)
868868
Expect(cond).NotTo(BeNil())
869869
Expect(cond.Status).To(Equal(metav1.ConditionUnknown))

internal/resolution/variablesources/required_package.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,14 @@ func (r *RequiredPackageVariableSource) GetVariables(ctx context.Context) ([]dep
9191
}
9292

9393
func (r *RequiredPackageVariableSource) notFoundError() error {
94-
// TODO: update this error message when/if we decide to support version ranges as opposed to fixing the version
95-
// context: we originally wanted to support version ranges and take the highest version that satisfies the range
96-
// during the upstream call on the 2023-04-11 we decided to pin the version instead. But, we'll keep version range
97-
// support under the covers in case we decide to pivot back.
9894
if r.versionRange != "" && r.channelName != "" {
99-
return fmt.Errorf("package '%s' at version '%s' in channel '%s' not found", r.packageName, r.versionRange, r.channelName)
95+
return fmt.Errorf("no package '%s' matching version '%s' found in channel '%s'", r.packageName, r.versionRange, r.channelName)
10096
}
10197
if r.versionRange != "" {
102-
return fmt.Errorf("package '%s' at version '%s' not found", r.packageName, r.versionRange)
98+
return fmt.Errorf("no package '%s' matching version '%s' found", r.packageName, r.versionRange)
10399
}
104100
if r.channelName != "" {
105-
return fmt.Errorf("package '%s' in channel '%s' not found", r.packageName, r.channelName)
101+
return fmt.Errorf("no package '%s' found in channel '%s'", r.packageName, r.channelName)
106102
}
107-
return fmt.Errorf("package '%s' not found", r.packageName)
103+
return fmt.Errorf("no package '%s' found", r.packageName)
108104
}

internal/resolution/variablesources/required_package_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ var _ = Describe("RequiredPackageVariableSource", func() {
122122
Expect(err).NotTo(HaveOccurred())
123123
_, err = rpvs.GetVariables(context.TODO())
124124
Expect(err).To(HaveOccurred())
125-
Expect(err).To(MatchError("package 'test-package' not found"))
125+
Expect(err).To(MatchError("no package 'test-package' found"))
126126
})
127127

128128
It("should return an error if catalog client errors", func() {

test/e2e/install_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ var _ = Describe("Operator Install", func() {
155155
g.Expect(cond).ToNot(BeNil())
156156
g.Expect(cond.Status).To(Equal(metav1.ConditionFalse))
157157
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonResolutionFailed))
158-
g.Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' not found", pkgName)))
158+
g.Expect(cond.Message).To(Equal(fmt.Sprintf("no package '%s' found", pkgName)))
159159
}).Should(Succeed())
160160

161161
By("creating an Operator catalog with the desired package")

0 commit comments

Comments
 (0)