Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLT-661:Added Cluster profile support for cluster group #62

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions client/cluster_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -203,13 +203,32 @@ 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)
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 " + clusterGroupContext)
}
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 {
Expand All @@ -225,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)
Expand Down