From c80354a395c5cee32b6462c805bbe63c09ef722e Mon Sep 17 00:00:00 2001 From: Sivaanand Murugesan Date: Fri, 27 Oct 2023 20:45:04 +0530 Subject: [PATCH 1/2] PLT-661:Added Cluster profile support for cluster group --- client/cluster_group.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/client/cluster_group.go b/client/cluster_group.go index 47937f30..47e8780a 100644 --- a/client/cluster_group.go +++ b/client/cluster_group.go @@ -210,6 +210,25 @@ func (h *V1Client) UpdateClusterGroup(uid string, clusterGroup *models.V1Cluster return err } +func (h *V1Client) UpdateClusterProfileInClusterGroup(clusterGroupContext string, clusterGroupUid string, clusterProfiles *models.V1SpectroClusterProfiles) error { + client, err := h.GetClusterClient() + if err != nil { + return err + } + var params *clusterC.V1ClusterGroupsUIDProfilesUpdateParams + switch clusterGroupContext { + case "project": + params = clusterC.NewV1ClusterGroupsUIDProfilesUpdateParamsWithContext(h.Ctx).WithUID(clusterGroupUid) + case "tenant": + params = clusterC.NewV1ClusterGroupsUIDProfilesUpdateParams().WithUID(clusterGroupUid) + default: + return errors.New("invalid scope") + } + params = params.WithBody(clusterProfiles) + _, err = client.V1ClusterGroupsUIDProfilesUpdate(params) + return err +} + func (h *V1Client) getClusterGroupMetadata(clusterGroupContext string) ([]*models.V1ObjectScopeEntity, error) { client, err := h.GetClusterClient() if err != nil { From 3703c4cd8d94e8133ce29ebbdabaa1413a3c3bb9 Mon Sep 17 00:00:00 2001 From: Sivaanand Murugesan Date: Mon, 30 Oct 2023 10:55:29 +0530 Subject: [PATCH 2/2] addressed review comment --- client/cluster_group.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/cluster_group.go b/client/cluster_group.go index 47e8780a..400b41c7 100644 --- a/client/cluster_group.go +++ b/client/cluster_group.go @@ -25,7 +25,7 @@ func (h *V1Client) CreateClusterGroup(cluster *models.V1ClusterGroupEntity, scop case "tenant": params = clusterC.NewV1ClusterGroupsCreateParams().WithBody(cluster) default: - return "", errors.New("invalid scope") + return "", errors.New("invalid scope " + scope) } success, err := client.V1ClusterGroupsCreate(params) if err != nil { @@ -50,7 +50,7 @@ func (h *V1Client) DeleteClusterGroup(uid, scope string) error { case "tenant": params = clusterC.NewV1ClusterGroupsUIDDeleteParams().WithUID(uid) default: - return errors.New("invalid scope") + return errors.New("invalid scope " + scope) } _, err = client.V1ClusterGroupsUIDDelete(params) return err @@ -85,7 +85,7 @@ func (h *V1Client) GetClusterGroupWithoutStatus(uid, scope string) (*models.V1Cl case "tenant": params = clusterC.NewV1ClusterGroupsUIDGetParams().WithUID(uid) default: - return nil, errors.New("invalid scope") + return nil, errors.New("invalid scope " + scope) } success, err := client.V1ClusterGroupsUIDGet(params) if e, ok := err.(*transport.TransportError); ok && e.HttpCode == 404 { @@ -151,7 +151,7 @@ func (h *V1Client) GetClusterGroupSummaries(clusterGroupContext string) ([]*mode case "tenant": params = clusterC.NewV1ClusterGroupsHostClusterSummaryParamsWithContext(h.Ctx) default: - return nil, errors.New("invalid scope") + return nil, errors.New("invalid scope " + clusterGroupContext) } resp, err := client.V1ClusterGroupsHostClusterSummary(params) @@ -176,7 +176,7 @@ func (h *V1Client) UpdateClusterGroupMeta(clusterGroup *models.V1ClusterGroupEnt case "tenant": params = clusterC.NewV1ClusterGroupsUIDMetaUpdateParams().WithUID(clusterGroup.Metadata.UID) default: - return errors.New("invalid scope") + return errors.New("invalid scope " + scope) } params = params.WithBody(&models.V1ObjectMeta{ Name: clusterGroup.Metadata.Name, @@ -203,7 +203,7 @@ func (h *V1Client) UpdateClusterGroup(uid string, clusterGroup *models.V1Cluster case "tenant": params = clusterC.NewV1ClusterGroupsUIDHostClusterUpdateParams().WithUID(uid) default: - return errors.New("invalid scope") + return errors.New("invalid scope " + scope) } params = params.WithBody(clusterGroup) _, err = client.V1ClusterGroupsUIDHostClusterUpdate(params) @@ -222,7 +222,7 @@ func (h *V1Client) UpdateClusterProfileInClusterGroup(clusterGroupContext string case "tenant": params = clusterC.NewV1ClusterGroupsUIDProfilesUpdateParams().WithUID(clusterGroupUid) default: - return errors.New("invalid scope") + return errors.New("invalid scope " + clusterGroupContext) } params = params.WithBody(clusterProfiles) _, err = client.V1ClusterGroupsUIDProfilesUpdate(params) @@ -244,7 +244,7 @@ func (h *V1Client) getClusterGroupMetadata(clusterGroupContext string) ([]*model case "tenant": params = clusterC.NewV1ClusterGroupsHostClusterMetadataParamsWithContext(h.Ctx) default: - return nil, errors.New("invalid scope") + return nil, errors.New("invalid scope " + clusterGroupContext) } resp, err := client.V1ClusterGroupsHostClusterMetadata(params)