Skip to content

Commit 5a47593

Browse files
author
Brendan Shephard
committed
Require EDPMServiceType
This change switches EDPMServiceType from optional to required. Since the EDPMServiceType of custom services needs to match that of an existing service, we also remove the defaulting mechanism in the webhook. Signed-off-by: Brendan Shephard <bshephar@redhat.com>
1 parent c8ed999 commit 5a47593

46 files changed

Lines changed: 67 additions & 18 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,11 @@ spec:
126126
type: array
127127
required:
128128
- contents
129+
- edpmRoleServiceName
129130
type: object
130131
type: object
132+
required:
133+
- edpmServiceType
131134
type: object
132135
status:
133136
properties:

apis/dataplane/v1beta1/openstackdataplaneservice_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type OpenstackDataPlaneServiceCert struct {
5353
// not set, OpenStackDataPlaneService.Spec.EDPMServiceType is used. If
5454
// OpenStackDataPlaneService.Spec.EDPMServiceType is not set, then
5555
// OpenStackDataPlaneService.Name is used.
56-
EDPMRoleServiceName string `json:"edpmRoleServiceName,omitempty"`
56+
EDPMRoleServiceName string `json:"edpmRoleServiceName"`
5757
}
5858

5959
// OpenStackDataPlaneServiceSpec defines the desired state of OpenStackDataPlaneService
@@ -111,7 +111,8 @@ type OpenStackDataPlaneServiceSpec struct {
111111
// corresponds to the ansible role name (without the "edpm_" prefix) used
112112
// to manage the service. If not set, will default to the
113113
// OpenStackDataPlaneService name.
114-
EDPMServiceType string `json:"edpmServiceType,omitempty" yaml:"edpmServiceType,omitempty"`
114+
// +kubebuilder:validation:Required
115+
EDPMServiceType string `json:"edpmServiceType" yaml:"edpmServiceType"`
115116
}
116117

117118
// OpenStackDataPlaneServiceStatus defines the observed state of OpenStackDataPlaneService

apis/dataplane/v1beta1/openstackdataplaneservice_webhook.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,9 @@ var _ webhook.Defaulter = &OpenStackDataPlaneService{}
4444
func (r *OpenStackDataPlaneService) Default() {
4545

4646
openstackdataplaneservicelog.Info("default", "name", r.Name)
47-
r.Spec.Default(r.Name)
4847
r.DefaultLabels()
4948
}
5049

51-
// Default - set defaults for this OpenStackDataPlaneService
52-
func (spec *OpenStackDataPlaneServiceSpec) Default(name string) {
53-
if spec.EDPMServiceType == "" {
54-
spec.EDPMServiceType = name
55-
}
56-
}
57-
5850
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
5951
// +kubebuilder:webhook:path=/validate-dataplane-openstack-org-v1beta1-openstackdataplaneservice,mutating=false,failurePolicy=fail,sideEffects=None,groups=dataplane.openstack.org,resources=openstackdataplaneservices,verbs=create;update,versions=v1beta1,name=vopenstackdataplaneservice.kb.io,admissionReviewVersions=v1
6052

config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,11 @@ spec:
126126
type: array
127127
required:
128128
- contents
129+
- edpmRoleServiceName
129130
type: object
130131
type: object
132+
required:
133+
- edpmServiceType
131134
type: object
132135
status:
133136
properties:

config/services/dataplane_v1beta1_openstackdataplaneservice_bootstrap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ metadata:
44
name: bootstrap
55
spec:
66
playbook: osp.edpm.bootstrap
7+
edpmServiceType: bootstrap

config/services/dataplane_v1beta1_openstackdataplaneservice_ceph_client.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ metadata:
44
name: ceph-client
55
spec:
66
playbook: osp.edpm.ceph_client
7+
edpmServiceType: ceph-client

config/services/dataplane_v1beta1_openstackdataplaneservice_ceph_hci_pre.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ metadata:
44
name: ceph-hci-pre
55
spec:
66
playbook: osp.edpm.ceph_hci_pre
7+
edpmServiceType: ceph-hci-pre

config/services/dataplane_v1beta1_openstackdataplaneservice_configure_network.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ metadata:
44
name: configure-network
55
spec:
66
playbook: osp.edpm.configure_network
7+
edpmServiceType: configure-network

config/services/dataplane_v1beta1_openstackdataplaneservice_configure_os.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ metadata:
44
name: configure-os
55
spec:
66
playbook: osp.edpm.configure_os
7+
edpmServiceType: configure-os

config/services/dataplane_v1beta1_openstackdataplaneservice_configure_ovs_dpdk.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ metadata:
44
name: configure-ovs-dpdk
55
spec:
66
playbook: osp.edpm.configure_ovs_dpdk
7+
edpmServiceType: configure-ovs-dpdk

0 commit comments

Comments
 (0)