diff --git a/api/v1alpha2/bundledeployment_types.go b/api/v1alpha2/bundledeployment_types.go index 150c6a9a..0a2609bd 100644 --- a/api/v1alpha2/bundledeployment_types.go +++ b/api/v1alpha2/bundledeployment_types.go @@ -69,8 +69,42 @@ type BundleDeploymentSpec struct { // // config is provisioner specific configurations Config runtime.RawExtension `json:"config,omitempty"` + + //+kubebuilder:Optional + // Preflight defines the strategy for the preflight checks (i.e. as of now, the CRD upgrade safety checks) to be enabled or disabled when attempting to install the BundleDeployment. + 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 { + //+kubebuilder:Optional + 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 *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" +) + // BundleDeploymentStatus defines the observed state of BundleDeployment type BundleDeploymentStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` diff --git a/api/v1alpha2/zz_generated.deepcopy.go b/api/v1alpha2/zz_generated.deepcopy.go index 7c12c15d..034540f0 100644 --- a/api/v1alpha2/zz_generated.deepcopy.go +++ b/api/v1alpha2/zz_generated.deepcopy.go @@ -105,6 +105,11 @@ func (in *BundleDeploymentSpec) DeepCopyInto(out *BundleDeploymentSpec) { *out = *in in.Source.DeepCopyInto(&out.Source) in.Config.DeepCopyInto(&out.Config) + if in.Preflight != nil { + in, out := &in.Preflight, &out.Preflight + *out = new(PreflightConfig) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BundleDeploymentSpec. @@ -179,6 +184,26 @@ func (in *BundleSource) DeepCopy() *BundleSource { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CRDUpgradeSafetyPreflightConfig) DeepCopyInto(out *CRDUpgradeSafetyPreflightConfig) { + *out = *in + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(CRDUpgradeSafetyMode) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CRDUpgradeSafetyPreflightConfig. +func (in *CRDUpgradeSafetyPreflightConfig) DeepCopy() *CRDUpgradeSafetyPreflightConfig { + if in == nil { + return nil + } + out := new(CRDUpgradeSafetyPreflightConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ConfigMapSource) DeepCopyInto(out *ConfigMapSource) { *out = *in @@ -257,3 +282,23 @@ func (in *ImageSource) DeepCopy() *ImageSource { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PreflightConfig) DeepCopyInto(out *PreflightConfig) { + *out = *in + if in.CRDUpgradeSafety != nil { + in, out := &in.CRDUpgradeSafety, &out.CRDUpgradeSafety + *out = new(CRDUpgradeSafetyPreflightConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PreflightConfig. +func (in *PreflightConfig) DeepCopy() *PreflightConfig { + if in == nil { + return nil + } + out := new(PreflightConfig) + in.DeepCopyInto(out) + return out +} diff --git a/manifests/base/apis/crds/core.rukpak.io_bundledeployments.yaml b/manifests/base/apis/crds/core.rukpak.io_bundledeployments.yaml index 2f7eb25a..699d2b3d 100644 --- a/manifests/base/apis/crds/core.rukpak.io_bundledeployments.yaml +++ b/manifests/base/apis/crds/core.rukpak.io_bundledeployments.yaml @@ -65,6 +65,26 @@ spec: maxLength: 63 pattern: ^[a-z0-9]([-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 enabled or + disabled when attempting to install the BundleDeployment. + 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 provisionerClassName: description: provisionerClassName sets the name of the provisioner that should reconcile this BundleDeployment.