Skip to content

Commit 63e2ad8

Browse files
committed
convert field CRDUpgradeSafetyPolicy to be an enum
Signed-off-by: yashoza19 <yoza@redhat.com>
1 parent 1fb6bd2 commit 63e2ad8

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

api/v1alpha1/clusterextension_types.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var (
2828
)
2929

3030
type UpgradeConstraintPolicy string
31+
type CRDUpgradeSafetyPolicy string
3132

3233
const (
3334
// The extension will only upgrade if the new version satisfies
@@ -113,8 +114,9 @@ type PreflightConfig struct {
113114
// CRDUpgradeSafetyPreflightConfig is the configuration for CRD upgrade safety preflight check.
114115
type CRDUpgradeSafetyPreflightConfig struct {
115116
//+kubebuilder:Required
116-
// Disabled represents the state of the CRD upgrade safety preflight check being disabled/enabled.
117-
Disabled bool `json:"disabled,omitempty"`
117+
// +kubebuilder:validation:Enum:="Enabled,Disabled"
118+
// policy represents the state of the CRD upgrade safety preflight check. Allowed values are "Enabled", and Disabled".
119+
Policy CRDUpgradeSafetyPolicy `json:"policy,omitempty"`
118120
}
119121

120122
const (
@@ -144,6 +146,9 @@ const (
144146
ReasonUnpackFailed = "UnpackFailed"
145147

146148
ReasonErrorGettingReleaseState = "ErrorGettingReleaseState"
149+
150+
CRDUpgradeSafetyPolicyEnabled CRDUpgradeSafetyPolicy = "Enabled"
151+
CRDUpgradeSafetyPolicyDisabled CRDUpgradeSafetyPolicy = "Disabled"
147152
)
148153

149154
func init() {

config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,13 @@ spec:
112112
description: CRDUpgradeSafety holds necessary configuration for
113113
the CRD Upgrade Safety preflight checks.
114114
properties:
115-
disabled:
116-
description: Disabled represents the state of the CRD upgrade
117-
safety preflight check being disabled/enabled.
118-
type: boolean
115+
policy:
116+
description: policy represents the state of the CRD upgrade
117+
safety preflight check. Allowed values are "Enabled", and
118+
Disabled".
119+
enum:
120+
- Enabled,Disabled
121+
type: string
119122
type: object
120123
type: object
121124
serviceAccount:

internal/applier/helm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.Clust
7070

7171
for _, preflight := range h.Preflights {
7272
if ext.Spec.Preflight != nil && ext.Spec.Preflight.CRDUpgradeSafety != nil {
73-
if _, ok := preflight.(*crdupgradesafety.Preflight); ok && ext.Spec.Preflight.CRDUpgradeSafety.Disabled {
73+
if _, ok := preflight.(*crdupgradesafety.Preflight); ok && ext.Spec.Preflight.CRDUpgradeSafety.Policy == ocv1alpha1.CRDUpgradeSafetyPolicyDisabled {
7474
// Skip this preflight check because it is of type *crdupgradesafety.Preflight and the CRD Upgrade Safety
7575
// preflight check has been disabled
7676
continue

0 commit comments

Comments
 (0)