diff --git a/kubernetes/schema_container.go b/kubernetes/schema_container.go index f35af8fb18..752ccb8fb2 100644 --- a/kubernetes/schema_container.go +++ b/kubernetes/schema_container.go @@ -83,6 +83,20 @@ func lifecycleHandlerFields() map[string]*schema.Schema { }, }, }, + "sleep": { + Type: schema.TypeList, + Optional: true, + Description: "Sleep represents a duration that the container should sleep.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "seconds": { + Type: schema.TypeString, + Required: true, + Description: "Seconds is the number of seconds to sleep.", + }, + }, + }, + }, "tcp_socket": { Type: schema.TypeList, Optional: true, diff --git a/kubernetes/structures_container.go b/kubernetes/structures_container.go index 8e1d0e08da..9b7fe63677 100644 --- a/kubernetes/structures_container.go +++ b/kubernetes/structures_container.go @@ -77,6 +77,9 @@ func flattenLifecycleHandler(in *v1.LifecycleHandler) []interface{} { if in.HTTPGet != nil { att["http_get"] = flattenHTTPGet(in.HTTPGet) } + if in.Sleep != nil { + att["sleep"] = flattenSleep(in.Sleep) + } if in.TCPSocket != nil { att["tcp_socket"] = flattenTCPSocket(in.TCPSocket) } @@ -119,6 +122,12 @@ func flattenHTTPGet(in *v1.HTTPGetAction) []interface{} { return []interface{}{att} } +func flattenSleep(in *v1.SleepAction) []interface{} { + att := make(map[string]interface{}) + att["seconds"] = in.Seconds + return []interface{}{att} +} + func flattenTCPSocket(in *v1.TCPSocketAction) []interface{} { att := make(map[string]interface{}) att["port"] = in.Port.String() @@ -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 { + obj.Seconds = int64(v) + } + return &obj +} + func expandTCPSocket(l []interface{}) *v1.TCPSocketAction { if len(l) == 0 || l[0] == nil { return &v1.TCPSocketAction{} @@ -788,6 +809,9 @@ func expandLifecycleHandlers(l []interface{}) *v1.LifecycleHandler { if v, ok := in["http_get"].([]interface{}); ok && len(v) > 0 { obj.HTTPGet = expandHTTPGet(v) } + if v, ok := in["sleep"].([]interface{}); ok && len(v) > 0 { + obj.Sleep = expandSleep(v) + } if v, ok := in["tcp_socket"].([]interface{}); ok && len(v) > 0 { obj.TCPSocket = expandTCPSocket(v) }