From c1363cc5e8fc6e6aee06f7bb4718332c52c0ada6 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 23 Feb 2024 11:00:30 -0500 Subject: [PATCH] Add HorizonSpecCore struct This version of the struct (called "core") is meant to be used via the OpenStackControlplane. It is the same as HorizonSpec only it is missing the containerImages. The Default() function for webhooks has been split accordingly. Jira: OSPRH-4835 --- api/v1beta1/horizon_types.go | 6 ++++++ api/v1beta1/horizon_webhook.go | 7 +++++++ api/v1beta1/zz_generated.deepcopy.go | 22 +++++++++++++++++++--- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/api/v1beta1/horizon_types.go b/api/v1beta1/horizon_types.go index 71b27b24..16f7172c 100644 --- a/api/v1beta1/horizon_types.go +++ b/api/v1beta1/horizon_types.go @@ -35,9 +35,15 @@ const ( // HorizonSpec defines the desired state of Horizon type HorizonSpec struct { + HorizonSpecCore `json:",inline"` + // +kubebuilder:validation:Required // horizon Container Image URL ContainerImage string `json:"containerImage"` +} + +// HorizonSpecBase - +type HorizonSpecCore struct { // +kubebuilder:validation:Optional // +kubebuilder:default=1 diff --git a/api/v1beta1/horizon_webhook.go b/api/v1beta1/horizon_webhook.go index 1d4bdb3f..37e38ea8 100644 --- a/api/v1beta1/horizon_webhook.go +++ b/api/v1beta1/horizon_webhook.go @@ -66,9 +66,16 @@ func (r *Horizon) Default() { // Default - set defaults for this Horizon spec func (spec *HorizonSpec) Default() { + // NOTE: only containerImage validations go here if spec.ContainerImage == "" { spec.ContainerImage = horizonDefaults.ContainerImageURL } + spec.HorizonSpecCore.Default() +} + +// Default - set defaults for this Horizon spec core (this one gets used by OpenstackControlPlane) +func (spec *HorizonSpecCore) 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 4acd9318..e1847d6d 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -123,6 +123,22 @@ func (in *HorizonList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HorizonSpec) DeepCopyInto(out *HorizonSpec) { + *out = *in + in.HorizonSpecCore.DeepCopyInto(&out.HorizonSpecCore) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HorizonSpec. +func (in *HorizonSpec) DeepCopy() *HorizonSpec { + if in == nil { + return nil + } + out := new(HorizonSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HorizonSpecCore) DeepCopyInto(out *HorizonSpecCore) { *out = *in if in.Replicas != nil { in, out := &in.Replicas, &out.Replicas @@ -148,12 +164,12 @@ func (in *HorizonSpec) DeepCopyInto(out *HorizonSpec) { in.TLS.DeepCopyInto(&out.TLS) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HorizonSpec. -func (in *HorizonSpec) DeepCopy() *HorizonSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HorizonSpecCore. +func (in *HorizonSpecCore) DeepCopy() *HorizonSpecCore { if in == nil { return nil } - out := new(HorizonSpec) + out := new(HorizonSpecCore) in.DeepCopyInto(out) return out }