@@ -17,7 +17,6 @@ limitations under the License.
1717package v1beta1
1818
1919import (
20- topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
2120 "k8s.io/apimachinery/pkg/runtime"
2221 "k8s.io/apimachinery/pkg/util/validation/field"
2322 ctrl "sigs.k8s.io/controller-runtime"
@@ -106,11 +105,8 @@ func (r *OVNControllerSpecCore) ValidateCreate(basePath *field.Path, namespace s
106105
107106 // When a TopologyRef CR is referenced, fail if a different Namespace is
108107 // referenced because is not supported
109- if r .TopologyRef != nil {
110- if err := topologyv1 .ValidateTopologyNamespace (r .TopologyRef .Namespace , * basePath , namespace ); err != nil {
111- errors = append (errors , err )
112- }
113- }
108+ errors = append (errors , r .ValidateTopology (basePath , namespace )... )
109+
114110 return errors
115111}
116112
@@ -123,11 +119,8 @@ func (r *OVNController) ValidateUpdate(old runtime.Object) (admission.Warnings,
123119
124120 // When a TopologyRef CR is referenced, fail if a different Namespace is
125121 // referenced because is not supported
126- if r .Spec .TopologyRef != nil {
127- if err := topologyv1 .ValidateTopologyNamespace (r .Spec .TopologyRef .Namespace , * basePath , r .Namespace ); err != nil {
128- errors = append (errors , err )
129- }
130- }
122+ errors = append (errors , r .Spec .ValidateTopology (basePath , r .Namespace )... )
123+
131124 if len (errors ) != 0 {
132125 return nil , apierrors .NewInvalid (
133126 schema.GroupKind {Group : "ovn.openstack.org" , Kind : "OVNController" },
@@ -141,16 +134,13 @@ func (r OVNControllerSpec) ValidateUpdate(old OVNControllerSpec, basePath *field
141134}
142135
143136func (r * OVNControllerSpecCore ) ValidateUpdate (old OVNControllerSpec , basePath * field.Path , namespace string ) field.ErrorList {
144- errors := field.ErrorList {}
137+ allErrs := field.ErrorList {}
145138
146139 // When a TopologyRef CR is referenced, fail if a different Namespace is
147140 // referenced because is not supported
148- if r .TopologyRef != nil {
149- if err := topologyv1 .ValidateTopologyNamespace (r .TopologyRef .Namespace , * basePath , namespace ); err != nil {
150- errors = append (errors , err )
151- }
152- }
153- return errors
141+ allErrs = append (allErrs , r .ValidateTopology (basePath , namespace )... )
142+
143+ return allErrs
154144}
155145
156146// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
0 commit comments