github.com/skyscape-cloud-services/terraform@v0.9.2-0.20170609144644-7ece028a1747/builtin/providers/kubernetes/structures_pod.go (about)

     1  package kubernetes
     2  
     3  import (
     4  	"strconv"
     5  
     6  	"github.com/hashicorp/terraform/helper/schema"
     7  	"k8s.io/kubernetes/pkg/api/v1"
     8  )
     9  
    10  // Flatteners
    11  
    12  func flattenPodSpec(in v1.PodSpec) ([]interface{}, error) {
    13  	att := make(map[string]interface{})
    14  	if in.ActiveDeadlineSeconds != nil {
    15  		att["active_deadline_seconds"] = *in.ActiveDeadlineSeconds
    16  	}
    17  	containers, err := flattenContainers(in.Containers)
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  	att["container"] = containers
    22  
    23  	att["dns_policy"] = in.DNSPolicy
    24  
    25  	att["host_ipc"] = in.HostIPC
    26  	att["host_network"] = in.HostNetwork
    27  	att["host_pid"] = in.HostPID
    28  
    29  	if in.Hostname != "" {
    30  		att["hostname"] = in.Hostname
    31  	}
    32  	att["image_pull_secrets"] = flattenLocalObjectReferenceArray(in.ImagePullSecrets)
    33  
    34  	if in.NodeName != "" {
    35  		att["node_name"] = in.NodeName
    36  	}
    37  	if len(in.NodeSelector) > 0 {
    38  		att["node_selector"] = in.NodeSelector
    39  	}
    40  	if in.RestartPolicy != "" {
    41  		att["restart_policy"] = in.RestartPolicy
    42  	}
    43  
    44  	if in.SecurityContext != nil {
    45  		att["security_context"] = flattenPodSecurityContext(in.SecurityContext)
    46  	}
    47  	if in.ServiceAccountName != "" {
    48  		att["service_account_name"] = in.ServiceAccountName
    49  	}
    50  	if in.Subdomain != "" {
    51  		att["subdomain"] = in.Subdomain
    52  	}
    53  
    54  	if in.TerminationGracePeriodSeconds != nil {
    55  		att["termination_grace_period_seconds"] = *in.TerminationGracePeriodSeconds
    56  	}
    57  
    58  	if len(in.Volumes) > 0 {
    59  		v, err := flattenVolumes(in.Volumes)
    60  		if err != nil {
    61  			return []interface{}{att}, err
    62  		}
    63  		att["volume"] = v
    64  	}
    65  	return []interface{}{att}, nil
    66  }
    67  
    68  func flattenPodSecurityContext(in *v1.PodSecurityContext) []interface{} {
    69  	att := make(map[string]interface{})
    70  	if in.FSGroup != nil {
    71  		att["fs_group"] = *in.FSGroup
    72  	}
    73  
    74  	if in.RunAsNonRoot != nil {
    75  		att["run_as_non_root"] = *in.RunAsNonRoot
    76  	}
    77  
    78  	if in.RunAsUser != nil {
    79  		att["run_as_user"] = *in.RunAsUser
    80  	}
    81  
    82  	if len(in.SupplementalGroups) > 0 {
    83  		att["supplemental_groups"] = newInt64Set(schema.HashSchema(&schema.Schema{
    84  			Type: schema.TypeInt,
    85  		}), in.SupplementalGroups)
    86  	}
    87  	if in.SELinuxOptions != nil {
    88  		att["se_linux_options"] = flattenSeLinuxOptions(in.SELinuxOptions)
    89  	}
    90  
    91  	if len(att) > 0 {
    92  		return []interface{}{att}
    93  	}
    94  	return []interface{}{}
    95  }
    96  
    97  func flattenSeLinuxOptions(in *v1.SELinuxOptions) []interface{} {
    98  	att := make(map[string]interface{})
    99  	if in.User != "" {
   100  		att["user"] = in.User
   101  	}
   102  	if in.Role != "" {
   103  		att["role"] = in.Role
   104  	}
   105  	if in.User != "" {
   106  		att["type"] = in.Type
   107  	}
   108  	if in.Level != "" {
   109  		att["level"] = in.Level
   110  	}
   111  	return []interface{}{att}
   112  }
   113  
   114  func flattenVolumes(volumes []v1.Volume) ([]interface{}, error) {
   115  	att := make([]interface{}, len(volumes))
   116  	for i, v := range volumes {
   117  		obj := map[string]interface{}{}
   118  
   119  		if v.Name != "" {
   120  			obj["name"] = v.Name
   121  		}
   122  		if v.ConfigMap != nil {
   123  			obj["config_map"] = flattenConfigMapVolumeSource(v.ConfigMap)
   124  		}
   125  		if v.GitRepo != nil {
   126  			obj["git_repo"] = flattenGitRepoVolumeSource(v.GitRepo)
   127  		}
   128  		if v.EmptyDir != nil {
   129  			obj["empty_dir"] = flattenEmptyDirVolumeSource(v.EmptyDir)
   130  		}
   131  		if v.DownwardAPI != nil {
   132  			obj["downward_api"] = flattenDownwardAPIVolumeSource(v.DownwardAPI)
   133  		}
   134  		if v.PersistentVolumeClaim != nil {
   135  			obj["persistent_volume_claim"] = flattenPersistentVolumeClaimVolumeSource(v.PersistentVolumeClaim)
   136  		}
   137  		if v.Secret != nil {
   138  			obj["secret"] = flattenSecretVolumeSource(v.Secret)
   139  		}
   140  		if v.GCEPersistentDisk != nil {
   141  			obj["gce_persistent_disk"] = flattenGCEPersistentDiskVolumeSource(v.GCEPersistentDisk)
   142  		}
   143  		if v.AWSElasticBlockStore != nil {
   144  			obj["aws_elastic_block_store"] = flattenAWSElasticBlockStoreVolumeSource(v.AWSElasticBlockStore)
   145  		}
   146  		if v.HostPath != nil {
   147  			obj["host_path"] = flattenHostPathVolumeSource(v.HostPath)
   148  		}
   149  		if v.Glusterfs != nil {
   150  			obj["glusterfs"] = flattenGlusterfsVolumeSource(v.Glusterfs)
   151  		}
   152  		if v.NFS != nil {
   153  			obj["nfs"] = flattenNFSVolumeSource(v.NFS)
   154  		}
   155  		if v.RBD != nil {
   156  			obj["rbd"] = flattenRBDVolumeSource(v.RBD)
   157  		}
   158  		if v.ISCSI != nil {
   159  			obj["iscsi"] = flattenISCSIVolumeSource(v.ISCSI)
   160  		}
   161  		if v.Cinder != nil {
   162  			obj["cinder"] = flattenCinderVolumeSource(v.Cinder)
   163  		}
   164  		if v.CephFS != nil {
   165  			obj["ceph_fs"] = flattenCephFSVolumeSource(v.CephFS)
   166  		}
   167  		if v.FC != nil {
   168  			obj["fc"] = flattenFCVolumeSource(v.FC)
   169  		}
   170  		if v.Flocker != nil {
   171  			obj["flocker"] = flattenFlockerVolumeSource(v.Flocker)
   172  		}
   173  		if v.FlexVolume != nil {
   174  			obj["flex_volume"] = flattenFlexVolumeSource(v.FlexVolume)
   175  		}
   176  		if v.AzureFile != nil {
   177  			obj["azure_file"] = flattenAzureFileVolumeSource(v.AzureFile)
   178  		}
   179  		if v.VsphereVolume != nil {
   180  			obj["vsphere_volume"] = flattenVsphereVirtualDiskVolumeSource(v.VsphereVolume)
   181  		}
   182  		if v.Quobyte != nil {
   183  			obj["quobyte"] = flattenQuobyteVolumeSource(v.Quobyte)
   184  		}
   185  		if v.AzureDisk != nil {
   186  			obj["azure_disk"] = flattenAzureDiskVolumeSource(v.AzureDisk)
   187  		}
   188  		if v.PhotonPersistentDisk != nil {
   189  			obj["photon_persistent_disk"] = flattenPhotonPersistentDiskVolumeSource(v.PhotonPersistentDisk)
   190  		}
   191  		att[i] = obj
   192  	}
   193  	return att, nil
   194  }
   195  
   196  func flattenPersistentVolumeClaimVolumeSource(in *v1.PersistentVolumeClaimVolumeSource) []interface{} {
   197  	att := make(map[string]interface{})
   198  	if in.ClaimName != "" {
   199  		att["claim_name"] = in.ClaimName
   200  	}
   201  	if in.ReadOnly {
   202  		att["read_only"] = in.ReadOnly
   203  	}
   204  
   205  	return []interface{}{att}
   206  }
   207  func flattenGitRepoVolumeSource(in *v1.GitRepoVolumeSource) []interface{} {
   208  	att := make(map[string]interface{})
   209  	if in.Directory != "" {
   210  		att["directory"] = in.Directory
   211  	}
   212  
   213  	att["repository"] = in.Repository
   214  
   215  	if in.Revision != "" {
   216  		att["revision"] = in.Revision
   217  	}
   218  	return []interface{}{att}
   219  }
   220  
   221  func flattenDownwardAPIVolumeSource(in *v1.DownwardAPIVolumeSource) []interface{} {
   222  	att := make(map[string]interface{})
   223  	if in.DefaultMode != nil {
   224  		att["default_mode"] = in.DefaultMode
   225  	}
   226  	if len(in.Items) > 0 {
   227  		att["items"] = flattenDownwardAPIVolumeFile(in.Items)
   228  	}
   229  	return []interface{}{att}
   230  }
   231  
   232  func flattenDownwardAPIVolumeFile(in []v1.DownwardAPIVolumeFile) []interface{} {
   233  	att := make([]interface{}, len(in))
   234  	for i, v := range in {
   235  		m := map[string]interface{}{}
   236  		if v.FieldRef != nil {
   237  			m["field_ref"] = flattenObjectFieldSelector(v.FieldRef)
   238  		}
   239  		if v.Mode != nil {
   240  			m["mode"] = *v.Mode
   241  		}
   242  		if v.Path != "" {
   243  			m["path"] = v.Path
   244  		}
   245  		if v.ResourceFieldRef != nil {
   246  			m["resource_field_ref"] = flattenResourceFieldSelector(v.ResourceFieldRef)
   247  		}
   248  		att[i] = m
   249  	}
   250  	return att
   251  }
   252  
   253  func flattenConfigMapVolumeSource(in *v1.ConfigMapVolumeSource) []interface{} {
   254  	att := make(map[string]interface{})
   255  	if in.DefaultMode != nil {
   256  		att["default_mode"] = *in.DefaultMode
   257  	}
   258  	att["name"] = in.Name
   259  	if len(in.Items) > 0 {
   260  		items := make([]interface{}, len(in.Items))
   261  		for i, v := range in.Items {
   262  			m := map[string]interface{}{}
   263  			m["key"] = v.Key
   264  			m["mode"] = v.Mode
   265  			m["path"] = v.Path
   266  			items[i] = m
   267  		}
   268  		att["items"] = items
   269  	}
   270  
   271  	return []interface{}{att}
   272  }
   273  
   274  func flattenEmptyDirVolumeSource(in *v1.EmptyDirVolumeSource) []interface{} {
   275  	att := make(map[string]interface{})
   276  	att["medium"] = in.Medium
   277  	return []interface{}{att}
   278  }
   279  
   280  func flattenSecretVolumeSource(in *v1.SecretVolumeSource) []interface{} {
   281  	att := make(map[string]interface{})
   282  	if in.SecretName != "" {
   283  		att["secret_name"] = in.SecretName
   284  	}
   285  	return []interface{}{att}
   286  }
   287  
   288  // Expanders
   289  
   290  func expandPodSpec(p []interface{}) (v1.PodSpec, error) {
   291  	obj := v1.PodSpec{}
   292  	if len(p) == 0 || p[0] == nil {
   293  		return obj, nil
   294  	}
   295  	in := p[0].(map[string]interface{})
   296  
   297  	if v, ok := in["active_deadline_seconds"].(int); ok && v > 0 {
   298  		obj.ActiveDeadlineSeconds = ptrToInt64(int64(v))
   299  	}
   300  
   301  	if v, ok := in["container"].([]interface{}); ok && len(v) > 0 {
   302  		cs, err := expandContainers(v)
   303  		if err != nil {
   304  			return obj, err
   305  		}
   306  		obj.Containers = cs
   307  	}
   308  
   309  	if v, ok := in["dns_policy"].(string); ok {
   310  		obj.DNSPolicy = v1.DNSPolicy(v)
   311  	}
   312  
   313  	if v, ok := in["host_ipc"]; ok {
   314  		obj.HostIPC = v.(bool)
   315  	}
   316  
   317  	if v, ok := in["host_network"]; ok {
   318  		obj.HostNetwork = v.(bool)
   319  	}
   320  
   321  	if v, ok := in["host_pid"]; ok {
   322  		obj.HostPID = v.(bool)
   323  	}
   324  
   325  	if v, ok := in["hostname"]; ok {
   326  		obj.Hostname = v.(string)
   327  	}
   328  
   329  	if v, ok := in["image_pull_secrets"].([]interface{}); ok {
   330  		cs := expandLocalObjectReferenceArray(v)
   331  		obj.ImagePullSecrets = cs
   332  	}
   333  
   334  	if v, ok := in["node_name"]; ok {
   335  		obj.NodeName = v.(string)
   336  	}
   337  
   338  	if v, ok := in["node_selector"].(map[string]string); ok {
   339  		obj.NodeSelector = v
   340  	}
   341  
   342  	if v, ok := in["restart_policy"].(string); ok {
   343  		obj.RestartPolicy = v1.RestartPolicy(v)
   344  	}
   345  
   346  	if v, ok := in["security_context"].([]interface{}); ok && len(v) > 0 {
   347  		obj.SecurityContext = expandPodSecurityContext(v)
   348  	}
   349  
   350  	if v, ok := in["service_account_name"].(string); ok {
   351  		obj.ServiceAccountName = v
   352  	}
   353  
   354  	if v, ok := in["subdomain"].(string); ok {
   355  		obj.Subdomain = v
   356  	}
   357  
   358  	if v, ok := in["termination_grace_period_seconds"].(int); ok {
   359  		obj.TerminationGracePeriodSeconds = ptrToInt64(int64(v))
   360  	}
   361  
   362  	if v, ok := in["volume"].([]interface{}); ok && len(v) > 0 {
   363  		cs, err := expandVolumes(v)
   364  		if err != nil {
   365  			return obj, err
   366  		}
   367  		obj.Volumes = cs
   368  	}
   369  	return obj, nil
   370  }
   371  
   372  func expandPodSecurityContext(l []interface{}) *v1.PodSecurityContext {
   373  	if len(l) == 0 || l[0] == nil {
   374  		return &v1.PodSecurityContext{}
   375  	}
   376  	in := l[0].(map[string]interface{})
   377  	obj := &v1.PodSecurityContext{}
   378  	if v, ok := in["fs_group"].(int); ok {
   379  		obj.FSGroup = ptrToInt64(int64(v))
   380  	}
   381  	if v, ok := in["run_as_non_root"].(bool); ok {
   382  		obj.RunAsNonRoot = ptrToBool(v)
   383  	}
   384  	if v, ok := in["run_as_user"].(int); ok {
   385  		obj.RunAsUser = ptrToInt64(int64(v))
   386  	}
   387  	if v, ok := in["supplemental_groups"].(*schema.Set); ok {
   388  		obj.SupplementalGroups = schemaSetToInt64Array(v)
   389  	}
   390  
   391  	if v, ok := in["se_linux_options"].([]interface{}); ok && len(v) > 0 {
   392  		obj.SELinuxOptions = expandSeLinuxOptions(v)
   393  	}
   394  
   395  	return obj
   396  }
   397  
   398  func expandSeLinuxOptions(l []interface{}) *v1.SELinuxOptions {
   399  	if len(l) == 0 || l[0] == nil {
   400  		return &v1.SELinuxOptions{}
   401  	}
   402  	in := l[0].(map[string]interface{})
   403  	obj := &v1.SELinuxOptions{}
   404  	if v, ok := in["level"]; ok {
   405  		obj.Level = v.(string)
   406  	}
   407  	if v, ok := in["role"]; ok {
   408  		obj.Role = v.(string)
   409  	}
   410  	if v, ok := in["type"]; ok {
   411  		obj.Type = v.(string)
   412  	}
   413  	if v, ok := in["user"]; ok {
   414  		obj.User = v.(string)
   415  	}
   416  	return obj
   417  }
   418  
   419  func expandKeyPath(in []interface{}) []v1.KeyToPath {
   420  	if len(in) == 0 {
   421  		return []v1.KeyToPath{}
   422  	}
   423  	keyPaths := make([]v1.KeyToPath, len(in))
   424  	for i, c := range in {
   425  		p := c.(map[string]interface{})
   426  		if v, ok := p["key"].(string); ok {
   427  			keyPaths[i].Key = v
   428  		}
   429  		if v, ok := p["mode"].(int); ok {
   430  			keyPaths[i].Mode = ptrToInt32(int32(v))
   431  		}
   432  		if v, ok := p["path"].(string); ok {
   433  			keyPaths[i].Path = v
   434  		}
   435  
   436  	}
   437  	return keyPaths
   438  }
   439  
   440  func expandDownwardAPIVolumeFile(in []interface{}) ([]v1.DownwardAPIVolumeFile, error) {
   441  	var err error
   442  	if len(in) == 0 {
   443  		return []v1.DownwardAPIVolumeFile{}, nil
   444  	}
   445  	dapivf := make([]v1.DownwardAPIVolumeFile, len(in))
   446  	for i, c := range in {
   447  		p := c.(map[string]interface{})
   448  		if v, ok := p["mode"].(int); ok {
   449  			dapivf[i].Mode = ptrToInt32(int32(v))
   450  		}
   451  		if v, ok := p["path"].(string); ok {
   452  			dapivf[i].Path = v
   453  		}
   454  		if v, ok := p["field_ref"].([]interface{}); ok && len(v) > 0 {
   455  			dapivf[i].FieldRef, err = expandFieldRef(v)
   456  			if err != nil {
   457  				return dapivf, err
   458  			}
   459  		}
   460  		if v, ok := p["resource_field_ref"].([]interface{}); ok && len(v) > 0 {
   461  			dapivf[i].ResourceFieldRef, err = expandResourceFieldRef(v)
   462  			if err != nil {
   463  				return dapivf, err
   464  			}
   465  		}
   466  	}
   467  	return dapivf, nil
   468  }
   469  
   470  func expandConfigMapVolumeSource(l []interface{}) *v1.ConfigMapVolumeSource {
   471  	if len(l) == 0 || l[0] == nil {
   472  		return &v1.ConfigMapVolumeSource{}
   473  	}
   474  	in := l[0].(map[string]interface{})
   475  	obj := &v1.ConfigMapVolumeSource{
   476  		DefaultMode: ptrToInt32(int32(in["default_mode "].(int))),
   477  	}
   478  
   479  	if v, ok := in["name"].(string); ok {
   480  		obj.Name = v
   481  	}
   482  
   483  	if v, ok := in["items"].([]interface{}); ok && len(v) > 0 {
   484  		obj.Items = expandKeyPath(v)
   485  	}
   486  
   487  	return obj
   488  }
   489  
   490  func expandDownwardAPIVolumeSource(l []interface{}) (*v1.DownwardAPIVolumeSource, error) {
   491  	if len(l) == 0 || l[0] == nil {
   492  		return &v1.DownwardAPIVolumeSource{}, nil
   493  	}
   494  	in := l[0].(map[string]interface{})
   495  	obj := &v1.DownwardAPIVolumeSource{
   496  		DefaultMode: ptrToInt32(int32(in["default_mode "].(int))),
   497  	}
   498  	if v, ok := in["items"].([]interface{}); ok && len(v) > 0 {
   499  		var err error
   500  		obj.Items, err = expandDownwardAPIVolumeFile(v)
   501  		if err != nil {
   502  			return obj, err
   503  		}
   504  	}
   505  	return obj, nil
   506  }
   507  
   508  func expandGitRepoVolumeSource(l []interface{}) *v1.GitRepoVolumeSource {
   509  	if len(l) == 0 || l[0] == nil {
   510  		return &v1.GitRepoVolumeSource{}
   511  	}
   512  	in := l[0].(map[string]interface{})
   513  	obj := &v1.GitRepoVolumeSource{}
   514  
   515  	if v, ok := in["directory"].(string); ok {
   516  		obj.Directory = v
   517  	}
   518  
   519  	if v, ok := in["repository"].(string); ok {
   520  		obj.Repository = v
   521  	}
   522  	if v, ok := in["revision"].(string); ok {
   523  		obj.Revision = v
   524  	}
   525  	return obj
   526  }
   527  
   528  func expandEmptyDirVolumeSource(l []interface{}) *v1.EmptyDirVolumeSource {
   529  	if len(l) == 0 || l[0] == nil {
   530  		return &v1.EmptyDirVolumeSource{}
   531  	}
   532  	in := l[0].(map[string]interface{})
   533  	obj := &v1.EmptyDirVolumeSource{
   534  		Medium: v1.StorageMedium(in["medium"].(string)),
   535  	}
   536  	return obj
   537  }
   538  
   539  func expandPersistentVolumeClaimVolumeSource(l []interface{}) *v1.PersistentVolumeClaimVolumeSource {
   540  	if len(l) == 0 || l[0] == nil {
   541  		return &v1.PersistentVolumeClaimVolumeSource{}
   542  	}
   543  	in := l[0].(map[string]interface{})
   544  	obj := &v1.PersistentVolumeClaimVolumeSource{
   545  		ClaimName: in["claim_name"].(string),
   546  		ReadOnly:  in["read_only"].(bool),
   547  	}
   548  	return obj
   549  }
   550  
   551  func expandSecretVolumeSource(l []interface{}) *v1.SecretVolumeSource {
   552  	if len(l) == 0 || l[0] == nil {
   553  		return &v1.SecretVolumeSource{}
   554  	}
   555  	in := l[0].(map[string]interface{})
   556  	obj := &v1.SecretVolumeSource{
   557  		SecretName: in["secret_name"].(string),
   558  	}
   559  	return obj
   560  }
   561  
   562  func expandVolumes(volumes []interface{}) ([]v1.Volume, error) {
   563  	if len(volumes) == 0 {
   564  		return []v1.Volume{}, nil
   565  	}
   566  	vl := make([]v1.Volume, len(volumes))
   567  	for i, c := range volumes {
   568  		m := c.(map[string]interface{})
   569  
   570  		if value, ok := m["name"]; ok {
   571  			vl[i].Name = value.(string)
   572  		}
   573  
   574  		if value, ok := m["config_map"].([]interface{}); ok && len(value) > 0 {
   575  			vl[i].ConfigMap = expandConfigMapVolumeSource(value)
   576  		}
   577  		if value, ok := m["git_repo"].([]interface{}); ok && len(value) > 0 {
   578  			vl[i].GitRepo = expandGitRepoVolumeSource(value)
   579  		}
   580  
   581  		if value, ok := m["empty_dir"].([]interface{}); ok && len(value) > 0 {
   582  			vl[i].EmptyDir = expandEmptyDirVolumeSource(value)
   583  		}
   584  		if value, ok := m["downward_api"].([]interface{}); ok && len(value) > 0 {
   585  			var err error
   586  			vl[i].DownwardAPI, err = expandDownwardAPIVolumeSource(value)
   587  			if err != nil {
   588  				return vl, err
   589  			}
   590  		}
   591  
   592  		if value, ok := m["persistent_volume_claim"].([]interface{}); ok && len(value) > 0 {
   593  			vl[i].PersistentVolumeClaim = expandPersistentVolumeClaimVolumeSource(value)
   594  		}
   595  		if value, ok := m["secret"].([]interface{}); ok && len(value) > 0 {
   596  			vl[i].Secret = expandSecretVolumeSource(value)
   597  		}
   598  		if v, ok := m["gce_persistent_disk"].([]interface{}); ok && len(v) > 0 {
   599  			vl[i].GCEPersistentDisk = expandGCEPersistentDiskVolumeSource(v)
   600  		}
   601  		if v, ok := m["aws_elastic_block_store"].([]interface{}); ok && len(v) > 0 {
   602  			vl[i].AWSElasticBlockStore = expandAWSElasticBlockStoreVolumeSource(v)
   603  		}
   604  		if v, ok := m["host_path"].([]interface{}); ok && len(v) > 0 {
   605  			vl[i].HostPath = expandHostPathVolumeSource(v)
   606  		}
   607  		if v, ok := m["glusterfs"].([]interface{}); ok && len(v) > 0 {
   608  			vl[i].Glusterfs = expandGlusterfsVolumeSource(v)
   609  		}
   610  		if v, ok := m["nfs"].([]interface{}); ok && len(v) > 0 {
   611  			vl[i].NFS = expandNFSVolumeSource(v)
   612  		}
   613  		if v, ok := m["rbd"].([]interface{}); ok && len(v) > 0 {
   614  			vl[i].RBD = expandRBDVolumeSource(v)
   615  		}
   616  		if v, ok := m["iscsi"].([]interface{}); ok && len(v) > 0 {
   617  			vl[i].ISCSI = expandISCSIVolumeSource(v)
   618  		}
   619  		if v, ok := m["cinder"].([]interface{}); ok && len(v) > 0 {
   620  			vl[i].Cinder = expandCinderVolumeSource(v)
   621  		}
   622  		if v, ok := m["ceph_fs"].([]interface{}); ok && len(v) > 0 {
   623  			vl[i].CephFS = expandCephFSVolumeSource(v)
   624  		}
   625  		if v, ok := m["fc"].([]interface{}); ok && len(v) > 0 {
   626  			vl[i].FC = expandFCVolumeSource(v)
   627  		}
   628  		if v, ok := m["flocker"].([]interface{}); ok && len(v) > 0 {
   629  			vl[i].Flocker = expandFlockerVolumeSource(v)
   630  		}
   631  		if v, ok := m["flex_volume"].([]interface{}); ok && len(v) > 0 {
   632  			vl[i].FlexVolume = expandFlexVolumeSource(v)
   633  		}
   634  		if v, ok := m["azure_file"].([]interface{}); ok && len(v) > 0 {
   635  			vl[i].AzureFile = expandAzureFileVolumeSource(v)
   636  		}
   637  		if v, ok := m["vsphere_volume"].([]interface{}); ok && len(v) > 0 {
   638  			vl[i].VsphereVolume = expandVsphereVirtualDiskVolumeSource(v)
   639  		}
   640  		if v, ok := m["quobyte"].([]interface{}); ok && len(v) > 0 {
   641  			vl[i].Quobyte = expandQuobyteVolumeSource(v)
   642  		}
   643  		if v, ok := m["azure_disk"].([]interface{}); ok && len(v) > 0 {
   644  			vl[i].AzureDisk = expandAzureDiskVolumeSource(v)
   645  		}
   646  		if v, ok := m["photon_persistent_disk"].([]interface{}); ok && len(v) > 0 {
   647  			vl[i].PhotonPersistentDisk = expandPhotonPersistentDiskVolumeSource(v)
   648  		}
   649  	}
   650  	return vl, nil
   651  }
   652  
   653  func patchPodSpec(pathPrefix, prefix string, d *schema.ResourceData) (PatchOperations, error) {
   654  	ops := make([]PatchOperation, 0)
   655  
   656  	if d.HasChange(prefix + "active_deadline_seconds") {
   657  
   658  		v := d.Get(prefix + "active_deadline_seconds").(int)
   659  		ops = append(ops, &ReplaceOperation{
   660  			Path:  pathPrefix + "/activeDeadlineSeconds",
   661  			Value: v,
   662  		})
   663  	}
   664  
   665  	if d.HasChange(prefix + "container") {
   666  		containers := d.Get(prefix + "container").([]interface{})
   667  		value, _ := expandContainers(containers)
   668  
   669  		for i, v := range value {
   670  			ops = append(ops, &ReplaceOperation{
   671  				Path:  pathPrefix + "/containers/" + strconv.Itoa(i) + "/image",
   672  				Value: v.Image,
   673  			})
   674  			ops = append(ops, &ReplaceOperation{
   675  				Path:  pathPrefix + "/containers/" + strconv.Itoa(i) + "/name",
   676  				Value: v.Name,
   677  			})
   678  
   679  		}
   680  
   681  	}
   682  
   683  	return ops, nil
   684  }