Skip to content

Commit

Permalink
Add GaleraSpecCore struct
Browse files Browse the repository at this point in the history
This version of the struct (called "core") is meant to
be used via the OpenStackControlplane. It is the same
as GaleraSpec only it is missing the containerImages.

The Default() function for webhooks has been updated accordingly.

Jira: OSPRH-4835
  • Loading branch information
dprince committed Feb 28, 2024
1 parent 76fef73 commit 4376f3f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
11 changes: 8 additions & 3 deletions api/v1beta1/galera_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion api/v1beta1/galera_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 19 additions & 3 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4376f3f

Please sign in to comment.