Skip to content

Commit 41042b1

Browse files
dprincestuggi
authored andcommitted
Add KeystoneAPISpecCore struct
This version of the struct (called "core") is meant to be used via the OpenStackControlplane. It is the same as KeystoneAPISpec only it is missing the containerImages. The Default() function for webhooks has been updated accordingly. Jira: OSPRH-4835
1 parent f699384 commit 41042b1

File tree

6 files changed

+45
-17
lines changed

6 files changed

+45
-17
lines changed

api/bases/keystone.openstack.org_keystoneapis.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ spec:
4646
metadata:
4747
type: object
4848
spec:
49-
description: KeystoneAPISpec defines the desired state of KeystoneAPI
5049
properties:
5150
adminProject:
5251
default: admin

api/test/helpers/crd.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ func (th *TestHelper) CreateKeystoneAPIWithFixture(
110110
Namespace: namespace,
111111
},
112112
Spec: keystonev1.KeystoneAPISpec{
113-
Secret: n + "-secret",
114-
AdminUser: "admin",
115-
PasswordSelectors: keystonev1.PasswordSelector{
116-
Admin: "admin-password",
113+
KeystoneAPISpecCore: keystonev1.KeystoneAPISpecCore{
114+
Secret: n + "-secret",
115+
AdminUser: "admin",
116+
PasswordSelectors: keystonev1.PasswordSelector{
117+
Admin: "admin-password",
118+
},
117119
},
118120
},
119121
}

api/v1beta1/keystoneapi_types.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,16 @@ const (
4747
KeystoneAPIContainerImage = "quay.io/podified-antelope-centos9/openstack-keystone:current-podified"
4848
)
4949

50-
// KeystoneAPISpec defines the desired state of KeystoneAPI
5150
type KeystoneAPISpec struct {
51+
KeystoneAPISpecCore `json:",inline"`
52+
53+
// +kubebuilder:validation:Required
54+
// Keystone Container Image URL (will be set to environmental default if empty)
55+
ContainerImage string `json:"containerImage"`
56+
}
57+
58+
// KeystoneAPISpec defines the desired state of KeystoneAPI
59+
type KeystoneAPISpecCore struct {
5260
// +kubebuilder:validation:Required
5361
// MariaDB instance name
5462
// Right now required by the maridb-operator to get the credentials from the instance to create the DB
@@ -81,10 +89,6 @@ type KeystoneAPISpec struct {
8189
// AdminUser - admin user name
8290
AdminUser string `json:"adminUser"`
8391

84-
// +kubebuilder:validation:Required
85-
// Keystone Container Image URL (will be set to environmental default if empty)
86-
ContainerImage string `json:"containerImage"`
87-
8892
// +kubebuilder:validation:Optional
8993
// +kubebuilder:default=1
9094
// +kubebuilder:validation:Maximum=32

api/v1beta1/keystoneapi_webhook.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,22 @@ var _ webhook.Defaulter = &KeystoneAPI{}
6161
func (r *KeystoneAPI) Default() {
6262
keystoneapilog.Info("default", "name", r.Name)
6363

64+
if r.Spec.ContainerImage == "" {
65+
r.Spec.ContainerImage = keystoneAPIDefaults.ContainerImageURL
66+
}
6467
r.Spec.Default()
6568
}
6669

6770
// Default - set defaults for this KeystoneAPI spec
6871
func (spec *KeystoneAPISpec) Default() {
69-
if spec.ContainerImage == "" {
70-
spec.ContainerImage = keystoneAPIDefaults.ContainerImageURL
71-
}
72+
// no defaults to set yet
73+
spec.KeystoneAPISpecCore.Default()
74+
}
75+
76+
// Default - set defaults for this KeystoneAPI core spec
77+
// NOTE: only this version is used by OpenStackOperators webhook
78+
func (spec *KeystoneAPISpecCore) Default() {
79+
// no defaults to set yet
7280
}
7381

7482
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 19 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/keystone.openstack.org_keystoneapis.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ spec:
4646
metadata:
4747
type: object
4848
spec:
49-
description: KeystoneAPISpec defines the desired state of KeystoneAPI
5049
properties:
5150
adminProject:
5251
default: admin

0 commit comments

Comments
 (0)