Skip to content

Commit d1b5345

Browse files
committed
update resource definition and tests based on review
Signed-off-by: perdasilva <[email protected]>
1 parent d25be66 commit d1b5345

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

api/v1alpha1/operator_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ type OperatorSpec struct {
3131
//+kubebuilder:validation:MaxLength:=64
3232
//+kubebuilder:validation:Pattern:=^(\|\||\s+)?([\s~^><=]*)v?(\d+)(\.(\d+))?(\.(\d+))?(\-(.+))?$
3333
//+kubebuilder:optional
34+
// Version is an optional is semver constraint on the package version. If not specified, the latest version available of the package will be installed.
35+
// If specified, the specific version of the package will be installed so long as it is available in any of the content sources available.
36+
// Examples:
37+
// - 1.2.3
38+
// - 1.0.0-alpha
39+
// - 1.0.0-rc.1
40+
//
41+
// For more information on semver, please see https://semver.org/
3442
Version string `json:"version,omitempty"`
3543
}
3644

config/crd/bases/operators.operatorframework.io_operators.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ spec:
4040
pattern: ^[a-z0-9]+(-[a-z0-9]+)*$
4141
type: string
4242
version:
43+
description: "Version is an optional is semver constraint on the package
44+
version. If not specified, the latest version available of the package
45+
will be installed. If specified, the specific version of the package
46+
will be installed so long as it is available in any of the content
47+
sources available. Examples: - 1.2.3 - 1.0.0-alpha - 1.0.0-rc.1
48+
\n For more information on semver, please see https://semver.org/"
4349
maxLength: 64
4450
pattern: ^(\|\||\s+)?([\s~^><=]*)v?(\d+)(\.(\d+))?(\.(\d+))?(\-(.+))?$
4551
type: string

controllers/operator_controller_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ var _ = Describe("Operator Controller Test", func() {
8080
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' not found", pkgName)))
8181
})
8282
})
83-
When("the operator specifies a version range for which there are no bundles", func() {
83+
When("the operator specifies a version that does not exist", func() {
8484
var pkgName string
8585
BeforeEach(func() {
8686
By("initializing cluster state")
@@ -89,7 +89,7 @@ var _ = Describe("Operator Controller Test", func() {
8989
ObjectMeta: metav1.ObjectMeta{Name: opKey.Name},
9090
Spec: operatorsv1alpha1.OperatorSpec{
9191
PackageName: pkgName,
92-
Version: ">=0.50.0",
92+
Version: "0.50.0",
9393
},
9494
}
9595
err := cl.Create(ctx, operator)
@@ -99,7 +99,7 @@ var _ = Describe("Operator Controller Test", func() {
9999
By("running reconcile")
100100
res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: opKey})
101101
Expect(res).To(Equal(ctrl.Result{}))
102-
Expect(err).To(MatchError(fmt.Sprintf("package '%s' in version range '>=0.50.0' not found", pkgName)))
102+
Expect(err).To(MatchError(fmt.Sprintf("package '%s' at version '0.50.0' not found", pkgName)))
103103

104104
By("fetching updated operator after reconcile")
105105
Expect(cl.Get(ctx, opKey, operator)).NotTo(HaveOccurred())
@@ -109,7 +109,7 @@ var _ = Describe("Operator Controller Test", func() {
109109
Expect(cond).NotTo(BeNil())
110110
Expect(cond.Status).To(Equal(metav1.ConditionFalse))
111111
Expect(cond.Reason).To(Equal(operatorsv1alpha1.ReasonResolutionFailed))
112-
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' in version range '>=0.50.0' not found", pkgName)))
112+
Expect(cond.Message).To(Equal(fmt.Sprintf("package '%s' at version '0.50.0' not found", pkgName)))
113113
})
114114
})
115115
When("the operator specifies a valid available package", func() {

internal/resolution/variable_sources/required_package/required_package.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ func (r *RequiredPackageVariableSource) GetVariables(ctx context.Context, entity
9494
}
9595

9696
func (r *RequiredPackageVariableSource) notFoundError() error {
97+
// TODO: update this error message when/if we decide to support version ranges as opposed to fixing the version
98+
// context: we originally wanted to support version ranges and take the highest version that satisfies the range
99+
// during the upstream call on the 2023-04-11 we decided to pin the version instead. But, we'll keep version range
100+
// support under the covers in case we decide to pivot back.
97101
if r.versionRange != "" {
98-
return fmt.Errorf("package '%s' in version range '%s' not found", r.packageName, r.versionRange)
102+
return fmt.Errorf("package '%s' at version '%s' not found", r.packageName, r.versionRange)
99103
}
100104
return fmt.Errorf("package '%s' not found", r.packageName)
101105
}

0 commit comments

Comments
 (0)