Skip to content

Commit

Permalink
Merge pull request #62 from spectrocloud/PLT-661
Browse files Browse the repository at this point in the history
PLT-661:Added Cluster profile support for cluster group
  • Loading branch information
nikchern authored Oct 30, 2023
2 parents 198e0b9 + 3703c4c commit 0102285
Showing 1 changed file with 26 additions and 7 deletions.
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

0 comments on commit 0102285

Please sign in to comment.