Skip to content

Commit

Permalink
Add optional field to ClusterExtension API to skip CRD upgrade safety…
Browse files Browse the repository at this point in the history
… checks

Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>
  • Loading branch information
rashmigottipati committed May 14, 2024
1 parent e9acbd3 commit 67cc278
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
33 changes: 33 additions & 0 deletions api/v1alpha1/clusterextension_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,41 @@ type ClusterExtensionSpec struct {
// the bundle may contain resources that are cluster-scoped or that are
// installed in a different namespace. This namespace is expected to exist.
InstallNamespace string `json:"installNamespace"`

//+kubebuilder:Optional
// Preflight defines the strategy for the preflight checks (i.e. as of now, the CRD upgrade safety checks) to be applied or skipped when attempting to install the cluster extension.
Preflight PreflightConfig `json:"preflight,omitempty"`
}

// PreflightConfig holds the config for the preflight checks. Currently, this is implemented for the
// CRDUpgradeSafety preflight check and can be extended in the future to add other preflight checks.
type PreflightConfig struct {
CRDUpgradeSafety CRDUpgradeSafetyPreflightConfig `json:"crdUpgradeSafety,omitempty"`
}

// CRDUpgradeSafetyPreflightConfig is a custom struct that holds the necessary configuration values to
// enable or disable the CRD Upgrade Safety validations. Currently, this holds Mode
// that sets the CRD Upgrade Safety validations to either Enabled/Disabled.
// By default, this is set to "Enabled".
type CRDUpgradeSafetyPreflightConfig struct {
//+kubebuilder:validation:Enum:=Enabled;Disabled
//+kubebuilder:default:=Enabled
//+kubebuilder:Optional
Mode Mode `json:"mode,omitempty"`
}

type Mode string

const (
// CRDUpgradeSafetyPreflightConfigEnabled represents the default state for the
// CRD Upgrade Safety validations by setting it to "Enabled".
CRDUpgradeSafetyPreflightConfigEnabled Mode = "Enabled"

// CRDUpgradeSafetyPreflightConfigDisabled represents the option for the
// CRD Upgrade Safety validations to be disabled by setting it to "Disabled".
CRDUpgradeSafetyPreflightConfigDisabled Mode = "Disabled"
)

const (
// TODO(user): add more Types, here and into init()
TypeInstalled = "Installed"
Expand Down
32 changes: 32 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions config/crd/bases/olm.operatorframework.io_clusterextensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ spec:
maxLength: 48
pattern: ^[a-z0-9]+(-[a-z0-9]+)*$
type: string
preflight:
description: Preflight defines the strategy for the preflight checks
(i.e. as of now, the CRD upgrade safety checks) to be applied or
skipped when attempting to install the cluster extension.
properties:
crdUpgradeSafety:
description: |-
CRDUpgradeSafetyPreflightConfig is a custom struct that holds the necessary configuration values to
enable or disable the CRD Upgrade Safety validations. Currently, this holds Mode
that sets the CRD Upgrade Safety validations to either Enabled/Disabled.
By default, this is set to "Enabled".
properties:
mode:
default: Enabled
enum:
- Enabled
- Disabled
type: string
type: object
type: object
upgradeConstraintPolicy:
default: Enforce
description: Defines the policy for how to handle upgrade constraints
Expand Down

0 comments on commit 67cc278

Please sign in to comment.