Skip to content

Commit 49ab890

Browse files
Merge pull request #517 from fmount/topologyref
Update LastAppliedTopology to TopologyRef interface
2 parents ae9a664 + 9e44794 commit 49ab890

28 files changed

+319
-238
lines changed

api/bases/ironic.openstack.org_ironicapis.yaml

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

api/bases/ironic.openstack.org_ironicconductors.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,19 @@ spec:
342342
type: object
343343
lastAppliedTopology:
344344
description: LastAppliedTopology - the last applied Topology
345-
type: string
345+
properties:
346+
name:
347+
description: Name - The Topology CR name that the Service references
348+
type: string
349+
namespace:
350+
description: |-
351+
Namespace - The Namespace to fetch the Topology CR referenced
352+
NOTE: Namespace currently points by default to the same namespace where
353+
the Service is deployed. Customizing the namespace is not supported and
354+
webhooks prevent editing this field to a value different from the
355+
current project
356+
type: string
357+
type: object
346358
networkAttachments:
347359
additionalProperties:
348360
items:

api/bases/ironic.openstack.org_ironicinspectors.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,19 @@ spec:
531531
type: object
532532
lastAppliedTopology:
533533
description: LastAppliedTopology - the last applied Topology
534-
type: string
534+
properties:
535+
name:
536+
description: Name - The Topology CR name that the Service references
537+
type: string
538+
namespace:
539+
description: |-
540+
Namespace - The Namespace to fetch the Topology CR referenced
541+
NOTE: Namespace currently points by default to the same namespace where
542+
the Service is deployed. Customizing the namespace is not supported and
543+
webhooks prevent editing this field to a value different from the
544+
current project
545+
type: string
546+
type: object
535547
networkAttachments:
536548
additionalProperties:
537549
items:

api/bases/ironic.openstack.org_ironicneutronagents.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,19 @@ spec:
250250
type: object
251251
lastAppliedTopology:
252252
description: LastAppliedTopology - the last applied Topology
253-
type: string
253+
properties:
254+
name:
255+
description: Name - The Topology CR name that the Service references
256+
type: string
257+
namespace:
258+
description: |-
259+
Namespace - The Namespace to fetch the Topology CR referenced
260+
NOTE: Namespace currently points by default to the same namespace where
261+
the Service is deployed. Customizing the namespace is not supported and
262+
webhooks prevent editing this field to a value different from the
263+
current project
264+
type: string
265+
type: object
254266
observedGeneration:
255267
description: |-
256268
ObservedGeneration - the most recent generation observed for this

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.21
55
require (
66
github.com/onsi/ginkgo/v2 v2.20.1
77
github.com/onsi/gomega v1.34.1
8-
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250210183624-a8bf66784d6d
8+
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded
99
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250205143454-43504d7ad19a
1010
k8s.io/api v0.29.14
1111
k8s.io/apimachinery v0.29.14

api/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
7474
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
7575
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6Beb1gQ96Ptej9AE/BvwCBiRj1E=
7676
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
77-
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250210183624-a8bf66784d6d h1:JuIcZjfFUH9G68MR9F62xBK4eS5F2P5nKVCoDXFrvQM=
78-
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250210183624-a8bf66784d6d/go.mod h1:kkjcOSZ7jkHbVzxJd0nDQzjB+vqafuAMgSf7AnEXydw=
77+
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded h1:09SyMAXgnohPLQGKuvBeR72nxZWXLXI7309RjmYYBUU=
78+
github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250218115938-ae95bdfefded/go.mod h1:kkjcOSZ7jkHbVzxJd0nDQzjB+vqafuAMgSf7AnEXydw=
7979
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250205143454-43504d7ad19a h1:3LuUgB85VxGD6lmVOeZelYEASmytkrzaudU014PN7xw=
8080
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250205143454-43504d7ad19a/go.mod h1:KxnNSUk15llkKTSq/bQEE7pnc0IMk44fxhoBRpimMa8=
8181
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=

api/v1beta1/ironic_webhook.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ func (r *Ironic) ValidateCreate() (admission.Warnings, error) {
106106
var allErrs field.ErrorList
107107
basePath := field.NewPath("spec")
108108

109-
allErrs = r.Spec.ValidateIronicTopology(basePath, r.Namespace)
110-
if err := r.Spec.ValidateCreate(basePath); err != nil {
109+
if err := r.Spec.ValidateCreate(basePath, r.Namespace); err != nil {
111110
allErrs = append(allErrs, err...)
112111
}
113112

@@ -122,11 +121,11 @@ func (r *Ironic) ValidateCreate() (admission.Warnings, error) {
122121

123122
// ValidateCreate - Exported function wrapping non-exported validate functions,
124123
// this function can be called externally to validate an ironic spec.
125-
func (spec *IronicSpec) ValidateCreate(basePath *field.Path) field.ErrorList {
126-
return spec.IronicSpecCore.ValidateCreate(basePath)
124+
func (spec *IronicSpec) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
125+
return spec.IronicSpecCore.ValidateCreate(basePath, namespace)
127126
}
128127

129-
func (spec *IronicSpecCore) ValidateCreate(basePath *field.Path) field.ErrorList {
128+
func (spec *IronicSpecCore) ValidateCreate(basePath *field.Path, namespace string) field.ErrorList {
130129
var allErrs field.ErrorList
131130

132131
if err := validateRPCTransport(spec, basePath); err != nil {
@@ -157,6 +156,7 @@ func (spec *IronicSpecCore) ValidateCreate(basePath *field.Path) field.ErrorList
157156
allErrs = append(allErrs, err...)
158157
}
159158

159+
allErrs = append(allErrs, spec.ValidateIronicTopology(basePath, namespace)...)
160160
return allErrs
161161
}
162162

@@ -172,8 +172,7 @@ func (r *Ironic) ValidateUpdate(old runtime.Object) (admission.Warnings, error)
172172
var allErrs field.ErrorList
173173
basePath := field.NewPath("spec")
174174

175-
allErrs = r.Spec.ValidateIronicTopology(basePath, r.Namespace)
176-
if err := r.Spec.ValidateUpdate(oldIronic.Spec, basePath); err != nil {
175+
if err := r.Spec.ValidateUpdate(oldIronic.Spec, basePath, r.Namespace); err != nil {
177176
allErrs = append(allErrs, err...)
178177
}
179178

@@ -188,11 +187,11 @@ func (r *Ironic) ValidateUpdate(old runtime.Object) (admission.Warnings, error)
188187

189188
// ValidateUpdate - Exported function wrapping non-exported validate functions,
190189
// this function can be called externally to validate an ironic spec.
191-
func (spec *IronicSpec) ValidateUpdate(old IronicSpec, basePath *field.Path) field.ErrorList {
192-
return spec.IronicSpecCore.ValidateUpdate(old.IronicSpecCore, basePath)
190+
func (spec *IronicSpec) ValidateUpdate(old IronicSpec, basePath *field.Path, namespace string) field.ErrorList {
191+
return spec.IronicSpecCore.ValidateUpdate(old.IronicSpecCore, basePath, namespace)
193192
}
194193

195-
func (spec *IronicSpecCore) ValidateUpdate(old IronicSpecCore, basePath *field.Path) field.ErrorList {
194+
func (spec *IronicSpecCore) ValidateUpdate(old IronicSpecCore, basePath *field.Path, namespace string) field.ErrorList {
196195
var allErrs field.ErrorList
197196

198197
if err := validateRPCTransport(spec, basePath); err != nil {
@@ -223,6 +222,7 @@ func (spec *IronicSpecCore) ValidateUpdate(old IronicSpecCore, basePath *field.P
223222
allErrs = append(allErrs, err...)
224223
}
225224

225+
allErrs = append(allErrs, spec.ValidateIronicTopology(basePath, namespace)...)
226226
return allErrs
227227
}
228228

@@ -607,7 +607,7 @@ func (spec *IronicSpecCore) Default() {
607607

608608
// ValidateIronicTopology - Returns an ErrorList if the Topology is referenced
609609
// on a different namespace
610-
func (spec *IronicSpec) ValidateIronicTopology(basePath *field.Path, namespace string) field.ErrorList {
610+
func (spec *IronicSpecCore) ValidateIronicTopology(basePath *field.Path, namespace string) field.ErrorList {
611611
var allErrs field.ErrorList
612612

613613
// When a TopologyRef CR is referenced, fail if a different Namespace is

api/v1beta1/ironicapi_types.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/openstack-k8s-operators/lib-common/modules/common/endpoint"
2424
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
2525
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
26+
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
2627
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2728
)
2829

@@ -137,7 +138,7 @@ type IronicAPIStatus struct {
137138
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
138139

139140
// LastAppliedTopology - the last applied Topology
140-
LastAppliedTopology string `json:"lastAppliedTopology,omitempty"`
141+
LastAppliedTopology *topologyv1.TopoRef `json:"lastAppliedTopology,omitempty"`
141142
}
142143

143144
//+kubebuilder:object:root=true
@@ -201,3 +202,18 @@ func (instance IronicAPI) RbacResourceName() string {
201202
}
202203
return "ironicapi-" + instance.Name
203204
}
205+
206+
// GetSpecTopologyRef - Returns the LastAppliedTopology Set in the Status
207+
func (instance *IronicAPI) GetSpecTopologyRef() *topologyv1.TopoRef {
208+
return instance.Spec.TopologyRef
209+
}
210+
211+
// GetLastAppliedTopology - Returns the LastAppliedTopology Set in the Status
212+
func (instance *IronicAPI) GetLastAppliedTopology() *topologyv1.TopoRef {
213+
return instance.Status.LastAppliedTopology
214+
}
215+
216+
// SetLastAppliedTopology - Sets the LastAppliedTopology value in the Status
217+
func (instance *IronicAPI) SetLastAppliedTopology(topologyRef *topologyv1.TopoRef) {
218+
instance.Status.LastAppliedTopology = topologyRef
219+
}

api/v1beta1/ironicconductor_types.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
2121
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
2324
)
2425

2526
// IronicConductorTemplate defines the input parameters for Ironic Conductor service
@@ -142,7 +143,7 @@ type IronicConductorStatus struct {
142143
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
143144

144145
// LastAppliedTopology - the last applied Topology
145-
LastAppliedTopology string `json:"lastAppliedTopology,omitempty"`
146+
LastAppliedTopology *topologyv1.TopoRef `json:"lastAppliedTopology,omitempty"`
146147
}
147148

148149
//+kubebuilder:object:root=true
@@ -196,3 +197,18 @@ func (instance IronicConductor) RbacResourceName() string {
196197
}
197198
return "ironicconductor-" + instance.Name
198199
}
200+
201+
// GetSpecTopologyRef - Returns the LastAppliedTopology Set in the Status
202+
func (instance *IronicConductor) GetSpecTopologyRef() *topologyv1.TopoRef {
203+
return instance.Spec.TopologyRef
204+
}
205+
206+
// GetLastAppliedTopology - Returns the LastAppliedTopology Set in the Status
207+
func (instance *IronicConductor) GetLastAppliedTopology() *topologyv1.TopoRef {
208+
return instance.Status.LastAppliedTopology
209+
}
210+
211+
// SetLastAppliedTopology - Sets the LastAppliedTopology value in the Status
212+
func (instance *IronicConductor) SetLastAppliedTopology(topologyRef *topologyv1.TopoRef) {
213+
instance.Status.LastAppliedTopology = topologyRef
214+
}

api/v1beta1/ironicinspector_types.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ type IronicInspectorStatus struct {
210210
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
211211

212212
// LastAppliedTopology - the last applied Topology
213-
LastAppliedTopology string `json:"lastAppliedTopology,omitempty"`
213+
LastAppliedTopology *topologyv1.TopoRef `json:"lastAppliedTopology,omitempty"`
214214
}
215215

216216
//+kubebuilder:object:root=true
@@ -264,3 +264,18 @@ func (instance IronicInspector) RbacResourceName() string {
264264
}
265265
return "ironicinspector-" + instance.Name
266266
}
267+
268+
// GetSpecTopologyRef - Returns the LastAppliedTopology Set in the Status
269+
func (instance *IronicInspector) GetSpecTopologyRef() *topologyv1.TopoRef {
270+
return instance.Spec.TopologyRef
271+
}
272+
273+
// GetLastAppliedTopology - Returns the LastAppliedTopology Set in the Status
274+
func (instance *IronicInspector) GetLastAppliedTopology() *topologyv1.TopoRef {
275+
return instance.Status.LastAppliedTopology
276+
}
277+
278+
// SetLastAppliedTopology - Sets the LastAppliedTopology value in the Status
279+
func (instance *IronicInspector) SetLastAppliedTopology(topologyRef *topologyv1.TopoRef) {
280+
instance.Status.LastAppliedTopology = topologyRef
281+
}

0 commit comments

Comments
 (0)