Skip to content

Commit

Permalink
Merge pull request #287 from kajinamit/required-specs
Browse files Browse the repository at this point in the history
Ensure required spec fields are given
  • Loading branch information
openshift-merge-robot authored Aug 23, 2023
2 parents 2f21d0d + 7abd39a commit f311345
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions api/bases/glance.openstack.org_glanceapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,8 @@ spec:
type: string
required:
- containerImage
- databaseHostname
- secret
- serviceAccount
type: object
status:
Expand Down
1 change: 1 addition & 0 deletions api/bases/glance.openstack.org_glances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ spec:
- databaseInstance
- glanceAPIExternal
- glanceAPIInternal
- secret
- storageRequest
type: object
status:
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/glance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ type GlanceSpec struct {
// TODO: -> implement needs work in mariadb-operator, right now only glance
DatabaseUser string `json:"databaseUser"`

// +kubebuilder:validation:Optional
// +kubebuilder:validation:Required
// Secret containing OpenStack password information for glance GlanceDatabasePassword
Secret string `json:"secret,omitempty"`
Secret string `json:"secret"`

// +kubebuilder:validation:Optional
// +kubebuilder:default={database: GlanceDatabasePassword, service: GlancePassword}
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/glanceapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type GlanceAPISpec struct {
// ServiceAccount - service account name used internally to provide GlanceAPI the default SA name
ServiceAccount string `json:"serviceAccount"`

// +kubebuilder:validation:Optional
// +kubebuilder:validation:Required
// DatabaseHostname - Glance Database Hostname
DatabaseHostname string `json:"databaseHostname"`

Expand All @@ -59,7 +59,7 @@ type GlanceAPISpec struct {
// TODO: -> implement needs work in mariadb-operator, right now only glance
DatabaseUser string `json:"databaseUser"`

// +kubebuilder:validation:Optional
// +kubebuilder:validation:Required
// Secret containing OpenStack password information for glance AdminPassword
Secret string `json:"secret"`

Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/glance.openstack.org_glanceapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,8 @@ spec:
type: string
required:
- containerImage
- databaseHostname
- secret
- serviceAccount
type: object
status:
Expand Down
1 change: 1 addition & 0 deletions config/crd/bases/glance.openstack.org_glances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ spec:
- databaseInstance
- glanceAPIExternal
- glanceAPIInternal
- secret
- storageRequest
type: object
status:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ require (
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0
github.com/openstack-k8s-operators/cinder-operator/api v0.1.0
github.com/openstack-k8s-operators/lib-common/modules/test v0.1.1
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
)

require (
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/tools v0.9.3 // indirect
)
Expand Down
18 changes: 14 additions & 4 deletions tests/functional/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package functional

import (
"golang.org/x/exp/maps"

k8s_errors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -152,21 +154,29 @@ func GetDefaultGlanceSpec() map[string]interface{} {
return map[string]interface{}{
"databaseInstance": "openstack",
"secret": SecretName,
"glanceAPIInternal": GetDefaultGlanceAPISpec(GlanceAPITypeInternal),
"glanceAPIExternal": GetDefaultGlanceAPISpec(GlanceAPITypeExternal),
"glanceAPIInternal": GetDefaultGlanceAPITemplate(GlanceAPITypeInternal),
"glanceAPIExternal": GetDefaultGlanceAPITemplate(GlanceAPITypeExternal),
}
}

func GetDefaultGlanceAPISpec(apiType APIType) map[string]interface{} {
func GetDefaultGlanceAPITemplate(apiType APIType) map[string]interface{} {
return map[string]interface{}{
"secret": SecretName,
"replicas": 1,
"containerImage": glanceTest.ContainerImage,
"serviceAccount": glanceTest.GlanceSA.Name,
"apiType": apiType,
}
}

func GetDefaultGlanceAPISpec(apiType APIType) map[string]interface{} {
spec := GetDefaultGlanceAPITemplate(apiType)
maps.Copy(spec, map[string]interface{}{
"databaseHostname": "openstack",
"secret": SecretName,
})
return spec
}

func GlanceAPINotExists(name types.NamespacedName) {
Consistently(func(g Gomega) {
instance := &glancev1.GlanceAPI{}
Expand Down

0 comments on commit f311345

Please sign in to comment.