diff --git a/spectrocloud/cluster_common_policies.go b/spectrocloud/cluster_common_policies.go index fb6004bb..3dfa5fe7 100644 --- a/spectrocloud/cluster_common_policies.go +++ b/spectrocloud/cluster_common_policies.go @@ -80,12 +80,19 @@ func flattenBackupPolicy(policy *models.V1ClusterBackupConfig) []interface{} { data["namespaces"] = policy.Namespaces data["expiry_in_hour"] = policy.DurationInHours data["include_disks"] = policy.IncludeAllDisks - data["include_cluster_resources"] = policy.IncludeClusterResources + data["include_cluster_resources"] = flattenIncludeResourceMode(policy.IncludeClusterResourceMode) data["include_cluster_resources_mode"] = policy.IncludeClusterResourceMode result = append(result, data) return result } +func flattenIncludeResourceMode(m models.V1IncludeClusterResourceMode) bool { + if m == models.V1IncludeClusterResourceMode("Always") { + return true + } + return false +} + func updateBackupPolicy(c *client.V1Client, d *schema.ResourceData) error { if policy := toBackupPolicy(d); policy != nil { //clusterContext := d.Get("context").(string) diff --git a/spectrocloud/cluster_policies_test.go b/spectrocloud/cluster_policies_test.go index 64d605ef..e4bf4908 100644 --- a/spectrocloud/cluster_policies_test.go +++ b/spectrocloud/cluster_policies_test.go @@ -76,13 +76,14 @@ func TestFlattenBackupPolicy(t *testing.T) { expected := []interface{}{ map[string]interface{}{ - "schedule": "daily", - "backup_location_id": "location-123", - "prefix": "backup-prefix", - "namespaces": []string{"namespace1", "namespace2"}, - "expiry_in_hour": int64(24), - "include_disks": true, - "include_cluster_resources": true, + "schedule": "daily", + "backup_location_id": "location-123", + "prefix": "backup-prefix", + "namespaces": []string{"namespace1", "namespace2"}, + "expiry_in_hour": int64(24), + "include_disks": true, + "include_cluster_resources": false, + "include_cluster_resources_mode": models.V1IncludeClusterResourceMode(""), }, } @@ -112,12 +113,13 @@ func TestToBackupPolicy(t *testing.T) { result := toBackupPolicy(resourceData) expected := &models.V1ClusterBackupConfig{ - BackupLocationUID: "location-123", - BackupPrefix: "backup-prefix", - DurationInHours: 24, - IncludeAllDisks: true, - IncludeClusterResources: true, - Namespaces: []string{"namespace1"}, + BackupLocationUID: "location-123", + BackupPrefix: "backup-prefix", + DurationInHours: 24, + IncludeAllDisks: true, + IncludeClusterResources: false, + IncludeClusterResourceMode: models.V1IncludeClusterResourceMode("Always"), + Namespaces: []string{"namespace1"}, Schedule: &models.V1ClusterFeatureSchedule{ ScheduledRunTime: "daily", }, @@ -192,12 +194,13 @@ func TestToPolicies(t *testing.T) { expected := &models.V1SpectroClusterPolicies{ BackupPolicy: &models.V1ClusterBackupConfig{ - BackupLocationUID: "location-123", - BackupPrefix: "backup-prefix", - DurationInHours: 24, - IncludeAllDisks: true, - IncludeClusterResources: true, - Namespaces: []string{"namespace1"}, + BackupLocationUID: "location-123", + BackupPrefix: "backup-prefix", + DurationInHours: 24, + IncludeAllDisks: true, + IncludeClusterResources: false, + IncludeClusterResourceMode: models.V1IncludeClusterResourceMode("Always"), + Namespaces: []string{"namespace1"}, Schedule: &models.V1ClusterFeatureSchedule{ ScheduledRunTime: "daily", },