Skip to content

Commit

Permalink
PLT-724:Fixed Back up day 2 operation
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM committed Oct 9, 2023
1 parent b76840d commit 31c76af
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions client/cluster_backup_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,28 @@ func (h *V1Client) CreateClusterBackupConfig(uid string, config *models.V1Cluste
return err
}

func (h *V1Client) UpdateClusterBackupConfig(uid string, config *models.V1ClusterBackupConfig) error {
func (h *V1Client) UpdateClusterBackupConfig(uid string, config *models.V1ClusterBackupConfig, ClusterContext string) error {
client, err := h.GetClusterClient()
if err != nil {
return err
}

params := clusterC.NewV1ClusterFeatureBackupUpdateParamsWithContext(h.Ctx).WithUID(uid).WithBody(config)
var params *clusterC.V1ClusterFeatureBackupUpdateParams
switch ClusterContext {
case "project":
params = clusterC.NewV1ClusterFeatureBackupUpdateParamsWithContext(h.Ctx).WithUID(uid).WithBody(config)
case "tenant":
params = clusterC.NewV1ClusterFeatureBackupUpdateParams().WithUID(uid).WithBody(config)
}
_, err = client.V1ClusterFeatureBackupUpdate(params)
return err
}

func (h *V1Client) ApplyClusterBackupConfig(uid string, config *models.V1ClusterBackupConfig, ClusterContext string) error {
if policy, err := h.GetClusterBackupConfig(uid, ClusterContext); err != nil {
return err
} else if policy == nil {
return h.CreateClusterBackupConfig(uid, config, ClusterContext)
} else {
return h.UpdateClusterBackupConfig(uid, config, ClusterContext)
}
}

0 comments on commit 31c76af

Please sign in to comment.