Skip to content

Commit ae1cb19

Browse files
Add classNamespace to topology
Signed-off-by: Danil-Grigorev <[email protected]>
1 parent e75b4e7 commit ae1cb19

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

api/v1beta1/cluster_types.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"cmp"
2021
"fmt"
2122
"net"
2223
"strings"
@@ -100,6 +101,11 @@ type Topology struct {
100101
// The name of the ClusterClass object to create the topology.
101102
Class string `json:"class"`
102103

104+
// The namespace of the ClusterClass object to create the topology.
105+
//
106+
// +optional
107+
ClassNamespace string `json:"classNamespace,omitempty"`
108+
103109
// The Kubernetes version of the cluster.
104110
Version string `json:"version"`
105111

@@ -628,7 +634,8 @@ func (c *Cluster) GetClassKey() types.NamespacedName {
628634
if c.Spec.Topology == nil {
629635
return types.NamespacedName{}
630636
}
631-
return types.NamespacedName{Namespace: c.GetNamespace(), Name: c.Spec.Topology.Class}
637+
namespace := cmp.Or(c.Spec.Topology.ClassNamespace, c.GetNamespace())
638+
return types.NamespacedName{Namespace: namespace, Name: c.Spec.Topology.Class}
632639
}
633640

634641
// GetConditions returns the set of conditions for this object.

api/v1beta1/zz_generated.openapi.go

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/clusterctl/client/cluster/topology.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ func (t *topologyClient) affectedClusters(ctx context.Context, in *TopologyPlanI
704704
for _, cc := range affectedClusterClasses {
705705
for i := range clusterList.Items {
706706
cluster := clusterList.Items[i]
707-
if cluster.Spec.Topology != nil && cluster.GetClassKey().Name == cc.Name {
707+
if cluster.Spec.Topology != nil && cluster.GetClassKey().Name == cc.Name && cluster.GetClassKey().Namespace == cc.Namespace {
708708
affectedClusters[client.ObjectKeyFromObject(&clusterList.Items[i])] = true
709709
}
710710
}

config/crd/bases/cluster.x-k8s.io_clusters.yaml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/apis/core/v1alpha4/zz_generated.conversion.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)