Skip to content

Commit d070789

Browse files
committed
Align LastAppliedTopology to TopologyRef interface
While TopologyRef is able to reference Name and namespace, we currently only save TopologyRef.Name to .Status.LastAppliedTopology. This patch aligns both interfaces to use the same type in the same form. In addition, some logic is moved to infra-operator because is common to all operators, and this patch also adopts this new form. Signed-off-by: Francesco Pantano <fpantano@redhat.com>
1 parent 32c9f26 commit d070789

27 files changed

+221
-182
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/ironicapi_types.go

Lines changed: 7 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,8 @@ func (instance IronicAPI) RbacResourceName() string {
201202
}
202203
return "ironicapi-" + instance.Name
203204
}
205+
206+
// GetLastAppliedTopology - Returns the LastAppliedTopology Set in the Status
207+
func (instance IronicAPI) GetLastAppliedTopology() *topologyv1.TopoRef {
208+
return instance.Status.LastAppliedTopology
209+
}

api/v1beta1/ironicconductor_types.go

Lines changed: 7 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,8 @@ func (instance IronicConductor) RbacResourceName() string {
196197
}
197198
return "ironicconductor-" + instance.Name
198199
}
200+
201+
// GetLastAppliedTopology - Returns the LastAppliedTopology Set in the Status
202+
func (instance IronicConductor) GetLastAppliedTopology() *topologyv1.TopoRef {
203+
return instance.Status.LastAppliedTopology
204+
}

api/v1beta1/ironicinspector_types.go

Lines changed: 6 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,8 @@ func (instance IronicInspector) RbacResourceName() string {
264264
}
265265
return "ironicinspector-" + instance.Name
266266
}
267+
268+
// GetLastAppliedTopology - Returns the LastAppliedTopology Set in the Status
269+
func (instance IronicInspector) GetLastAppliedTopology() *topologyv1.TopoRef {
270+
return instance.Status.LastAppliedTopology
271+
}

api/v1beta1/ironicneutronagent_types.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1beta1
1818

1919
import (
2020
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
21+
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
2122
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
2223
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324
)
@@ -84,7 +85,7 @@ type IronicNeutronAgentStatus struct {
8485
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
8586

8687
// LastAppliedTopology - the last applied Topology
87-
LastAppliedTopology string `json:"lastAppliedTopology,omitempty"`
88+
LastAppliedTopology *topologyv1.TopoRef `json:"lastAppliedTopology,omitempty"`
8889
}
8990

9091
//+kubebuilder:object:root=true
@@ -141,3 +142,8 @@ func (instance IronicNeutronAgent) RbacResourceName() string {
141142
}
142143
return "ironicneutronagent-" + instance.Name
143144
}
145+
146+
// GetLastAppliedTopology - Returns the LastAppliedTopology Set in the Status
147+
func (instance IronicNeutronAgent) GetLastAppliedTopology() *topologyv1.TopoRef {
148+
return instance.Status.LastAppliedTopology
149+
}

0 commit comments

Comments
 (0)