Skip to content

Commit

Permalink
Add upgradeConstraintPolicy field to Operator spec
Browse files Browse the repository at this point in the history
Signed-off-by: Mikalai Radchuk <[email protected]>
  • Loading branch information
m1kola committed Oct 5, 2023
1 parent 6808a50 commit 60c3c1b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions api/v1alpha1/operator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ import (
"github.com/operator-framework/operator-controller/internal/conditionsets"
)

type UpgradeConstraintPolicy string

const (
// The operator will only upgrade if the new version satisfies
// the upgrade constraints set by the package author.
UpgradeConstraintPolicyEnforce UpgradeConstraintPolicy = "Enforce"

// Unsafe option which allows an operator to be
// upgraded or downgraded to any available version of the package and
// ignore the upgrade path designed by package authors.
// This assumes that users independently verify the outcome of the changes.
// Use with caution as this can lead to unknown and potentially
// disastrous results such as data loss.
UpgradeConstraintPolicyIgnore UpgradeConstraintPolicy = "Ignore"
)

// OperatorSpec defines the desired state of Operator
type OperatorSpec struct {
//+kubebuilder:validation:MaxLength:=48
Expand All @@ -42,6 +58,13 @@ type OperatorSpec struct {
//+kubebuilder:validation:Pattern:=^[a-z0-9]+([\.-][a-z0-9]+)*$
// Channel constraint definition
Channel string `json:"channel,omitempty"`

//+kubebuilder:validation:Enum:=Enforce;Ignore
//+kubebuilder:default:=Enforce
//+kubebuilder:Optional
//
// Defines the policy for how to handle upgrade constraints
UpgradeConstraintPolicy UpgradeConstraintPolicy `json:"upgradeConstraintPolicy,omitempty"`
}

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ spec:
maxLength: 48
pattern: ^[a-z0-9]+(-[a-z0-9]+)*$
type: string
upgradeConstraintPolicy:
default: Enforce
description: Defines the policy for how to handle upgrade constraints
enum:
- Enforce
- Ignore
type: string
version:
description: "Version is an optional semver constraint on the package
version. If not specified, the latest version available of the package
Expand Down

0 comments on commit 60c3c1b

Please sign in to comment.