Don't crash if node config is nil in google_container_cluster (#467)

This commit is contained in:
Vincent Roseberry 2017-09-26 15:32:12 -07:00 committed by GitHub
parent 38a961facc
commit 27a99c7dab

View File

@ -162,20 +162,24 @@ func expandNodeConfig(v interface{}) *container.NodeConfig {
}
func flattenNodeConfig(c *container.NodeConfig) []map[string]interface{} {
config := []map[string]interface{}{
{
"machine_type": c.MachineType,
"disk_size_gb": c.DiskSizeGb,
"local_ssd_count": c.LocalSsdCount,
"service_account": c.ServiceAccount,
"metadata": c.Metadata,
"image_type": c.ImageType,
"labels": c.Labels,
"tags": c.Tags,
"preemptible": c.Preemptible,
},
config := make([]map[string]interface{}, 0, 1)
if c == nil {
return config
}
config = append(config, map[string]interface{}{
"machine_type": c.MachineType,
"disk_size_gb": c.DiskSizeGb,
"local_ssd_count": c.LocalSsdCount,
"service_account": c.ServiceAccount,
"metadata": c.Metadata,
"image_type": c.ImageType,
"labels": c.Labels,
"tags": c.Tags,
"preemptible": c.Preemptible,
})
if len(c.OauthScopes) > 0 {
config[0]["oauth_scopes"] = c.OauthScopes
}