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

Supported Succeeded and Failed states in Target Pods #2141

Merged
merged 5 commits into from
Jul 14, 2023
Merged
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/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
@@ -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,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a description here.

}
}

@@ -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) {
1 change: 1 addition & 0 deletions website/docs/r/pod.html.markdown
Original file line number Diff line number Diff line change
@@ -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