Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gkebackup backupplan: Add State and StateReason fields #15201

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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