diff --git a/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml b/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml index 85330b265..1ff487d4d 100644 --- a/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml +++ b/apis/bases/dataplane.openstack.org_openstackdataplaneservices.yaml @@ -71,6 +71,13 @@ spec: deployOnAllNodeSets: type: boolean edpmServiceType: + enum: + - nova + - ovn + - update + - libvirt + - neutron-metadata + - telemetry type: string openStackAnsibleEERunnerImage: type: string diff --git a/apis/dataplane/v1beta1/openstackdataplaneservice_types.go b/apis/dataplane/v1beta1/openstackdataplaneservice_types.go index 607863151..e3566254c 100644 --- a/apis/dataplane/v1beta1/openstackdataplaneservice_types.go +++ b/apis/dataplane/v1beta1/openstackdataplaneservice_types.go @@ -110,6 +110,7 @@ type OpenStackDataPlaneServiceSpec struct { // corresponds to the ansible role name (without the "edpm_" prefix) used // to manage the service. If not set, will default to the // OpenStackDataPlaneService name. + // +kubebuilder:validation:Enum=nova;ovn;update;libvirt;neutron-metadata;telemetry EDPMServiceType string `json:"edpmServiceType,omitempty" yaml:"edpmServiceType,omitempty"` } diff --git a/apis/dataplane/v1beta1/openstackdataplaneservice_webhook.go b/apis/dataplane/v1beta1/openstackdataplaneservice_webhook.go index 7088a12c3..72ca22635 100644 --- a/apis/dataplane/v1beta1/openstackdataplaneservice_webhook.go +++ b/apis/dataplane/v1beta1/openstackdataplaneservice_webhook.go @@ -44,17 +44,9 @@ var _ webhook.Defaulter = &OpenStackDataPlaneService{} func (r *OpenStackDataPlaneService) Default() { openstackdataplaneservicelog.Info("default", "name", r.Name) - r.Spec.Default(r.Name) r.DefaultLabels() } -// Default - set defaults for this OpenStackDataPlaneService -func (spec *OpenStackDataPlaneServiceSpec) Default(name string) { - if spec.EDPMServiceType == "" { - spec.EDPMServiceType = name - } -} - // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. // +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 diff --git a/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml b/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml index 85330b265..1ff487d4d 100644 --- a/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml +++ b/config/crd/bases/dataplane.openstack.org_openstackdataplaneservices.yaml @@ -71,6 +71,13 @@ spec: deployOnAllNodeSets: type: boolean edpmServiceType: + enum: + - nova + - ovn + - update + - libvirt + - neutron-metadata + - telemetry type: string openStackAnsibleEERunnerImage: type: string diff --git a/tests/functional/dataplane/openstackdataplanedeployment_controller_test.go b/tests/functional/dataplane/openstackdataplanedeployment_controller_test.go index 29abd907d..c216dcce9 100644 --- a/tests/functional/dataplane/openstackdataplanedeployment_controller_test.go +++ b/tests/functional/dataplane/openstackdataplanedeployment_controller_test.go @@ -133,7 +133,6 @@ var _ = Describe("Dataplane Deployment Test", func() { CreateDataplaneService(dataplaneGlobalServiceName, true) // with EDPMServiceType set CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{ - "edpmServiceType": "foo-update-service", "openStackAnsibleEERunnerImage": "foo-image:latest"}) DeferCleanup(th.DeleteService, dataplaneServiceName) @@ -279,7 +278,6 @@ var _ = Describe("Dataplane Deployment Test", func() { CreateDataplaneService(dataplaneServiceName, false) CreateDataplaneService(dataplaneGlobalServiceName, true) CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{ - "edpmServiceType": "foo-update-service", "openStackAnsibleEERunnerImage": "foo-image:latest"}) DeferCleanup(th.DeleteService, dataplaneServiceName) @@ -749,8 +747,7 @@ var _ = Describe("Dataplane Deployment Test", func() { // Three services on both nodesets CreateDataplaneService(dataplaneServiceName, false) CreateDataplaneService(dataplaneGlobalServiceName, true) - CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{ - "EDPMServiceType": "foo-update-service"}) + CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{}) DeferCleanup(th.DeleteService, dataplaneServiceName) DeferCleanup(th.DeleteService, dataplaneGlobalServiceName) @@ -1080,8 +1077,7 @@ var _ = Describe("Dataplane Deployment Test", func() { // Three services on both nodesets CreateDataplaneService(dataplaneServiceName, false) CreateDataplaneService(dataplaneGlobalServiceName, true) - CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{ - "EDPMServiceType": "foo-update-service"}) + CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{}) DeferCleanup(th.DeleteService, dataplaneServiceName) DeferCleanup(th.DeleteService, dataplaneGlobalServiceName) @@ -1287,8 +1283,7 @@ var _ = Describe("Dataplane Deployment Test", func() { // Three services on both nodesets CreateDataplaneService(dataplaneServiceName, false) CreateDataplaneService(dataplaneGlobalServiceName, true) - CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{ - "EDPMServiceType": "foo-update-service"}) + CreateDataPlaneServiceFromSpec(dataplaneUpdateServiceName, map[string]interface{}{}) DeferCleanup(th.DeleteService, dataplaneServiceName) DeferCleanup(th.DeleteService, dataplaneGlobalServiceName)