diff --git a/api/v1alpha1/clusterextension_types.go b/api/v1alpha1/clusterextension_types.go index 55f13ab667..0a97aea8c9 100644 --- a/api/v1alpha1/clusterextension_types.go +++ b/api/v1alpha1/clusterextension_types.go @@ -265,7 +265,7 @@ type ClusterExtensionSpec struct { // When not specified, the default configuration for each preflight check will be used. // //+optional - Preflight *PreflightConfig `json:"preflight,omitempty"` + Preflight PreflightConfig `json:"preflight,omitempty"` // serviceAccount is a required reference to a ServiceAccount that exists // in the installNamespace. The provided ServiceAccount is used to install and @@ -319,7 +319,7 @@ type PreflightConfig struct { // consequences of upgrading a CRD, such as data loss. // // This field is required if the spec.preflight field is specified. - CRDUpgradeSafety *CRDUpgradeSafetyPreflightConfig `json:"crdUpgradeSafety"` + CRDUpgradeSafety CRDUpgradeSafetyPreflightConfig `json:"crdUpgradeSafety,omitempty"` } // CRDUpgradeSafetyPreflightConfig is the configuration for CRD upgrade safety preflight check. @@ -340,7 +340,7 @@ type CRDUpgradeSafetyPreflightConfig struct { // //+kubebuilder:validation:Enum:="Enabled";"Disabled" //+kubebuilder:default:=Enabled - Policy CRDUpgradeSafetyPolicy `json:"policy"` + Policy CRDUpgradeSafetyPolicy `json:"policy,omitempty"` } const ( diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 6b40fb2dfa..72621a7820 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -118,11 +118,7 @@ func (in *ClusterExtensionList) DeepCopyObject() runtime.Object { func (in *ClusterExtensionSpec) DeepCopyInto(out *ClusterExtensionSpec) { *out = *in in.CatalogSelector.DeepCopyInto(&out.CatalogSelector) - if in.Preflight != nil { - in, out := &in.Preflight, &out.Preflight - *out = new(PreflightConfig) - (*in).DeepCopyInto(*out) - } + out.Preflight = in.Preflight out.ServiceAccount = in.ServiceAccount } @@ -171,11 +167,7 @@ func (in *ClusterExtensionStatus) DeepCopy() *ClusterExtensionStatus { // 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) - **out = **in - } + out.CRDUpgradeSafety = in.CRDUpgradeSafety } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PreflightConfig. diff --git a/config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml b/config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml index eddc77b748..a20d1d3d04 100644 --- a/config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml +++ b/config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml @@ -253,11 +253,7 @@ spec: - Enabled - Disabled type: string - required: - - policy type: object - required: - - crdUpgradeSafety type: object serviceAccount: description: |- diff --git a/internal/applier/helm.go b/internal/applier/helm.go index 0d764a0d6e..1c727368d1 100644 --- a/internal/applier/helm.go +++ b/internal/applier/helm.go @@ -69,12 +69,10 @@ func (h *Helm) Apply(ctx context.Context, contentFS fs.FS, ext *ocv1alpha1.Clust } for _, preflight := range h.Preflights { - if ext.Spec.Preflight != nil && ext.Spec.Preflight.CRDUpgradeSafety != nil { - if _, ok := preflight.(*crdupgradesafety.Preflight); ok && ext.Spec.Preflight.CRDUpgradeSafety.Policy == ocv1alpha1.CRDUpgradeSafetyPolicyDisabled { - // Skip this preflight check because it is of type *crdupgradesafety.Preflight and the CRD Upgrade Safety - // preflight check has been disabled - continue - } + if _, ok := preflight.(*crdupgradesafety.Preflight); ok && ext.Spec.Preflight.CRDUpgradeSafety.Policy == ocv1alpha1.CRDUpgradeSafetyPolicyDisabled { + // Skip this preflight check because it is of type *crdupgradesafety.Preflight and the CRD Upgrade Safety + // preflight check has been disabled + continue } switch state { case StateNeedsInstall: