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
14 changes: 14 additions & 0 deletions kubernetes/schema_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 24 additions & 0 deletions kubernetes/structures_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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()
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 {
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 @@ -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)
}
Expand Down