diff --git a/kubernetes/structures_pod.go b/kubernetes/structures_pod.go index 854c914423..f7bf94fd8f 100644 --- a/kubernetes/structures_pod.go +++ b/kubernetes/structures_pod.go @@ -313,32 +313,6 @@ func flattenSecretVolumeSource(in *v1.SecretVolumeSource) []interface{} { // Expanders -func expandPodSecurityContext(l []interface{}) *v1.PodSecurityContext { - if len(l) == 0 || l[0] == nil { - return &v1.PodSecurityContext{} - } - in := l[0].(map[string]interface{}) - obj := &v1.PodSecurityContext{} - if v, ok := in["fs_group"].(int); ok { - obj.FSGroup = ptrToInt64(int64(v)) - } - if v, ok := in["run_as_non_root"].(bool); ok { - obj.RunAsNonRoot = ptrToBool(v) - } - if v, ok := in["run_as_user"].(int); ok { - obj.RunAsUser = ptrToInt64(int64(v)) - } - if v, ok := in["supplemental_groups"].(*schema.Set); ok { - obj.SupplementalGroups = schemaSetToInt64Array(v) - } - - if v, ok := in["se_linux_options"].([]interface{}); ok && len(v) > 0 { - obj.SELinuxOptions = expandSeLinuxOptions(v) - } - - return obj -} - func expandPodSpec(p []interface{}) (v1.PodSpec, error) { obj := v1.PodSpec{} if len(p) == 0 || p[0] == nil { @@ -435,6 +409,32 @@ func expandPodSpec(p []interface{}) (v1.PodSpec, error) { return obj, nil } +func expandPodSecurityContext(l []interface{}) *v1.PodSecurityContext { + if len(l) == 0 || l[0] == nil { + return &v1.PodSecurityContext{} + } + in := l[0].(map[string]interface{}) + obj := &v1.PodSecurityContext{} + if v, ok := in["fs_group"].(int); ok { + obj.FSGroup = ptrToInt64(int64(v)) + } + if v, ok := in["run_as_non_root"].(bool); ok { + obj.RunAsNonRoot = ptrToBool(v) + } + if v, ok := in["run_as_user"].(int); ok { + obj.RunAsUser = ptrToInt64(int64(v)) + } + if v, ok := in["supplemental_groups"].(*schema.Set); ok { + obj.SupplementalGroups = schemaSetToInt64Array(v) + } + + if v, ok := in["se_linux_options"].([]interface{}); ok && len(v) > 0 { + obj.SELinuxOptions = expandSeLinuxOptions(v) + } + + return obj +} + func expandSeLinuxOptions(l []interface{}) *v1.SELinuxOptions { if len(l) == 0 || l[0] == nil { return &v1.SELinuxOptions{}