mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 01:26:43 +00:00
Merge pull request #1685 from emilymye/container_cluster_list_param_multifix
Make sure TypeList keys still have empty values
This commit is contained in:
commit
9bd15ad48d
@ -709,9 +709,9 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
d.Set("name", cluster.Name)
|
d.Set("name", cluster.Name)
|
||||||
|
if err := d.Set("network_policy", flattenNetworkPolicy(cluster.NetworkPolicy)); err != nil {
|
||||||
d.Set("network_policy", flattenNetworkPolicy(cluster.NetworkPolicy))
|
return err
|
||||||
|
}
|
||||||
d.Set("zone", cluster.Zone)
|
d.Set("zone", cluster.Zone)
|
||||||
|
|
||||||
locations := schema.NewSet(schema.HashString, convertStringArrToInterface(cluster.Locations))
|
locations := schema.NewSet(schema.HashString, convertStringArrToInterface(cluster.Locations))
|
||||||
@ -719,31 +719,15 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
|
|||||||
d.Set("additional_zones", locations)
|
d.Set("additional_zones", locations)
|
||||||
|
|
||||||
d.Set("endpoint", cluster.Endpoint)
|
d.Set("endpoint", cluster.Endpoint)
|
||||||
|
if err := d.Set("maintenance_policy", flattenMaintenancePolicy(cluster.MaintenancePolicy)); err != nil {
|
||||||
if cluster.MaintenancePolicy != nil {
|
return err
|
||||||
d.Set("maintenance_policy", flattenMaintenancePolicy(cluster.MaintenancePolicy))
|
|
||||||
}
|
}
|
||||||
|
if err := d.Set("master_auth", flattenMasterAuth(cluster.MasterAuth)); err != nil {
|
||||||
masterAuth := []map[string]interface{}{
|
return err
|
||||||
{
|
|
||||||
"username": cluster.MasterAuth.Username,
|
|
||||||
"password": cluster.MasterAuth.Password,
|
|
||||||
"client_certificate": cluster.MasterAuth.ClientCertificate,
|
|
||||||
"client_key": cluster.MasterAuth.ClientKey,
|
|
||||||
"cluster_ca_certificate": cluster.MasterAuth.ClusterCaCertificate,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
if len(cluster.MasterAuth.ClientCertificate) == 0 {
|
if err := d.Set("master_authorized_networks_config", flattenMasterAuthorizedNetworksConfig(cluster.MasterAuthorizedNetworksConfig)); err != nil {
|
||||||
masterAuth[0]["client_certificate_config"] = []map[string]interface{}{
|
return err
|
||||||
{"issue_client_certificate": false},
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
d.Set("master_auth", masterAuth)
|
|
||||||
|
|
||||||
if cluster.MasterAuthorizedNetworksConfig != nil {
|
|
||||||
d.Set("master_authorized_networks_config", flattenMasterAuthorizedNetworksConfig(cluster.MasterAuthorizedNetworksConfig))
|
|
||||||
}
|
|
||||||
|
|
||||||
d.Set("initial_node_count", cluster.InitialNodeCount)
|
d.Set("initial_node_count", cluster.InitialNodeCount)
|
||||||
d.Set("master_version", cluster.CurrentMasterVersion)
|
d.Set("master_version", cluster.CurrentMasterVersion)
|
||||||
d.Set("node_version", cluster.CurrentNodeVersion)
|
d.Set("node_version", cluster.CurrentNodeVersion)
|
||||||
@ -759,32 +743,33 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
d.Set("project", project)
|
d.Set("project", project)
|
||||||
if cluster.AddonsConfig != nil {
|
if err := d.Set("addons_config", flattenClusterAddonsConfig(cluster.AddonsConfig)); err != nil {
|
||||||
d.Set("addons_config", flattenClusterAddonsConfig(cluster.AddonsConfig))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nps, err := flattenClusterNodePools(d, config, cluster.NodePools)
|
nps, err := flattenClusterNodePools(d, config, cluster.NodePools)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
d.Set("node_pool", nps)
|
if err := d.Set("node_pool", nps); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if cluster.IpAllocationPolicy != nil {
|
|
||||||
if err := d.Set("ip_allocation_policy", flattenIPAllocationPolicy(cluster.IpAllocationPolicy)); err != nil {
|
if err := d.Set("ip_allocation_policy", flattenIPAllocationPolicy(cluster.IpAllocationPolicy)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if igUrls, err := getInstanceGroupUrlsFromManagerUrls(config, cluster.InstanceGroupUrls); err != nil {
|
igUrls, err := getInstanceGroupUrlsFromManagerUrls(config, cluster.InstanceGroupUrls)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := d.Set("instance_group_urls", igUrls); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
|
||||||
d.Set("instance_group_urls", igUrls)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if cluster.PodSecurityPolicyConfig != nil {
|
|
||||||
if err := d.Set("pod_security_policy_config", flattenPodSecurityPolicyConfig(cluster.PodSecurityPolicyConfig)); err != nil {
|
if err := d.Set("pod_security_policy_config", flattenPodSecurityPolicyConfig(cluster.PodSecurityPolicyConfig)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
d.Set("private_cluster", cluster.PrivateCluster)
|
d.Set("private_cluster", cluster.PrivateCluster)
|
||||||
d.Set("master_ipv4_cidr_block", cluster.MasterIpv4CidrBlock)
|
d.Set("master_ipv4_cidr_block", cluster.MasterIpv4CidrBlock)
|
||||||
@ -1386,6 +1371,9 @@ func flattenNetworkPolicy(c *containerBeta.NetworkPolicy) []map[string]interface
|
|||||||
|
|
||||||
func flattenClusterAddonsConfig(c *containerBeta.AddonsConfig) []map[string]interface{} {
|
func flattenClusterAddonsConfig(c *containerBeta.AddonsConfig) []map[string]interface{} {
|
||||||
result := make(map[string]interface{})
|
result := make(map[string]interface{})
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if c.HorizontalPodAutoscaling != nil {
|
if c.HorizontalPodAutoscaling != nil {
|
||||||
result["horizontal_pod_autoscaling"] = []map[string]interface{}{
|
result["horizontal_pod_autoscaling"] = []map[string]interface{}{
|
||||||
{
|
{
|
||||||
@ -1433,6 +1421,9 @@ func flattenClusterNodePools(d *schema.ResourceData, config *Config, c []*contai
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenIPAllocationPolicy(c *containerBeta.IPAllocationPolicy) []map[string]interface{} {
|
func flattenIPAllocationPolicy(c *containerBeta.IPAllocationPolicy) []map[string]interface{} {
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return []map[string]interface{}{
|
return []map[string]interface{}{
|
||||||
{
|
{
|
||||||
"cluster_secondary_range_name": c.ClusterSecondaryRangeName,
|
"cluster_secondary_range_name": c.ClusterSecondaryRangeName,
|
||||||
@ -1442,6 +1433,9 @@ func flattenIPAllocationPolicy(c *containerBeta.IPAllocationPolicy) []map[string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenMaintenancePolicy(mp *containerBeta.MaintenancePolicy) []map[string]interface{} {
|
func flattenMaintenancePolicy(mp *containerBeta.MaintenancePolicy) []map[string]interface{} {
|
||||||
|
if mp == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return []map[string]interface{}{
|
return []map[string]interface{}{
|
||||||
{
|
{
|
||||||
"daily_maintenance_window": []map[string]interface{}{
|
"daily_maintenance_window": []map[string]interface{}{
|
||||||
@ -1454,7 +1448,31 @@ func flattenMaintenancePolicy(mp *containerBeta.MaintenancePolicy) []map[string]
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func flattenMasterAuth(ma *containerBeta.MasterAuth) []map[string]interface{} {
|
||||||
|
if ma == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
masterAuth := []map[string]interface{}{
|
||||||
|
{
|
||||||
|
"username": ma.Username,
|
||||||
|
"password": ma.Password,
|
||||||
|
"client_certificate": ma.ClientCertificate,
|
||||||
|
"client_key": ma.ClientKey,
|
||||||
|
"cluster_ca_certificate": ma.ClusterCaCertificate,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if len(ma.ClientCertificate) == 0 {
|
||||||
|
masterAuth[0]["client_certificate_config"] = []map[string]interface{}{
|
||||||
|
{"issue_client_certificate": false},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return masterAuth
|
||||||
|
}
|
||||||
|
|
||||||
func flattenMasterAuthorizedNetworksConfig(c *containerBeta.MasterAuthorizedNetworksConfig) []map[string]interface{} {
|
func flattenMasterAuthorizedNetworksConfig(c *containerBeta.MasterAuthorizedNetworksConfig) []map[string]interface{} {
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if len(c.CidrBlocks) == 0 {
|
if len(c.CidrBlocks) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1473,6 +1491,9 @@ func flattenMasterAuthorizedNetworksConfig(c *containerBeta.MasterAuthorizedNetw
|
|||||||
}
|
}
|
||||||
|
|
||||||
func flattenPodSecurityPolicyConfig(c *containerBeta.PodSecurityPolicyConfig) []map[string]interface{} {
|
func flattenPodSecurityPolicyConfig(c *containerBeta.PodSecurityPolicyConfig) []map[string]interface{} {
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return []map[string]interface{}{
|
return []map[string]interface{}{
|
||||||
{
|
{
|
||||||
"enabled": c.Enabled,
|
"enabled": c.Enabled,
|
||||||
|
Loading…
Reference in New Issue
Block a user