Skip to content

Commit 43cb995

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

File tree

6 files changed

+22
-2
lines changed

6 files changed

+22
-2
lines changed

Diff for: 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.

Diff for: 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.

Diff for: 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
}

Diff for: 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.

Diff for: internal/apis/core/v1alpha4/conversion.go

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error {
4242
if dst.Spec.Topology == nil {
4343
dst.Spec.Topology = &clusterv1.Topology{}
4444
}
45+
dst.Spec.Topology.ClassNamespace = restored.Spec.Topology.ClassNamespace
4546
dst.Spec.Topology.Variables = restored.Spec.Topology.Variables
4647
dst.Spec.Topology.ControlPlane.Variables = restored.Spec.Topology.ControlPlane.Variables
4748

Diff for: 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)