Skip to content

Commit

Permalink
set master_authorized_networks_config.enabled=true when there is a ma…
Browse files Browse the repository at this point in the history
…ster_authorized_networks_config block (#2939)

Merged PR #2939.
  • Loading branch information
yukinying authored and modular-magician committed Jan 8, 2020
1 parent a72a112 commit 988be6e
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions third_party/validator/container.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// This file is written manually and is not based from terraform-provider-google.
// There is a huge potential for drift. The longer term plan is to have this
// file generated from the logic in terraform-provider-google. Please
// see https://github.com/GoogleCloudPlatform/magic-modules/pull/2485#issuecomment-545680059
// This file is written manually and is not based from terraform-provider-google.
// There is a huge potential for drift. The longer term plan is to have this
// file generated from the logic in terraform-provider-google. Please
// see https://github.com/GoogleCloudPlatform/magic-modules/pull/2485#issuecomment-545680059
// for the discussion.

package google

import (
"fmt"
"fmt"
"reflect"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -1100,12 +1100,9 @@ func expandContainerClusterMasterAuthorizedNetworksConfig(v interface{}, d Terra
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedEnabled, err := expandContainerClusterMasterAuthorizedNetworksConfigEnabled(original["enabled"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEnabled); val.IsValid() && !isEmptyValue(val) {
transformed["enabled"] = transformedEnabled
}
// enabled is always true as long as there is a master_authorized_networks_config config block.
// There is no option in Terraform to disable that when master_authorized_networks_config is seen.
transformed["enabled"] = true

transformedCidrBlocks, err := expandContainerClusterMasterAuthorizedNetworksConfigCidrBlocks(original["cidr_blocks"], d, config)
if err != nil {
Expand All @@ -1117,10 +1114,6 @@ func expandContainerClusterMasterAuthorizedNetworksConfig(v interface{}, d Terra
return transformed, nil
}

func expandContainerClusterMasterAuthorizedNetworksConfigEnabled(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandContainerClusterMasterAuthorizedNetworksConfigCidrBlocks(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
v = v.(*schema.Set).List()
l := v.([]interface{})
Expand Down

0 comments on commit 988be6e

Please sign in to comment.