Skip to content

Commit c02b6dc

Browse files
gkebackup backupplan: Add State and StateReason fields (#8227) (#15201)
Signed-off-by: Modular Magician <[email protected]>
1 parent 5ac6351 commit c02b6dc

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

.changelog/8227.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
gkebackup: added `state` and `state_reason` output-only fields to `google_gkebackup_backupplan` resource
3+
```

google/services/gkebackup/resource_gke_backup_backup_plan.go

+24
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@ backupPlans.delete to ensure that their change will be applied to the same versi
265265
Computed: true,
266266
Description: `The number of Kubernetes Pods backed up in the last successful Backup created via this BackupPlan.`,
267267
},
268+
"state": {
269+
Type: schema.TypeString,
270+
Computed: true,
271+
Description: `The State of the BackupPlan.`,
272+
},
273+
"state_reason": {
274+
Type: schema.TypeString,
275+
Computed: true,
276+
Description: `Detailed description of why BackupPlan is in its current state.`,
277+
},
268278
"uid": {
269279
Type: schema.TypeString,
270280
Computed: true,
@@ -479,6 +489,12 @@ func resourceGKEBackupBackupPlanRead(d *schema.ResourceData, meta interface{}) e
479489
if err := d.Set("protected_pod_count", flattenGKEBackupBackupPlanProtectedPodCount(res["protectedPodCount"], d, config)); err != nil {
480490
return fmt.Errorf("Error reading BackupPlan: %s", err)
481491
}
492+
if err := d.Set("state", flattenGKEBackupBackupPlanState(res["state"], d, config)); err != nil {
493+
return fmt.Errorf("Error reading BackupPlan: %s", err)
494+
}
495+
if err := d.Set("state_reason", flattenGKEBackupBackupPlanStateReason(res["stateReason"], d, config)); err != nil {
496+
return fmt.Errorf("Error reading BackupPlan: %s", err)
497+
}
482498

483499
return nil
484500
}
@@ -914,6 +930,14 @@ func flattenGKEBackupBackupPlanProtectedPodCount(v interface{}, d *schema.Resour
914930
return v // let terraform core handle it otherwise
915931
}
916932

933+
func flattenGKEBackupBackupPlanState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
934+
return v
935+
}
936+
937+
func flattenGKEBackupBackupPlanStateReason(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
938+
return v
939+
}
940+
917941
func expandGKEBackupBackupPlanName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
918942
return tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/backupPlans/{{name}}")
919943
}

website/docs/r/gke_backup_backup_plan.html.markdown

+6
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ In addition to the arguments listed above, the following computed attributes are
365365
* `protected_pod_count` -
366366
The number of Kubernetes Pods backed up in the last successful Backup created via this BackupPlan.
367367

368+
* `state` -
369+
The State of the BackupPlan.
370+
371+
* `state_reason` -
372+
Detailed description of why BackupPlan is in its current state.
373+
368374

369375
## Timeouts
370376

0 commit comments

Comments
 (0)