Skip to content

Commit c5f4e23

Browse files
committed
clusterctl: allow Namespace objects in topology plan input
1 parent eecabe4 commit c5f4e23

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cmd/clusterctl/client/cluster/assets/topology-test/new-clusterclass-and-cluster.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: default
5+
spec: {}
6+
---
17
apiVersion: cluster.x-k8s.io/v1beta1
28
kind: ClusterClass
39
metadata:

cmd/clusterctl/client/cluster/topology.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,13 @@ func clusterClassUsesTemplate(cc *clusterv1.ClusterClass, templateRef *corev1.Ob
681681
func uniqueNamespaces(objs []*unstructured.Unstructured) []string {
682682
ns := sets.NewString()
683683
for _, obj := range objs {
684+
// Namespace objects do not have metadata.namespace set, but we can add the
685+
// name of the obj to the namespace list, as it is another unique namespace.
686+
if obj.GroupVersionKind().Kind == "Namespace" && obj.GroupVersionKind().Group == "" {
687+
ns.Insert(obj.GetName())
688+
continue
689+
}
690+
684691
// Note: treat empty namespace (namespace not set) as a unique namespace.
685692
// If some have a namespace set and some do not. It is safer to consider them as
686693
// objects from different namespaces.

0 commit comments

Comments
 (0)