Merge pull request #7 from unguiculus/feature/tags_labels

Add support for labels and tags on GKE node_config
This commit is contained in:
Dana Hoffman 2017-06-19 10:04:57 -07:00 committed by GitHub
commit dcb564b23d
3 changed files with 50 additions and 0 deletions

View File

@ -284,6 +284,20 @@ func resourceContainerCluster() *schema.Resource {
Computed: true,
ForceNew: true,
},
"labels": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: schema.TypeString,
},
"tags": &schema.Schema{
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
},
},
@ -468,6 +482,23 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
if v, ok = nodeConfig["image_type"]; ok {
cluster.NodeConfig.ImageType = v.(string)
}
if v, ok = nodeConfig["labels"]; ok {
m := make(map[string]string)
for k, val := range v.(map[string]interface{}) {
m[k] = val.(string)
}
cluster.NodeConfig.Labels = m
}
if v, ok := nodeConfig["tags"]; ok {
tagsList := v.([]interface{})
tags := []string{}
for _, v := range tagsList {
tags = append(tags, v.(string))
}
cluster.NodeConfig.Tags = tags
}
}
nodePoolsCount := d.Get("node_pool.#").(int)
@ -683,6 +714,8 @@ func flattenClusterNodeConfig(c *container.NodeConfig) []map[string]interface{}
"service_account": c.ServiceAccount,
"metadata": c.Metadata,
"image_type": c.ImageType,
"labels": c.Labels,
"tags": c.Tags,
},
}

View File

@ -268,6 +268,8 @@ func testAccCheckContainerCluster(n string) resource.TestCheckFunc {
{"node_config.0.service_account", cluster.NodeConfig.ServiceAccount},
{"node_config.0.metadata", cluster.NodeConfig.Metadata},
{"node_config.0.image_type", cluster.NodeConfig.ImageType},
{"node_config.0.labels", cluster.NodeConfig.Labels},
{"node_config.0.tags", cluster.NodeConfig.Tags},
{"node_version", cluster.CurrentNodeVersion},
}
@ -466,6 +468,10 @@ resource "google_container_cluster" "with_node_config" {
foo = "bar"
}
image_type = "CONTAINER_VM"
labels {
foo = "bar"
}
tags = ["foo", "bar"]
}
}`, acctest.RandString(10))

View File

@ -40,6 +40,12 @@ resource "google_container_cluster" "primary" {
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
labels {
foo = "bar"
}
tags = ["foo", "bar"]
}
}
```
@ -137,6 +143,11 @@ which the cluster's instances are launched
* `image_type` - (Optional) The image type to use for this node.
* `labels` - (Optional) The Kubernetes labels (key/value pairs) to be applied to each node.
* `tags` - (Optional) The list of instance tags applied to all nodes. Tags are used to identify
valid sources or targets for network firewalls.
**Addons Config** supports the following addons:
* `http_load_balancing` - (Optional) The status of the HTTP Load Balancing