Skip to content

Commit ee4c869

Browse files
Merge pull request #288 from fmount/topologyref
Update LastAppliedTopology to TopologyRef interface
2 parents a144a7c + caddded commit ee4c869

File tree

44 files changed

+581
-352
lines changed

Some content is hidden

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

44 files changed

+581
-352
lines changed

api/bases/designate.openstack.org_designateapis.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,19 @@ spec:
479479
type: object
480480
lastAppliedTopology:
481481
description: LastAppliedTopology - the last applied Topology
482-
type: string
482+
properties:
483+
name:
484+
description: Name - The Topology CR name that the Service references
485+
type: string
486+
namespace:
487+
description: |-
488+
Namespace - The Namespace to fetch the Topology CR referenced
489+
NOTE: Namespace currently points by default to the same namespace where
490+
the Service is deployed. Customizing the namespace is not supported and
491+
webhooks prevent editing this field to a value different from the
492+
current project
493+
type: string
494+
type: object
483495
networkAttachments:
484496
additionalProperties:
485497
items:

api/bases/designate.openstack.org_designatebackendbind9s.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,19 @@ spec:
451451
type: object
452452
lastAppliedTopology:
453453
description: LastAppliedTopology - the last applied Topology
454-
type: string
454+
properties:
455+
name:
456+
description: Name - The Topology CR name that the Service references
457+
type: string
458+
namespace:
459+
description: |-
460+
Namespace - The Namespace to fetch the Topology CR referenced
461+
NOTE: Namespace currently points by default to the same namespace where
462+
the Service is deployed. Customizing the namespace is not supported and
463+
webhooks prevent editing this field to a value different from the
464+
current project
465+
type: string
466+
type: object
455467
networkAttachments:
456468
additionalProperties:
457469
items:

api/bases/designate.openstack.org_designatecentrals.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,19 @@ spec:
295295
type: object
296296
lastAppliedTopology:
297297
description: LastAppliedTopology - the last applied Topology
298-
type: string
298+
properties:
299+
name:
300+
description: Name - The Topology CR name that the Service references
301+
type: string
302+
namespace:
303+
description: |-
304+
Namespace - The Namespace to fetch the Topology CR referenced
305+
NOTE: Namespace currently points by default to the same namespace where
306+
the Service is deployed. Customizing the namespace is not supported and
307+
webhooks prevent editing this field to a value different from the
308+
current project
309+
type: string
310+
type: object
299311
networkAttachments:
300312
additionalProperties:
301313
items:

api/bases/designate.openstack.org_designatemdnses.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,19 @@ spec:
457457
type: object
458458
lastAppliedTopology:
459459
description: LastAppliedTopology - the last applied Topology
460-
type: string
460+
properties:
461+
name:
462+
description: Name - The Topology CR name that the Service references
463+
type: string
464+
namespace:
465+
description: |-
466+
Namespace - The Namespace to fetch the Topology CR referenced
467+
NOTE: Namespace currently points by default to the same namespace where
468+
the Service is deployed. Customizing the namespace is not supported and
469+
webhooks prevent editing this field to a value different from the
470+
current project
471+
type: string
472+
type: object
461473
networkAttachments:
462474
additionalProperties:
463475
items:

api/bases/designate.openstack.org_designateproducers.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,19 @@ spec:
294294
type: object
295295
lastAppliedTopology:
296296
description: LastAppliedTopology - the last applied Topology
297-
type: string
297+
properties:
298+
name:
299+
description: Name - The Topology CR name that the Service references
300+
type: string
301+
namespace:
302+
description: |-
303+
Namespace - The Namespace to fetch the Topology CR referenced
304+
NOTE: Namespace currently points by default to the same namespace where
305+
the Service is deployed. Customizing the namespace is not supported and
306+
webhooks prevent editing this field to a value different from the
307+
current project
308+
type: string
309+
type: object
298310
networkAttachments:
299311
additionalProperties:
300312
items:

api/bases/designate.openstack.org_designateunbounds.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,19 @@ spec:
382382
type: object
383383
lastAppliedTopology:
384384
description: LastAppliedTopology - the last applied Topology
385-
type: string
385+
properties:
386+
name:
387+
description: Name - The Topology CR name that the Service references
388+
type: string
389+
namespace:
390+
description: |-
391+
Namespace - The Namespace to fetch the Topology CR referenced
392+
NOTE: Namespace currently points by default to the same namespace where
393+
the Service is deployed. Customizing the namespace is not supported and
394+
webhooks prevent editing this field to a value different from the
395+
current project
396+
type: string
397+
type: object
386398
networkAttachments:
387399
additionalProperties:
388400
items:

api/bases/designate.openstack.org_designateworkers.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,19 @@ spec:
284284
type: object
285285
lastAppliedTopology:
286286
description: LastAppliedTopology - the last applied Topology
287-
type: string
287+
properties:
288+
name:
289+
description: Name - The Topology CR name that the Service references
290+
type: string
291+
namespace:
292+
description: |-
293+
Namespace - The Namespace to fetch the Topology CR referenced
294+
NOTE: Namespace currently points by default to the same namespace where
295+
the Service is deployed. Customizing the namespace is not supported and
296+
webhooks prevent editing this field to a value different from the
297+
current project
298+
type: string
299+
type: object
288300
networkAttachments:
289301
additionalProperties:
290302
items:

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414

1515
require (
1616
github.com/onsi/gomega v1.34.1
17-
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250213131341-8e63f078f923
17+
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded
1818
)
1919

2020
require (

api/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo
7272
github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
7373
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
7474
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
75-
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250213131341-8e63f078f923 h1:PpGup24Ri4sgw8UNyaEENy16dUHLIo8i4bpj8hLQWoU=
76-
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250213131341-8e63f078f923/go.mod h1:kkjcOSZ7jkHbVzxJd0nDQzjB+vqafuAMgSf7AnEXydw=
75+
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded h1:09SyMAXgnohPLQGKuvBeR72nxZWXLXI7309RjmYYBUU=
76+
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded/go.mod h1:kkjcOSZ7jkHbVzxJd0nDQzjB+vqafuAMgSf7AnEXydw=
7777
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250211124440-b44f6585b825 h1:46pv5xpwfU03Ik/a520eGb+hJ6ITkup7Li9S9lu0iCU=
7878
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250211124440-b44f6585b825/go.mod h1:56bsoJFKzVDZz/fLoouFfAZFeCW++H6R6thGhvKos1E=
7979
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20250211124440-b44f6585b825 h1:zp77hu95TEs+V6ivfXMegQUlQJQN7cJfQE/sco6ngZM=

api/v1beta1/designate_webhook.go

Lines changed: 89 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ func (r *Designate) ValidateCreate() (admission.Warnings, error) {
124124
var allErrs field.ErrorList
125125
basePath := field.NewPath("spec")
126126

127-
allErrs = r.Spec.ValidateDesignateTopology(basePath, r.Namespace)
128-
if err := r.Spec.ValidateCreate(basePath); err != nil {
127+
if err := r.Spec.ValidateCreate(basePath, r.Namespace); err != nil {
129128
allErrs = append(allErrs, err...)
130129
}
131130

@@ -140,9 +139,11 @@ func (r *Designate) ValidateCreate() (admission.Warnings, error) {
140139

141140
// ValidateCreate - Exported function wrapping non-exported validate functions,
142141
// this function can be called externally to validate an designate spec.
143-
func (r *DesignateSpec) ValidateCreate(basePath *field.Path) field.ErrorList {
142+
func (r *DesignateSpec) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
144143
var allErrs field.ErrorList
145144

145+
allErrs = r.ValidateDesignateTopology(basePath, namespace)
146+
146147
// validate the service override key is valid
147148
allErrs = append(allErrs, service.ValidateRoutedOverrides(
148149
basePath.Child("designateAPI").Child("override").Child("service"),
@@ -151,9 +152,11 @@ func (r *DesignateSpec) ValidateCreate(basePath *field.Path) field.ErrorList {
151152
return allErrs
152153
}
153154

154-
func (r *DesignateSpecCore) ValidateCreate(basePath *field.Path) field.ErrorList {
155+
func (r *DesignateSpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
155156
var allErrs field.ErrorList
156157

158+
allErrs = r.ValidateDesignateTopology(basePath, namespace)
159+
157160
// validate the service override key is valid
158161
allErrs = append(allErrs, service.ValidateRoutedOverrides(
159162
basePath.Child("designateAPI").Child("override").Child("service"),
@@ -174,8 +177,7 @@ func (r *Designate) ValidateUpdate(old runtime.Object) (admission.Warnings, erro
174177
var allErrs field.ErrorList
175178
basePath := field.NewPath("spec")
176179

177-
allErrs = r.Spec.ValidateDesignateTopology(basePath, r.Namespace)
178-
if err := r.Spec.ValidateUpdate(oldDesignate.Spec, basePath); err != nil {
180+
if err := r.Spec.ValidateUpdate(oldDesignate.Spec, basePath, r.Namespace); err != nil {
179181
allErrs = append(allErrs, err...)
180182
}
181183

@@ -190,9 +192,10 @@ func (r *Designate) ValidateUpdate(old runtime.Object) (admission.Warnings, erro
190192

191193
// ValidateUpdate - Exported function wrapping non-exported validate functions,
192194
// this function can be called externally to validate an designate spec.
193-
func (r *DesignateSpec) ValidateUpdate(old DesignateSpec, basePath *field.Path) field.ErrorList {
195+
func (r *DesignateSpec) ValidateUpdate(old DesignateSpec, basePath *field.Path, namespace string) field.ErrorList {
194196
var allErrs field.ErrorList
195197

198+
allErrs = r.ValidateDesignateTopology(basePath, namespace)
196199
// validate the service override key is valid
197200
allErrs = append(allErrs, service.ValidateRoutedOverrides(
198201
basePath.Child("designateAPI").Child("override").Child("service"),
@@ -201,9 +204,10 @@ func (r *DesignateSpec) ValidateUpdate(old DesignateSpec, basePath *field.Path)
201204
return allErrs
202205
}
203206

204-
func (r *DesignateSpecCore) ValidateUpdate(old DesignateSpecCore, basePath *field.Path) field.ErrorList {
207+
func (r *DesignateSpecCore) ValidateUpdate(old DesignateSpecCore, basePath *field.Path, namespace string) field.ErrorList {
205208
var allErrs field.ErrorList
206209

210+
allErrs = r.ValidateDesignateTopology(basePath, namespace)
207211
// validate the service override key is valid
208212
allErrs = append(allErrs, service.ValidateRoutedOverrides(
209213
basePath.Child("designateAPI").Child("override").Child("service"),
@@ -328,3 +332,80 @@ func (spec *DesignateSpec) ValidateDesignateTopology(basePath *field.Path, names
328332

329333
return allErrs
330334
}
335+
336+
// ValidateDesignateTopology - Returns an ErrorList if the Topology is referenced
337+
// on a different namespace
338+
func (spec *DesignateSpecCore) ValidateDesignateTopology(basePath *field.Path, namespace string) field.ErrorList {
339+
var allErrs field.ErrorList
340+
341+
// When a TopologyRef CR is referenced, fail if a different Namespace is
342+
// referenced because is not supported
343+
if spec.TopologyRef != nil {
344+
if err := topologyv1.ValidateTopologyNamespace(spec.TopologyRef.Namespace, *basePath, namespace); err != nil {
345+
allErrs = append(allErrs, err)
346+
}
347+
}
348+
349+
// When a TopologyRef CR is referenced with an override to DesignateAPI, fail
350+
// if a different Namespace is referenced because not supported
351+
if spec.DesignateAPI.TopologyRef != nil {
352+
if err := topologyv1.ValidateTopologyNamespace(spec.DesignateAPI.TopologyRef.Namespace, *basePath, namespace); err != nil {
353+
allErrs = append(allErrs, err)
354+
}
355+
}
356+
357+
// When a TopologyRef CR is referenced with an override to DesignateBackendbind9
358+
// fail if a different Namespace is referenced because not supported
359+
if spec.DesignateBackendbind9.TopologyRef != nil {
360+
if err := topologyv1.ValidateTopologyNamespace(spec.DesignateBackendbind9.TopologyRef.Namespace, *basePath, namespace); err != nil {
361+
allErrs = append(allErrs, err)
362+
}
363+
}
364+
365+
// When a TopologyRef CR is referenced with an override to an instance of
366+
// DesignateCentral, fail if a different Namespace is referenced because not
367+
// supported
368+
if spec.DesignateCentral.TopologyRef != nil {
369+
if err := topologyv1.ValidateTopologyNamespace(spec.DesignateCentral.TopologyRef.Namespace, *basePath, namespace); err != nil {
370+
allErrs = append(allErrs, err)
371+
}
372+
}
373+
374+
// When a TopologyRef CR is referenced with an override to an instance of
375+
// DesignateMDNS, fail if a different Namespace is referenced because not
376+
// supported
377+
if spec.DesignateMdns.TopologyRef != nil {
378+
if err := topologyv1.ValidateTopologyNamespace(spec.DesignateMdns.TopologyRef.Namespace, *basePath, namespace); err != nil {
379+
allErrs = append(allErrs, err)
380+
}
381+
}
382+
383+
// When a TopologyRef CR is referenced with an override to an instance of
384+
// DesignateProducer, fail if a different Namespace is referenced because not
385+
// supported
386+
if spec.DesignateProducer.TopologyRef != nil {
387+
if err := topologyv1.ValidateTopologyNamespace(spec.DesignateProducer.TopologyRef.Namespace, *basePath, namespace); err != nil {
388+
allErrs = append(allErrs, err)
389+
}
390+
}
391+
392+
// When a TopologyRef CR is referenced with an override to an instance of
393+
// DesignateUnbound, fail if a different Namespace is referenced because not
394+
// supported
395+
if spec.DesignateUnbound.TopologyRef != nil {
396+
if err := topologyv1.ValidateTopologyNamespace(spec.DesignateUnbound.TopologyRef.Namespace, *basePath, namespace); err != nil {
397+
allErrs = append(allErrs, err)
398+
}
399+
}
400+
401+
// When a TopologyRef CR is referenced with an override to an instance of
402+
// DesignateWorker, fail if a different Namespace is referenced because not
403+
// supported
404+
if spec.DesignateWorker.TopologyRef != nil {
405+
if err := topologyv1.ValidateTopologyNamespace(spec.DesignateWorker.TopologyRef.Namespace, *basePath, namespace); err != nil {
406+
allErrs = append(allErrs, err)
407+
}
408+
}
409+
410+
return allErrs
411+
}

0 commit comments

Comments
 (0)