Skip to content

Commit

Permalink
added het node repave reason function (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM authored Nov 29, 2023
1 parent dcecb84 commit 9857c34
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
3 changes: 2 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ type V1Client struct {
GetClusterScanConfigFn func(uid string) (*models.V1ClusterComplianceScan, error)
GetClusterRbacConfigFn func(uid string) (*models.V1ClusterRbacs, error)
GetClusterNamespaceConfigFn func(uid string) (*models.V1ClusterNamespaceResources, error)
ApproveClusterRepaveFn func(clusterUID string, context string) error
ApproveClusterRepaveFn func(context string, clusterUID string) error
GetRepaveReasonsFn func(context string, clusterUID string) ([]string, error)

// Cluster Groups
CreateClusterGroupFn func(*models.V1ClusterGroupEntity) (string, error)
Expand Down
32 changes: 31 additions & 1 deletion client/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func (h *V1Client) ImportClusterGeneric(meta *models.V1ObjectMetaInputEntity) (s
return *success.Payload.UID, nil
}

func (h *V1Client) ApproveClusterRepave(clusterUID string, context string) error {
func (h *V1Client) ApproveClusterRepave(context string, clusterUID string) error {
if h.ApproveClusterRepaveFn != nil {
return h.ApproveClusterRepaveFn(clusterUID, context)
}
Expand All @@ -367,3 +367,33 @@ func (h *V1Client) ApproveClusterRepave(clusterUID string, context string) error
_, err = client.V1SpectroClustersUIDRepaveApproveUpdate(params)
return err
}

func (h *V1Client) GetRepaveReasons(context string, clusterUID string) ([]string, error) {
if h.GetRepaveReasonsFn != nil {
return h.GetRepaveReasonsFn(context, clusterUID)
}

client, err := h.GetClusterClient()
if err != nil {
return nil, err
}
var params *clusterC.V1SpectroClustersUIDRepaveGetParams
switch context {
case "project":
params = clusterC.NewV1SpectroClustersUIDRepaveGetParamsWithContext(h.Ctx).WithUID(clusterUID)
case "tenant":
params = clusterC.NewV1SpectroClustersUIDRepaveGetParams().WithUID(clusterUID)
default:
err = fmt.Errorf("invalid Context set - %s", context)
return nil, err
}
res, err := client.V1SpectroClustersUIDRepaveGet(params)
if err != nil {
return nil, err
}
var reasons []string
for _, r := range res.Payload.Spec.Reasons {
reasons = append(reasons, fmt.Sprintf("Repave Reason Code - %s , Reason - %s.", r.Code, r.Message))
}
return reasons, err
}

0 comments on commit 9857c34

Please sign in to comment.