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:
Vincent Roseberry 2018-02-09 13:55:38 -08:00 committed by GitHub
parent 8c4c546a3c
commit 5f32d7e87a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1095,8 +1095,9 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig {
func expandIPAllocationPolicy(configured interface{}) (*container.IPAllocationPolicy, error) {
ap := &container.IPAllocationPolicy{}
if len(configured.([]interface{})) > 0 {
if config, ok := configured.([]interface{})[0].(map[string]interface{}); ok {
l := configured.([]interface{})
if len(l) > 0 {
if config, ok := l[0].(map[string]interface{}); ok {
ap.UseIpAliases = true
if v, ok := config["cluster_secondary_range_name"]; ok {
ap.ClusterSecondaryRangeName = v.(string)
@ -1105,14 +1106,10 @@ func expandIPAllocationPolicy(configured interface{}) (*container.IPAllocationPo
if v, ok := config["services_secondary_range_name"]; ok {
ap.ServicesSecondaryRangeName = v.(string)
}
if ap.UseIpAliases &&
(ap.ClusterSecondaryRangeName == "" || ap.ServicesSecondaryRangeName == "") {
} else {
return nil, fmt.Errorf("clusters using IP aliases must specify secondary ranges.")
}
}
}
return ap, nil
}