Add sort on google_container_cluster auth_scopes (#506)

* replalce TypeList by TypeSet

* Add migrate function and test

* CORRECT

* remove migrate

* fix tests
This commit is contained in:
Sébastien GLON 2017-10-25 22:41:42 +02:00 committed by Dana Hoffman
parent ec008135ce
commit 1f954e0131
2 changed files with 13 additions and 10 deletions

View File

@ -38,7 +38,7 @@ var schemaNodeConfig = &schema.Schema{
},
"oauth_scopes": {
Type: schema.TypeList,
Type: schema.TypeSet,
Optional: true,
Computed: true,
ForceNew: true,
@ -48,6 +48,7 @@ var schemaNodeConfig = &schema.Schema{
return canonicalizeServiceScope(v.(string))
},
},
Set: stringScopeHashcode,
},
"service_account": {
@ -113,11 +114,11 @@ func expandNodeConfig(v interface{}) *container.NodeConfig {
nc.LocalSsdCount = int64(v.(int))
}
if v, ok := nodeConfig["oauth_scopes"]; ok {
scopesList := v.([]interface{})
scopes := []string{}
for _, v := range scopesList {
scopes = append(scopes, canonicalizeServiceScope(v.(string)))
if scopes, ok := nodeConfig["oauth_scopes"]; ok {
scopesSet := scopes.(*schema.Set)
scopes := make([]string, scopesSet.Len())
for i, scope := range scopesSet.List() {
scopes[i] = canonicalizeServiceScope(scope.(string))
}
nc.OauthScopes = scopes
@ -181,7 +182,7 @@ func flattenNodeConfig(c *container.NodeConfig) []map[string]interface{} {
})
if len(c.OauthScopes) > 0 {
config[0]["oauth_scopes"] = c.OauthScopes
config[0]["oauth_scopes"] = schema.NewSet(stringScopeHashcode, convertStringArrToInterface(c.OauthScopes))
}
return config

View File

@ -535,7 +535,9 @@ func testAccCheckContainerClusterDestroy(s *terraform.State) error {
}
var setFields map[string]struct{} = map[string]struct{}{
"additional_zones": struct{}{},
"additional_zones": struct{}{},
"node_config.0.oauth_scopes": struct{}{},
"node_pool.0.node_config.0.oauth_scopes": struct{}{},
}
func testAccCheckContainerCluster(n string) resource.TestCheckFunc {
@ -991,10 +993,10 @@ resource "google_container_cluster" "with_node_config" {
disk_size_gb = 15
local_ssd_count = 1
oauth_scopes = [
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring"
"https://www.googleapis.com/auth/logging.write"
]
service_account = "default"
metadata {