Skip to content

Commit

Permalink
gkebackup backupplan: Add State and StateReason fields (hashicorp#8227)…
Browse files Browse the repository at this point in the history
… (hashicorp#15201)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jul 17, 2023
1 parent 5ac6351 commit c02b6dc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/8227.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
gkebackup: added `state` and `state_reason` output-only fields to `google_gkebackup_backupplan` resource
```
24 changes: 24 additions & 0 deletions google/services/gkebackup/resource_gke_backup_backup_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,16 @@ backupPlans.delete to ensure that their change will be applied to the same versi
Computed: true,
Description: `The number of Kubernetes Pods backed up in the last successful Backup created via this BackupPlan.`,
},
"state": {
Type: schema.TypeString,
Computed: true,
Description: `The State of the BackupPlan.`,
},
"state_reason": {
Type: schema.TypeString,
Computed: true,
Description: `Detailed description of why BackupPlan is in its current state.`,
},
"uid": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -479,6 +489,12 @@ func resourceGKEBackupBackupPlanRead(d *schema.ResourceData, meta interface{}) e
if err := d.Set("protected_pod_count", flattenGKEBackupBackupPlanProtectedPodCount(res["protectedPodCount"], d, config)); err != nil {
return fmt.Errorf("Error reading BackupPlan: %s", err)
}
if err := d.Set("state", flattenGKEBackupBackupPlanState(res["state"], d, config)); err != nil {
return fmt.Errorf("Error reading BackupPlan: %s", err)
}
if err := d.Set("state_reason", flattenGKEBackupBackupPlanStateReason(res["stateReason"], d, config)); err != nil {
return fmt.Errorf("Error reading BackupPlan: %s", err)
}

return nil
}
Expand Down Expand Up @@ -914,6 +930,14 @@ func flattenGKEBackupBackupPlanProtectedPodCount(v interface{}, d *schema.Resour
return v // let terraform core handle it otherwise
}

func flattenGKEBackupBackupPlanState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenGKEBackupBackupPlanStateReason(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func expandGKEBackupBackupPlanName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/backupPlans/{{name}}")
}
Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/gke_backup_backup_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ In addition to the arguments listed above, the following computed attributes are
* `protected_pod_count` -
The number of Kubernetes Pods backed up in the last successful Backup created via this BackupPlan.

* `state` -
The State of the BackupPlan.

* `state_reason` -
Detailed description of why BackupPlan is in its current state.


## Timeouts

Expand Down

0 comments on commit c02b6dc

Please sign in to comment.