Skip to content

Commit 65bfc69

Browse files
authored
Add upgradeConstraintPolicy field to Operator spec (#439)
Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent 6808a50 commit 65bfc69

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

api/v1alpha1/operator_types.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ import (
2222
"github.com/operator-framework/operator-controller/internal/conditionsets"
2323
)
2424

25+
type UpgradeConstraintPolicy string
26+
27+
const (
28+
// The operator will only upgrade if the new version satisfies
29+
// the upgrade constraints set by the package author.
30+
UpgradeConstraintPolicyEnforce UpgradeConstraintPolicy = "Enforce"
31+
32+
// Unsafe option which allows an operator to be
33+
// upgraded or downgraded to any available version of the package and
34+
// ignore the upgrade path designed by package authors.
35+
// This assumes that users independently verify the outcome of the changes.
36+
// Use with caution as this can lead to unknown and potentially
37+
// disastrous results such as data loss.
38+
UpgradeConstraintPolicyIgnore UpgradeConstraintPolicy = "Ignore"
39+
)
40+
2541
// OperatorSpec defines the desired state of Operator
2642
type OperatorSpec struct {
2743
//+kubebuilder:validation:MaxLength:=48
@@ -42,6 +58,13 @@ type OperatorSpec struct {
4258
//+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$
4359
// Channel constraint definition
4460
Channel string `json:"channel,omitempty"`
61+
62+
//+kubebuilder:validation:Enum:=Enforce;Ignore
63+
//+kubebuilder:default:=Enforce
64+
//+kubebuilder:Optional
65+
//
66+
// Defines the policy for how to handle upgrade constraints
67+
UpgradeConstraintPolicy UpgradeConstraintPolicy `json:"upgradeConstraintPolicy,omitempty"`
4568
}
4669

4770
const (

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ spec:
4343
maxLength: 48
4444
pattern: ^[a-z0-9]+(-[a-z0-9]+)*$
4545
type: string
46+
upgradeConstraintPolicy:
47+
default: Enforce
48+
description: Defines the policy for how to handle upgrade constraints
49+
enum:
50+
- Enforce
51+
- Ignore
52+
type: string
4653
version:
4754
description: "Version is an optional semver constraint on the package
4855
version. If not specified, the latest version available of the package

0 commit comments

Comments
 (0)