@@ -888,7 +888,7 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
888
888
return err
889
889
}
890
890
891
- if err := d .Set ("ip_allocation_policy" , flattenIPAllocationPolicy (cluster . IpAllocationPolicy , d , config )); err != nil {
891
+ if err := d .Set ("ip_allocation_policy" , flattenIPAllocationPolicy (cluster , d , config )); err != nil {
892
892
return err
893
893
}
894
894
@@ -1783,35 +1783,36 @@ func flattenPrivateClusterConfig(c *containerBeta.PrivateClusterConfig) []map[st
1783
1783
}
1784
1784
}
1785
1785
1786
- func flattenIPAllocationPolicy (c * containerBeta.IPAllocationPolicy , d * schema.ResourceData , config * Config ) []map [string ]interface {} {
1787
- if c == nil {
1786
+ func flattenIPAllocationPolicy (c * containerBeta.Cluster , d * schema.ResourceData , config * Config ) []map [string ]interface {} {
1787
+ if c == nil || c . IpAllocationPolicy == nil {
1788
1788
return nil
1789
1789
}
1790
- node_cidr_block := ""
1791
- if c .SubnetworkName != "" {
1792
- subnetwork , err := ParseSubnetworkFieldValue (c .SubnetworkName , d , config )
1790
+ nodeCidrBlock := ""
1791
+ if c .Subnetwork != "" {
1792
+ subnetwork , err := ParseSubnetworkFieldValue (c .Subnetwork , d , config )
1793
1793
if err == nil {
1794
1794
sn , err := config .clientCompute .Subnetworks .Get (subnetwork .Project , subnetwork .Region , subnetwork .Name ).Do ()
1795
1795
if err == nil {
1796
- node_cidr_block = sn .IpCidrRange
1796
+ nodeCidrBlock = sn .IpCidrRange
1797
1797
}
1798
1798
} else {
1799
1799
log .Printf ("[WARN] Unable to parse subnetwork name, got error while trying to get new subnetwork: %s" , err )
1800
1800
}
1801
1801
}
1802
+ p := c .IpAllocationPolicy
1802
1803
return []map [string ]interface {}{
1803
1804
{
1804
- "use_ip_aliases" : c .UseIpAliases ,
1805
+ "use_ip_aliases" : p .UseIpAliases ,
1805
1806
1806
- "create_subnetwork" : c .CreateSubnetwork ,
1807
- "subnetwork_name" : c .SubnetworkName ,
1807
+ "create_subnetwork" : p .CreateSubnetwork ,
1808
+ "subnetwork_name" : p .SubnetworkName ,
1808
1809
1809
- "cluster_ipv4_cidr_block" : c .ClusterIpv4CidrBlock ,
1810
- "services_ipv4_cidr_block" : c .ServicesIpv4CidrBlock ,
1811
- "node_ipv4_cidr_block" : node_cidr_block ,
1810
+ "cluster_ipv4_cidr_block" : p .ClusterIpv4CidrBlock ,
1811
+ "services_ipv4_cidr_block" : p .ServicesIpv4CidrBlock ,
1812
+ "node_ipv4_cidr_block" : nodeCidrBlock ,
1812
1813
1813
- "cluster_secondary_range_name" : c .ClusterSecondaryRangeName ,
1814
- "services_secondary_range_name" : c .ServicesSecondaryRangeName ,
1814
+ "cluster_secondary_range_name" : p .ClusterSecondaryRangeName ,
1815
+ "services_secondary_range_name" : p .ServicesSecondaryRangeName ,
1815
1816
},
1816
1817
}
1817
1818
}
0 commit comments