Skip to content

Commit

Permalink
google container_cluster master_auth should be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
dwradcliffe committed May 18, 2017
1 parent 0b2d02f commit f781ede
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
22 changes: 12 additions & 10 deletions builtin/providers/google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func resourceContainerCluster() *schema.Resource {
Schema: map[string]*schema.Schema{
"master_auth": &schema.Schema{
Type: schema.TypeList,
Required: true,
Required: false,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -342,19 +342,21 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
zoneName := d.Get("zone").(string)
clusterName := d.Get("name").(string)

masterAuths := d.Get("master_auth").([]interface{})
if len(masterAuths) > 1 {
return fmt.Errorf("Cannot specify more than one master_auth.")
cluster := &container.Cluster{
Name: clusterName,
InitialNodeCount: int64(d.Get("initial_node_count").(int)),
}
masterAuth := masterAuths[0].(map[string]interface{})

cluster := &container.Cluster{
MasterAuth: &container.MasterAuth{
if v, ok := d.GetOk("master_auth"); ok {
masterAuths := v.([]interface{})
if len(masterAuths) > 1 {
return fmt.Errorf("Cannot specify more than one master_auth.")
}
masterAuth := masterAuths[0].(map[string]interface{})
cluster.MasterAuth = &container.MasterAuth{
Password: masterAuth["password"].(string),
Username: masterAuth["username"].(string),
},
Name: clusterName,
InitialNodeCount: int64(d.Get("initial_node_count").(int)),
}
}

if v, ok := d.GetOk("node_version"); ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ resource "google_container_cluster" "primary" {
* `initial_node_count` - (Required) The number of nodes to create in this
cluster (not including the Kubernetes master).

* `master_auth` - (Required) The authentication information for accessing the
Kubernetes master.

* `name` - (Required) The name of the cluster, unique within the project and
zone.

* `zone` - (Required) The zone that the master and the number of nodes specified
in `initial_node_count` should be created in.

- - -
* `master_auth` - (Optional) The authentication information for accessing the
Kubernetes master.

* `additional_zones` - (Optional) If additional zones are configured, the number
of nodes specified in `initial_node_count` is created in all specified zones.

Expand Down

0 comments on commit f781ede

Please sign in to comment.