Skip to content

Commit

Permalink
Supported Succeeded and Failed states in Target Pods (#2141)
Browse files Browse the repository at this point in the history
* add updated_target attribute

* Refactor to use legacy_lifecycle_states

* more descriptive doc for

* add description and changelog-entry
  • Loading branch information
BBBmau authored Jul 14, 2023
1 parent 6ee3f5a commit 98b02ed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/2141.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
`kubernetes/resource_kubernetes_pod.go`: Add `legacy_lifecycle_states` attribute
```
14 changes: 13 additions & 1 deletion kubernetes/resource_kubernetes_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ func resourceKubernetesPodSchemaV1() map[string]*schema.Schema {
Schema: podSpecFields(false, false),
},
},
"legacy_lifecycle_states": {
Type: schema.TypeBool,
Description: "Setting this attribute to `false` would set the target pod lifecycle state as [\"Running\", \"Succeeded\", \"Failed\"]. The default value of `true` would leave the target pod lifecycle state as [\"Running\"]`.",
Optional: true,
Default: true,
},
}
}

Expand Down Expand Up @@ -86,8 +92,14 @@ func resourceKubernetesPodCreate(ctx context.Context, d *schema.ResourceData, me

d.SetId(buildId(out.ObjectMeta))

target := []string{"Running"}

if d.Get("legacy_lifecycle_states").(bool) != true {
target = []string{"Running", "Succeeded", "Failed"}
}

stateConf := &resource.StateChangeConf{
Target: []string{"Running"},
Target: target,
Pending: []string{"Pending"},
Timeout: d.Timeout(schema.TimeoutCreate),
Refresh: func() (interface{}, string, error) {
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/pod.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ The following arguments are supported:

* `metadata` - (Required) Standard pod's metadata. For more info see [Kubernetes reference](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata)
* `spec` - (Required) Spec of the pod owned by the cluster
* `legacy_lifecycle_states` - (Optional) Setting this attribute to `false` would set the target pod lifecycle state as `["Running", "Succeeded", "Failed"]`. The default value of `true` would leave the target pod lifecycle state as `["Running"]`.

## Nested Blocks

Expand Down

0 comments on commit 98b02ed

Please sign in to comment.