mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
Fix TestAccContainerCluster_withIPAllocationPolicy test (#1065)
* Remove bad test in testAccContainerCluster_withIPAllocationPolicy One step was expecting the test to fail if the subnetwork defines secondary ip ranges that the cluster doesn't use. However, it is perfectly fine to do so and we don't expect an error. * Revert "Remove bad test in testAccContainerCluster_withIPAllocationPolicy" This reverts commit af2f369907181a107cfc0ed9fa2ff0e288f02f66. * Fail if use_ip_aliases is true and no range names is provided * make fmt * don't introduce new field for now. Wait until we want to support new feature in allocation policy
This commit is contained in:
parent
8c4c546a3c
commit
5f32d7e87a
@ -1095,8 +1095,9 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig {
|
|||||||
|
|
||||||
func expandIPAllocationPolicy(configured interface{}) (*container.IPAllocationPolicy, error) {
|
func expandIPAllocationPolicy(configured interface{}) (*container.IPAllocationPolicy, error) {
|
||||||
ap := &container.IPAllocationPolicy{}
|
ap := &container.IPAllocationPolicy{}
|
||||||
if len(configured.([]interface{})) > 0 {
|
l := configured.([]interface{})
|
||||||
if config, ok := configured.([]interface{})[0].(map[string]interface{}); ok {
|
if len(l) > 0 {
|
||||||
|
if config, ok := l[0].(map[string]interface{}); ok {
|
||||||
ap.UseIpAliases = true
|
ap.UseIpAliases = true
|
||||||
if v, ok := config["cluster_secondary_range_name"]; ok {
|
if v, ok := config["cluster_secondary_range_name"]; ok {
|
||||||
ap.ClusterSecondaryRangeName = v.(string)
|
ap.ClusterSecondaryRangeName = v.(string)
|
||||||
@ -1105,14 +1106,10 @@ func expandIPAllocationPolicy(configured interface{}) (*container.IPAllocationPo
|
|||||||
if v, ok := config["services_secondary_range_name"]; ok {
|
if v, ok := config["services_secondary_range_name"]; ok {
|
||||||
ap.ServicesSecondaryRangeName = v.(string)
|
ap.ServicesSecondaryRangeName = v.(string)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if ap.UseIpAliases &&
|
|
||||||
(ap.ClusterSecondaryRangeName == "" || ap.ServicesSecondaryRangeName == "") {
|
|
||||||
|
|
||||||
return nil, fmt.Errorf("clusters using IP aliases must specify secondary ranges.")
|
return nil, fmt.Errorf("clusters using IP aliases must specify secondary ranges.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ap, nil
|
return ap, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user