Skip to content

Commit

Permalink
Add classNamespace to topology
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Oct 30, 2024
1 parent e75b4e7 commit ae1cb19
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
9 changes: 8 additions & 1 deletion api/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta1

import (
"cmp"
"fmt"
"net"
"strings"
Expand Down Expand Up @@ -100,6 +101,11 @@ type Topology struct {
// The name of the ClusterClass object to create the topology.
Class string `json:"class"`

// The namespace of the ClusterClass object to create the topology.
//
// +optional
ClassNamespace string `json:"classNamespace,omitempty"`

// The Kubernetes version of the cluster.
Version string `json:"version"`

Expand Down Expand Up @@ -628,7 +634,8 @@ func (c *Cluster) GetClassKey() types.NamespacedName {
if c.Spec.Topology == nil {
return types.NamespacedName{}
}
return types.NamespacedName{Namespace: c.GetNamespace(), Name: c.Spec.Topology.Class}
namespace := cmp.Or(c.Spec.Topology.ClassNamespace, c.GetNamespace())
return types.NamespacedName{Namespace: namespace, Name: c.Spec.Topology.Class}
}

// GetConditions returns the set of conditions for this object.
Expand Down
7 changes: 7 additions & 0 deletions api/v1beta1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ func (t *topologyClient) affectedClusters(ctx context.Context, in *TopologyPlanI
for _, cc := range affectedClusterClasses {
for i := range clusterList.Items {
cluster := clusterList.Items[i]
if cluster.Spec.Topology != nil && cluster.GetClassKey().Name == cc.Name {
if cluster.Spec.Topology != nil && cluster.GetClassKey().Name == cc.Name && cluster.GetClassKey().Namespace == cc.Namespace {
affectedClusters[client.ObjectKeyFromObject(&clusterList.Items[i])] = true
}
}
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/cluster.x-k8s.io_clusters.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/apis/core/v1alpha4/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ae1cb19

Please sign in to comment.