Skip to content

Commit 05ae37f

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

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

api/v1beta1/cluster_types.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ type Topology struct {
100100
// The name of the ClusterClass object to create the topology.
101101
Class string `json:"class"`
102102

103+
// The namespace of the ClusterClass object to create the topology.
104+
//
105+
// +optional
106+
ClassNamespace string `json:"classNamespace,omitempty"`
107+
103108
// The Kubernetes version of the cluster.
104109
Version string `json:"version"`
105110

@@ -628,7 +633,17 @@ func (c *Cluster) GetClassKey() types.NamespacedName {
628633
if c.Spec.Topology == nil {
629634
return types.NamespacedName{}
630635
}
631-
return types.NamespacedName{Namespace: c.GetNamespace(), Name: c.Spec.Topology.Class}
636+
637+
return types.NamespacedName{Namespace: c.GetInfrastructureNamespace(), Name: c.Spec.Topology.Class}
638+
}
639+
640+
// GetInfrastructureNamespace returns common namespace for the cluster infrastructure
641+
func (c *Cluster) GetInfrastructureNamespace() string {
642+
if c.Spec.Topology == nil || c.Spec.Topology.ClassNamespace == "" {
643+
return c.Namespace
644+
}
645+
646+
return c.Spec.Topology.ClassNamespace
632647
}
633648

634649
// 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.

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/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

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)