Skip to content

Commit

Permalink
Add BarbicanSpecCore 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 BarbicanSpec only it is missing the containerImages.

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

Jira: OSPRH-4835
  • Loading branch information
dprince committed Feb 28, 2024
1 parent cb4e05f commit c94cc1c
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 18 deletions.
28 changes: 22 additions & 6 deletions api/v1beta1/barbican_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ const (

// BarbicanSpec defines the desired state of Barbican
type BarbicanSpec struct {
BarbicanSpecBase `json:",inline"`

BarbicanAPI BarbicanAPITemplate `json:"barbicanAPI"`

BarbicanWorker BarbicanWorkerTemplate `json:"barbicanWorker"`

BarbicanKeystoneListener BarbicanKeystoneListenerTemplate `json:"barbicanKeystoneListener"`
}

// BarbicanSpecCore defines the desired state of Barbican, for use with the OpenStackControlplane CR (no containerImages)
type BarbicanSpecCore struct {
BarbicanSpecBase `json:",inline"`

BarbicanAPI BarbicanAPITemplateCore `json:"barbicanAPI"`

BarbicanWorker BarbicanWorkerTemplateCore `json:"barbicanWorker"`

BarbicanKeystoneListener BarbicanKeystoneListenerTemplateCore `json:"barbicanKeystoneListener"`
}

// BarbicanSpecBase -
type BarbicanSpecBase struct {
BarbicanTemplate `json:",inline"`

// +kubebuilder:validation:Optional
Expand All @@ -66,12 +88,6 @@ type BarbicanSpec struct {

// +kubebuilder:validation:Required
// BarbicanAPIInternal - Spec definition for the internal and admin API service of this Barbican deployment

BarbicanAPI BarbicanAPITemplate `json:"barbicanAPI"`

BarbicanWorker BarbicanWorkerTemplate `json:"barbicanWorker"`

BarbicanKeystoneListener BarbicanKeystoneListenerTemplate `json:"barbicanKeystoneListener"`
}

// BarbicanStatus defines the observed state of Barbican
Expand Down
12 changes: 12 additions & 0 deletions api/v1beta1/barbican_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ func (spec *BarbicanSpec) Default() {
if spec.BarbicanKeystoneListener.ContainerImage == "" {
spec.BarbicanKeystoneListener.ContainerImage = barbicanDefaults.KeystoneListenerContainerImageURL
}
spec.BarbicanSpecBase.Default()
}

// Default - for shared base validations
func (spec *BarbicanSpecBase) Default() {
// no validations
}

// Default - set defaults for this BarbicanSpecBase. NOTE: this version is used by the OpenStackControlplane webhook
func (spec *BarbicanSpecCore) Default() {
// no validations
spec.BarbicanSpecBase.Default()
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
Expand Down
9 changes: 9 additions & 0 deletions api/v1beta1/barbicanapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ import (

// BarbicanAPITemplate defines the input parameters for the Barbican API service
type BarbicanAPITemplate struct {
BarbicanAPITemplateCore `json:",inline"`

// +kubebuilder:validation:Required
// ContainerImage - Barbican Container Image URL (will be set to environmental default if empty)
ContainerImage string `json:"containerImage"`
}

// BarbicanAPITemplateCore -
type BarbicanAPITemplateCore struct {
// Common input parameters for the Barbican API service
BarbicanComponentTemplate `json:",inline"`

Expand Down
9 changes: 9 additions & 0 deletions api/v1beta1/barbicankeystonelistener_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ import (

// BarbicanKeystoneListenerTemplate defines common Spec elements for the KeystoneListener process
type BarbicanKeystoneListenerTemplate struct {
BarbicanKeystoneListenerTemplateCore `json:",inline"`

// +kubebuilder:validation:Required
// ContainerImage - Barbican Container Image URL (will be set to environmental default if empty)
ContainerImage string `json:"containerImage"`
}

// BarbicanKeystoneListenerTemplate defines common Spec elements for the KeystoneListener process
type BarbicanKeystoneListenerTemplateCore struct {
BarbicanComponentTemplate `json:",inline"`

// TODO(dmendiza): Do we need a setting for number of keystone listener processes
Expand Down
9 changes: 9 additions & 0 deletions api/v1beta1/barbicanworker_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ import (

// BarbicanWorkerTemplate defines common Spec elements for the Worker process
type BarbicanWorkerTemplate struct {
BarbicanWorkerTemplateCore `json:",inline"`

// +kubebuilder:validation:Required
// ContainerImage - Barbican Container Image URL (will be set to environmental default if empty)
ContainerImage string `json:"containerImage"`
}

// BarbicanWorkerTemplateCore -
type BarbicanWorkerTemplateCore struct {
BarbicanComponentTemplate `json:",inline"`

// TODO(dmendiza): Do we need a setting for number of worker processes
Expand Down
4 changes: 0 additions & 4 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ type BarbicanTemplate struct {
// (e.g. API, Worker, Listener)
type BarbicanComponentTemplate struct {

// +kubebuilder:validation:Required
// ContainerImage - Barbican Container Image URL (will be set to environmental default if empty)
ContainerImage string `json:"containerImage"`

// +kubebuilder:validation:Optional
// NodeSelector to target subset of worker nodes running this component. Setting here overrides
// any global NodeSelector settings within the Barbican CR.
Expand Down
99 changes: 91 additions & 8 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 c94cc1c

Please sign in to comment.