diff --git a/api/v1beta1/galera_types.go b/api/v1beta1/galera_types.go index e81ab5e1..a3473bcf 100644 --- a/api/v1beta1/galera_types.go +++ b/api/v1beta1/galera_types.go @@ -39,6 +39,14 @@ type AdoptionRedirectSpec struct { // GaleraSpec defines the desired state of Galera type GaleraSpec struct { + GaleraSpecCore `json:",inline"` + // Name of the galera container image to run (will be set to environmental default if empty) + // +kubebuilder:validation:Required + ContainerImage string `json:"containerImage"` +} + +// GaleraSpec defines the desired state of Galera +type GaleraSpecCore struct { // Name of the secret to look for password keys // +kubebuilder:validation:Required Secret string `json:"secret"` @@ -48,9 +56,6 @@ type GaleraSpec struct { // Storage size allocated for the mariadb databases // +kubebuilder:validation:Required StorageRequest string `json:"storageRequest"` - // Name of the galera container image to run (will be set to environmental default if empty) - // +kubebuilder:validation:Required - ContainerImage string `json:"containerImage"` // +kubebuilder:validation:Minimum=1 // +kubebuilder:default=1 // +kubebuilder:validation:Enum=1;3 diff --git a/api/v1beta1/galera_webhook.go b/api/v1beta1/galera_webhook.go index 9d305694..1d722887 100644 --- a/api/v1beta1/galera_webhook.go +++ b/api/v1beta1/galera_webhook.go @@ -52,11 +52,18 @@ func (r *Galera) Default() { r.Spec.Default() } -// Default - set defaults for this MariaDB spec +// Default - set defaults for this GaleraSpec func (spec *GaleraSpec) Default() { + // only image validations go here if spec.ContainerImage == "" { spec.ContainerImage = galeraDefaults.ContainerImageURL } + spec.GaleraSpecCore.Default() +} + +// Default - set defaults for the GaleraSpecCore. This version is used by OpenStackControlplane +func (spec *GaleraSpecCore) Default() { + // nothing here yet } // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 72d0a765..168953a6 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -170,6 +170,22 @@ func (in *GaleraList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GaleraSpec) DeepCopyInto(out *GaleraSpec) { + *out = *in + in.GaleraSpecCore.DeepCopyInto(&out.GaleraSpecCore) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GaleraSpec. +func (in *GaleraSpec) DeepCopy() *GaleraSpec { + if in == nil { + return nil + } + out := new(GaleraSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GaleraSpecCore) DeepCopyInto(out *GaleraSpecCore) { *out = *in if in.Replicas != nil { in, out := &in.Replicas, &out.Replicas @@ -187,12 +203,12 @@ func (in *GaleraSpec) DeepCopyInto(out *GaleraSpec) { in.TLS.DeepCopyInto(&out.TLS) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GaleraSpec. -func (in *GaleraSpec) DeepCopy() *GaleraSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GaleraSpecCore. +func (in *GaleraSpecCore) DeepCopy() *GaleraSpecCore { if in == nil { return nil } - out := new(GaleraSpec) + out := new(GaleraSpecCore) in.DeepCopyInto(out) return out }