From 068e8f10d87dbbe7bb3a18929f30401b0cd46ce6 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Tue, 24 Sep 2024 18:16:02 -0700 Subject: [PATCH] Add ClusterInfo Signed-off-by: Tamal Saha --- api/v1/cluster.go | 25 ++++++++++++++++++++++--- api/v1/zz_generated.deepcopy.go | 22 ++++++++++++++++++++++ cluster/lib.go | 8 ++++---- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/api/v1/cluster.go b/api/v1/cluster.go index 1de796faf..9f71971dd 100644 --- a/api/v1/cluster.go +++ b/api/v1/cluster.go @@ -153,7 +153,26 @@ func (cm ClusterManager) String() string { } type CAPIClusterInfo struct { - Provider string `json:"provider,omitempty"` - Namespace string `json:"namespace,omitempty"` - ClusterName string `json:"clusterName,omitempty"` + Provider CAPIProvider `json:"provider,omitempty"` + Namespace string `json:"namespace,omitempty"` + ClusterName string `json:"clusterName,omitempty"` } + +// ClusterInfo used in ace-installer +type ClusterInfo struct { + UID string `json:"uid"` + Name string `json:"name"` + ClusterManagers []string `json:"clusterManagers"` + // +optional + CAPI CAPIClusterInfo `json:"capi"` +} + +// +kubebuilder:validation:Enum=capa;capg;capz +type CAPIProvider string + +const ( + CAPIProviderDisabled CAPIProvider = "" + CAPIProviderCAPA CAPIProvider = "capa" + CAPIProviderCAPG CAPIProvider = "capg" + CAPIProviderCAPZ CAPIProvider = "capz" +) diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index fd286ac41..9e3330952 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -119,6 +119,28 @@ func (in *CertificateSpec) DeepCopy() *CertificateSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterInfo) DeepCopyInto(out *ClusterInfo) { + *out = *in + if in.ClusterManagers != nil { + in, out := &in.ClusterManagers, &out.ClusterManagers + *out = make([]string, len(*in)) + copy(*out, *in) + } + out.CAPI = in.CAPI + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterInfo. +func (in *ClusterInfo) DeepCopy() *ClusterInfo { + if in == nil { + return nil + } + out := new(ClusterInfo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterMetadata) DeepCopyInto(out *ClusterMetadata) { *out = *in diff --git a/cluster/lib.go b/cluster/lib.go index c1a9cedd1..1069ab033 100644 --- a/cluster/lib.go +++ b/cluster/lib.go @@ -211,14 +211,14 @@ func getCAPIValues(values map[string]any) (string, string, string, error) { return capiProvider, clusterName, ns, nil } -func getProviderName(kind string) string { +func getProviderName(kind string) kmapi.CAPIProvider { switch kind { case "AWSManagedCluster", "AWSManagedControlPlane": - return "capa" + return kmapi.CAPIProviderCAPA case "AzureManagedCluster": - return "capz" + return kmapi.CAPIProviderCAPZ case "GCPManagedCluster": - return "capg" + return kmapi.CAPIProviderCAPG } return "" }