Skip to content
Open
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
36 changes: 36 additions & 0 deletions docs/resources/pod.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ Optional:

- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--http_get))
- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--tcp_socket))

<a id="nestedblock--spec--container--lifecycle--post_start--exec"></a>
Expand Down Expand Up @@ -523,6 +524,14 @@ Optional:



<a id="nestedblock--spec--container--lifecycle--post_start--sleep"></a>
### Nested Schema for `spec.container.lifecycle.post_start.sleep`

Required:

- `seconds` (Number) Number of seconds to sleep.


<a id="nestedblock--spec--container--lifecycle--post_start--tcp_socket"></a>
### Nested Schema for `spec.container.lifecycle.post_start.tcp_socket`

Expand All @@ -539,6 +548,7 @@ Optional:

- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--http_get))
- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--tcp_socket))

<a id="nestedblock--spec--container--lifecycle--pre_stop--exec"></a>
Expand Down Expand Up @@ -570,6 +580,14 @@ Optional:



<a id="nestedblock--spec--container--lifecycle--pre_stop--sleep"></a>
### Nested Schema for `spec.container.lifecycle.pre_stop.sleep`

Required:

- `seconds` (Number) Number of seconds to sleep.


<a id="nestedblock--spec--container--lifecycle--pre_stop--tcp_socket"></a>
### Nested Schema for `spec.container.lifecycle.pre_stop.tcp_socket`

Expand Down Expand Up @@ -1054,6 +1072,7 @@ Optional:

- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--http_get))
- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--tcp_socket))

<a id="nestedblock--spec--init_container--lifecycle--post_start--exec"></a>
Expand Down Expand Up @@ -1085,6 +1104,14 @@ Optional:



<a id="nestedblock--spec--init_container--lifecycle--post_start--sleep"></a>
### Nested Schema for `spec.init_container.lifecycle.post_start.sleep`

Required:

- `seconds` (Number) Number of seconds to sleep.


<a id="nestedblock--spec--init_container--lifecycle--post_start--tcp_socket"></a>
### Nested Schema for `spec.init_container.lifecycle.post_start.tcp_socket`

Expand All @@ -1101,6 +1128,7 @@ Optional:

- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--http_get))
- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--tcp_socket))

<a id="nestedblock--spec--init_container--lifecycle--pre_stop--exec"></a>
Expand Down Expand Up @@ -1132,6 +1160,14 @@ Optional:



<a id="nestedblock--spec--init_container--lifecycle--pre_stop--sleep"></a>
### Nested Schema for `spec.init_container.lifecycle.pre_stop.sleep`

Required:

- `seconds` (Number) Number of seconds to sleep.


<a id="nestedblock--spec--init_container--lifecycle--pre_stop--tcp_socket"></a>
### Nested Schema for `spec.init_container.lifecycle.pre_stop.tcp_socket`

Expand Down
45 changes: 45 additions & 0 deletions docs/resources/pod_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ Optional:

- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--http_get))
- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--container--lifecycle--post_start--tcp_socket))

<a id="nestedblock--spec--container--lifecycle--post_start--exec"></a>
Expand Down Expand Up @@ -522,6 +523,14 @@ Optional:



<a id="nestedblock--spec--container--lifecycle--post_start--sleep"></a>
### Nested Schema for `spec.container.lifecycle.post_start.sleep`

Required:

- `seconds` (Number) Number of seconds to sleep.


<a id="nestedblock--spec--container--lifecycle--post_start--tcp_socket"></a>
### Nested Schema for `spec.container.lifecycle.post_start.tcp_socket`

Expand All @@ -538,6 +547,7 @@ Optional:

- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--http_get))
- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--container--lifecycle--pre_stop--tcp_socket))

<a id="nestedblock--spec--container--lifecycle--pre_stop--exec"></a>
Expand Down Expand Up @@ -569,6 +579,14 @@ Optional:



<a id="nestedblock--spec--container--lifecycle--pre_stop--sleep"></a>
### Nested Schema for `spec.container.lifecycle.pre_stop.sleep`

Required:

- `seconds` (Number) Number of seconds to sleep.


<a id="nestedblock--spec--container--lifecycle--pre_stop--tcp_socket"></a>
### Nested Schema for `spec.container.lifecycle.pre_stop.tcp_socket`

Expand Down Expand Up @@ -1054,6 +1072,7 @@ Optional:

- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--http_get))
- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--post_start--tcp_socket))

<a id="nestedblock--spec--init_container--lifecycle--post_start--exec"></a>
Expand Down Expand Up @@ -1085,6 +1104,14 @@ Optional:



<a id="nestedblock--spec--init_container--lifecycle--post_start--sleep"></a>
### Nested Schema for `spec.init_container.lifecycle.post_start.sleep`

Required:

- `seconds` (Number) Number of seconds to sleep.


<a id="nestedblock--spec--init_container--lifecycle--post_start--tcp_socket"></a>
### Nested Schema for `spec.init_container.lifecycle.post_start.tcp_socket`

Expand All @@ -1101,6 +1128,7 @@ Optional:

- `exec` (Block List, Max: 1) exec specifies the action to take. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--exec))
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--http_get))
- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--sleep))
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--init_container--lifecycle--pre_stop--tcp_socket))

<a id="nestedblock--spec--init_container--lifecycle--pre_stop--exec"></a>
Expand Down Expand Up @@ -1132,6 +1160,14 @@ Optional:



<a id="nestedblock--spec--init_container--lifecycle--pre_stop--sleep"></a>
### Nested Schema for `spec.init_container.lifecycle.pre_stop.sleep`

Required:

- `seconds` (Number) Number of seconds to sleep.


<a id="nestedblock--spec--init_container--lifecycle--pre_stop--tcp_socket"></a>
### Nested Schema for `spec.init_container.lifecycle.pre_stop.tcp_socket`

Expand Down Expand Up @@ -1352,6 +1388,7 @@ Optional:
- `http_get` (Block List, Max: 1) Specifies the http request to perform. (see [below for nested schema](#nestedblock--spec--init_container--startup_probe--http_get))
- `initial_delay_seconds` (Number) Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes
- `period_seconds` (Number) How often (in seconds) to perform the probe
- `sleep` (Block List, Max: 1) Sleep represents a duration that the container should sleep (see [below for nested schema](#nestedblock--spec--init_container--startup_probe--sleep))
- `success_threshold` (Number) Minimum consecutive successes for the probe to be considered successful after having failed.
- `tcp_socket` (Block List) TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported (see [below for nested schema](#nestedblock--spec--init_container--startup_probe--tcp_socket))
- `timeout_seconds` (Number) Number of seconds after which the probe times out. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes
Expand Down Expand Up @@ -1397,6 +1434,14 @@ Optional:



<a id="nestedblock--spec--init_container--startup_probe--sleep"></a>
### Nested Schema for `spec.init_container.startup_probe.sleep`

Required:

- `seconds` (Number) Number of seconds to sleep.


<a id="nestedblock--spec--init_container--startup_probe--tcp_socket"></a>
### Nested Schema for `spec.init_container.startup_probe.tcp_socket`

Expand Down
17 changes: 17 additions & 0 deletions kubernetes/schema_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ func lifecycleHandlerFields() map[string]*schema.Schema {
},
},
},
"sleep": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Description: "Sleep represents a duration that the container should sleep",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"seconds": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(0),
Description: "Number of seconds to sleep.",
},
},
},
},
}
}

Expand Down Expand Up @@ -702,6 +718,7 @@ func containerFields(isUpdatable bool) map[string]*schema.Schema {

func probeSchema() *schema.Resource {
h := lifecycleHandlerFields()
delete(h, "sleep")
h["grpc"] = &schema.Schema{
Type: schema.TypeList,
Optional: true,
Expand Down
24 changes: 24 additions & 0 deletions kubernetes/structures_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,19 @@ func flattenLifecycleHandler(in *v1.LifecycleHandler) []interface{} {
if in.TCPSocket != nil {
att["tcp_socket"] = flattenTCPSocket(in.TCPSocket)
}
if in.Sleep != nil {
att["sleep"] = flattenSleep(in.Sleep)
}

return []interface{}{att}
}

func flattenSleep(in *v1.SleepAction) []interface{} {
att := make(map[string]interface{})
att["seconds"] = in.Seconds
return []interface{}{att}
}

func flattenHTTPHeader(in []v1.HTTPHeader) []interface{} {
att := make([]interface{}, len(in))
for i, v := range in {
Expand Down Expand Up @@ -686,6 +695,18 @@ func expandSecurityCapabilities(l []interface{}) *v1.Capabilities {
return &obj
}

func expandSleep(l []interface{}) *v1.SleepAction {
if len(l) == 0 || l[0] == nil {
return &v1.SleepAction{}
}
in := l[0].(map[string]interface{})
obj := v1.SleepAction{}
if v, ok := in["seconds"].(int); ok && v >= 0 {
obj.Seconds = int64(v)
}
return &obj
}

func expandTCPSocket(l []interface{}) *v1.TCPSocketAction {
if len(l) == 0 || l[0] == nil {
return &v1.TCPSocketAction{}
Expand Down Expand Up @@ -791,6 +812,9 @@ func expandLifecycleHandlers(l []interface{}) *v1.LifecycleHandler {
if v, ok := in["tcp_socket"].([]interface{}); ok && len(v) > 0 {
obj.TCPSocket = expandTCPSocket(v)
}
if v, ok := in["sleep"].([]interface{}); ok && len(v) > 0 {
obj.Sleep = expandSleep(v)
}
return &obj
}

Expand Down