Skip to content

Commit

Permalink
UseIpAliases should be true when not set and the ip_allocation_policy…
Browse files Browse the repository at this point in the history
… block is set (#3732) (#2260)

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Jul 8, 2020
1 parent 4a38e72 commit 473be78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/3732.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
container: fixes a bug where useIpAlias was not defaulting to true inside the `ip_allocation_policy` block
```
8 changes: 4 additions & 4 deletions google-beta/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2516,10 +2516,10 @@ func expandClusterAddonsConfig(configured interface{}) *containerBeta.AddonsConf
return ac
}

func expandIPAllocationPolicy(configured interface{}, networking_mode string) (*containerBeta.IPAllocationPolicy, error) {
func expandIPAllocationPolicy(configured interface{}, networkingMode string) (*containerBeta.IPAllocationPolicy, error) {
l := configured.([]interface{})
if len(l) == 0 || l[0] == nil {
if networking_mode == "VPC_NATIVE" {
if networkingMode == "VPC_NATIVE" {
return nil, fmt.Errorf("`ip_allocation_policy` block is required for VPC_NATIVE clusters.")
}
return &containerBeta.IPAllocationPolicy{
Expand All @@ -2530,14 +2530,14 @@ func expandIPAllocationPolicy(configured interface{}, networking_mode string) (*

config := l[0].(map[string]interface{})
return &containerBeta.IPAllocationPolicy{
UseIpAliases: networking_mode == "VPC_NATIVE",
UseIpAliases: networkingMode == "VPC_NATIVE" || networkingMode == "",
ClusterIpv4CidrBlock: config["cluster_ipv4_cidr_block"].(string),
ServicesIpv4CidrBlock: config["services_ipv4_cidr_block"].(string),

ClusterSecondaryRangeName: config["cluster_secondary_range_name"].(string),
ServicesSecondaryRangeName: config["services_secondary_range_name"].(string),
ForceSendFields: []string{"UseIpAliases"},
UseRoutes: networking_mode == "ROUTES",
UseRoutes: networkingMode == "ROUTES",
}, nil
}

Expand Down

0 comments on commit 473be78

Please sign in to comment.