convert dataproc_cluster.cluster_config.gce_cluster_config.tags into a set (#2633)

This commit is contained in:
The Magician 2018-12-12 11:27:56 -08:00 committed by Nathan McKinley
parent e31696da5a
commit 99f9d71a31
2 changed files with 8 additions and 6 deletions

View File

@ -144,7 +144,7 @@ func resourceDataprocCluster() *schema.Resource {
}, },
"tags": { "tags": {
Type: schema.TypeList, Type: schema.TypeSet,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
@ -541,7 +541,7 @@ func expandGceClusterConfig(d *schema.ResourceData, config *Config) (*dataproc.G
conf.SubnetworkUri = snf.RelativeLink() conf.SubnetworkUri = snf.RelativeLink()
} }
if v, ok := cfg["tags"]; ok { if v, ok := cfg["tags"]; ok {
conf.Tags = convertStringArr(v.([]interface{})) conf.Tags = convertStringSet(v.(*schema.Set))
} }
if v, ok := cfg["service_account"]; ok { if v, ok := cfg["service_account"]; ok {
conf.ServiceAccount = v.(string) conf.ServiceAccount = v.(string)
@ -840,7 +840,7 @@ func flattenInitializationActions(nia []*dataproc.NodeInitializationAction) ([]m
func flattenGceClusterConfig(d *schema.ResourceData, gcc *dataproc.GceClusterConfig) []map[string]interface{} { func flattenGceClusterConfig(d *schema.ResourceData, gcc *dataproc.GceClusterConfig) []map[string]interface{} {
gceConfig := map[string]interface{}{ gceConfig := map[string]interface{}{
"tags": gcc.Tags, "tags": schema.NewSet(schema.HashString, convertStringArrToInterface(gcc.Tags)),
"service_account": gcc.ServiceAccount, "service_account": gcc.ServiceAccount,
"zone": GetResourceNameFromSelfLink(gcc.ZoneUri), "zone": GetResourceNameFromSelfLink(gcc.ZoneUri),
"internal_ip_only": gcc.InternalIpOnly, "internal_ip_only": gcc.InternalIpOnly,

View File

@ -217,7 +217,7 @@ func TestAccDataprocCluster_withInternalIpOnlyTrue(t *testing.T) {
}) })
} }
func TestAccDataprocCluster_withMetadata(t *testing.T) { func TestAccDataprocCluster_withMetadataAndTags(t *testing.T) {
t.Parallel() t.Parallel()
var cluster dataproc.Cluster var cluster dataproc.Cluster
@ -228,12 +228,13 @@ func TestAccDataprocCluster_withMetadata(t *testing.T) {
CheckDestroy: testAccCheckDataprocClusterDestroy(), CheckDestroy: testAccCheckDataprocClusterDestroy(),
Steps: []resource.TestStep{ Steps: []resource.TestStep{
{ {
Config: testAccDataprocCluster_withMetadata(rnd), Config: testAccDataprocCluster_withMetadataAndTags(rnd),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckDataprocClusterExists("google_dataproc_cluster.basic", &cluster), testAccCheckDataprocClusterExists("google_dataproc_cluster.basic", &cluster),
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.metadata.foo", "bar"), resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.metadata.foo", "bar"),
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.metadata.baz", "qux"), resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.metadata.baz", "qux"),
resource.TestCheckResourceAttr("google_dataproc_cluster.basic", "cluster_config.0.gce_cluster_config.0.tags.#", "4"),
), ),
}, },
}, },
@ -785,7 +786,7 @@ resource "google_dataproc_cluster" "basic" {
`, rnd, rnd, rnd) `, rnd, rnd, rnd)
} }
func testAccDataprocCluster_withMetadata(rnd string) string { func testAccDataprocCluster_withMetadataAndTags(rnd string) string {
return fmt.Sprintf(` return fmt.Sprintf(`
resource "google_dataproc_cluster" "basic" { resource "google_dataproc_cluster" "basic" {
name = "dproc-cluster-test-%s" name = "dproc-cluster-test-%s"
@ -797,6 +798,7 @@ resource "google_dataproc_cluster" "basic" {
foo = "bar" foo = "bar"
baz = "qux" baz = "qux"
} }
tags = ["my-tag", "your-tag", "our-tag", "their-tag"]
} }
} }
} }