Skip to content

Commit 121265d

Browse files
Merge pull request #240 from fmount/topology_optimize
Optmize handling topology logic
2 parents 8a46bbf + 2506a2c commit 121265d

File tree

7 files changed

+8
-35
lines changed

7 files changed

+8
-35
lines changed

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.6.1-0.20250403063905-eb287d52f38d
8+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462
99
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250408123225-0d9e9b82c41b
1010
k8s.io/api v0.29.15
1111
k8s.io/apimachinery v0.29.15

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.6.1-0.20250403063905-eb287d52f38d h1:/C+ysubV00VYrqGFhQlDeQ5tUtnhIWPwQUc8MOfCEBA=
76-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250403063905-eb287d52f38d/go.mod h1:IY5zp1GRhacGMvjZMUZQ0LlxWDaogIRb/4H3by1Pivk=
75+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462 h1:hWdJM9hB/GSFjXc7E7b9L+2H4ZfCOxygceMiYXR4kKc=
76+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462/go.mod h1:+l+sclC6YCRcLcvS3UEGKBf8xya8aExMrmHeA9tMg+k=
7777
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250408123225-0d9e9b82c41b h1:T+N6xOT2NP+hVp2K1xl/NV3uheVHu38CcBuW+8uOBYw=
7878
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250408123225-0d9e9b82c41b/go.mod h1:A9Ohw5Q90YOGhcDF4ZHkMr5RArz3phoBu9+ibbYDKG4=
7979
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=

controllers/barbican_common.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,6 @@ type topologyHandler interface {
4444
SetLastAppliedTopology(t *topologyv1.TopoRef)
4545
}
4646

47-
// GetLastAppliedTopologyRef - Returns a TopoRef object that can be passed to the
48-
// Handle topology logic
49-
func GetLastAppliedTopologyRef(t topologyHandler, ns string) *topologyv1.TopoRef {
50-
lastAppliedTopologyName := ""
51-
if l := t.GetLastAppliedTopology(); l != nil {
52-
lastAppliedTopologyName = l.Name
53-
}
54-
return &topologyv1.TopoRef{
55-
Name: lastAppliedTopologyName,
56-
Namespace: ns,
57-
}
58-
}
59-
6047
func ensureTopology(
6148
ctx context.Context,
6249
helper *helper.Helper,
@@ -70,7 +57,7 @@ func ensureTopology(
7057
ctx,
7158
helper,
7259
instance.GetSpecTopologyRef(),
73-
GetLastAppliedTopologyRef(instance, helper.GetBefore().GetNamespace()),
60+
instance.GetLastAppliedTopology(),
7461
finalizer,
7562
defaultLabelSelector,
7663
)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/onsi/ginkgo/v2 v2.20.1
1010
github.com/onsi/gomega v1.34.1
1111
github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-00010101000000-000000000000
12-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250403063905-eb287d52f38d
12+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462
1313
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250406092234-10f5f7e5b5a9
1414
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250408123225-0d9e9b82c41b
1515
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20250402133843-5a4c5f4fb4f1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
7878
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
7979
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6Beb1gQ96Ptej9AE/BvwCBiRj1E=
8080
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
81-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250403063905-eb287d52f38d h1:/C+ysubV00VYrqGFhQlDeQ5tUtnhIWPwQUc8MOfCEBA=
82-
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250403063905-eb287d52f38d/go.mod h1:IY5zp1GRhacGMvjZMUZQ0LlxWDaogIRb/4H3by1Pivk=
81+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462 h1:hWdJM9hB/GSFjXc7E7b9L+2H4ZfCOxygceMiYXR4kKc=
82+
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250414173555-d17cbc245462/go.mod h1:+l+sclC6YCRcLcvS3UEGKBf8xya8aExMrmHeA9tMg+k=
8383
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250406092234-10f5f7e5b5a9 h1:Q1yMkuwIOCtGQJDsKYAbspJU5b6emRvoKw5VyPXfiak=
8484
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250406092234-10f5f7e5b5a9/go.mod h1:klMsoleakNm0dfNR9ePkL5pNZQsIyx4WMLaHDKIkTt4=
8585
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250408123225-0d9e9b82c41b h1:T+N6xOT2NP+hVp2K1xl/NV3uheVHu38CcBuW+8uOBYw=

tests/functional/barbican_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ var _ = Describe("Barbican controller", func() {
402402
topologySpec := GetSampleTopologySpec()
403403
// Create Test Topologies
404404
for _, t := range barbicanTest.BarbicanTopologies {
405-
CreateTopology(t, topologySpec)
405+
infra.CreateTopology(t, topologySpec)
406406
}
407407
spec := GetDefaultBarbicanSpec()
408408
spec["topologyRef"] = map[string]interface{}{

tests/functional/base_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -329,20 +329,6 @@ func GetSampleTopologySpec() map[string]interface{} {
329329
return topologySpec
330330
}
331331

332-
// CreateTopology - Creates a Topology CR based on the spec passed as input
333-
func CreateTopology(topology types.NamespacedName, spec map[string]interface{}) client.Object {
334-
raw := map[string]interface{}{
335-
"apiVersion": "topology.openstack.org/v1beta1",
336-
"kind": "Topology",
337-
"metadata": map[string]interface{}{
338-
"name": topology.Name,
339-
"namespace": topology.Namespace,
340-
},
341-
"spec": spec,
342-
}
343-
return th.CreateUnstructured(raw)
344-
}
345-
346332
// GetBarbicanAPISpec -
347333
func GetBarbicanAPISpec(name types.NamespacedName) barbicanv1.BarbicanAPITemplate {
348334
instance := &barbicanv1.BarbicanAPI{}

0 commit comments

Comments
 (0)