Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add optional field to ClusterExtension API to skip CRD upgrade safety checks #845

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a field is optional (i.e. with omitempty), it should also be a pointer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch - I totally missed that!

}

// 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"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above: re using pointer if field is optional.

}

// 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
CRDUpgradeSafetyMode CRDUpgradeSafetyMode `json:"mode,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
CRDUpgradeSafetyMode CRDUpgradeSafetyMode `json:"mode,omitempty"`
Mode CRDUpgradeSafetyMode `json:"mode,omitempty"`

}

type CRDUpgradeSafetyMode string

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

// CRDUpgradeSafetyModeDisabled represents the option for the
// CRD Upgrade Safety validations to be disabled by setting it to "Disabled".
CRDUpgradeSafetyModeDisabled CRDUpgradeSafetyMode = "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.

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
Loading