From 8de8c6884d89d5121ea6574f2372dc526ad5fdc3 Mon Sep 17 00:00:00 2001 From: Albert Choi Date: Tue, 22 Mar 2016 08:38:56 -0700 Subject: [PATCH] [clc] re-add alias as an optional field. update docs --- Godeps/Godeps.json | 36 +++++++++---------- builtin/providers/clc/provider.go | 10 ++++++ .../CenturyLinkCloud/clc-sdk/api/api.go | 2 +- .../docs/providers/clc/index.html.markdown | 6 ++-- .../clc/r/load_balancer_pool.html.markdown | 6 ++++ .../docs/providers/clc/r/server.html.markdown | 1 + 6 files changed, 39 insertions(+), 22 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index a3f8f46af8..1d57dc97b9 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -152,48 +152,48 @@ }, { "ImportPath": "github.com/CenturyLinkCloud/clc-sdk", - "Comment": "0.0.2-19-gbe16cca", - "Rev": "be16cca3fa780c77916e52370a9c89cc53bcf73a" + "Comment": "0.0.2-20-gd546567", + "Rev": "d546567abc945ad52d1906fc6c7caa8f903e7445" }, { "ImportPath": "github.com/CenturyLinkCloud/clc-sdk/aa", - "Comment": "0.0.2-19-gbe16cca", - "Rev": "be16cca3fa780c77916e52370a9c89cc53bcf73a" + "Comment": "0.0.2-20-gd546567", + "Rev": "d546567abc945ad52d1906fc6c7caa8f903e7445" }, { "ImportPath": "github.com/CenturyLinkCloud/clc-sdk/alert", - "Comment": "0.0.2-19-gbe16cca", - "Rev": "be16cca3fa780c77916e52370a9c89cc53bcf73a" + "Comment": "0.0.2-20-gd546567", + "Rev": "d546567abc945ad52d1906fc6c7caa8f903e7445" }, { "ImportPath": "github.com/CenturyLinkCloud/clc-sdk/api", - "Comment": "0.0.2-19-gbe16cca", - "Rev": "be16cca3fa780c77916e52370a9c89cc53bcf73a" + "Comment": "0.0.2-20-gd546567", + "Rev": "d546567abc945ad52d1906fc6c7caa8f903e7445" }, { "ImportPath": "github.com/CenturyLinkCloud/clc-sdk/dc", - "Comment": "0.0.2-19-gbe16cca", - "Rev": "be16cca3fa780c77916e52370a9c89cc53bcf73a" + "Comment": "0.0.2-20-gd546567", + "Rev": "d546567abc945ad52d1906fc6c7caa8f903e7445" }, { "ImportPath": "github.com/CenturyLinkCloud/clc-sdk/group", - "Comment": "0.0.2-19-gbe16cca", - "Rev": "be16cca3fa780c77916e52370a9c89cc53bcf73a" + "Comment": "0.0.2-20-gd546567", + "Rev": "d546567abc945ad52d1906fc6c7caa8f903e7445" }, { "ImportPath": "github.com/CenturyLinkCloud/clc-sdk/lb", - "Comment": "0.0.2-19-gbe16cca", - "Rev": "be16cca3fa780c77916e52370a9c89cc53bcf73a" + "Comment": "0.0.2-20-gd546567", + "Rev": "d546567abc945ad52d1906fc6c7caa8f903e7445" }, { "ImportPath": "github.com/CenturyLinkCloud/clc-sdk/server", - "Comment": "0.0.2-19-gbe16cca", - "Rev": "be16cca3fa780c77916e52370a9c89cc53bcf73a" + "Comment": "0.0.2-20-gd546567", + "Rev": "d546567abc945ad52d1906fc6c7caa8f903e7445" }, { "ImportPath": "github.com/CenturyLinkCloud/clc-sdk/status", - "Comment": "0.0.2-19-gbe16cca", - "Rev": "be16cca3fa780c77916e52370a9c89cc53bcf73a" + "Comment": "0.0.2-20-gd546567", + "Rev": "d546567abc945ad52d1906fc6c7caa8f903e7445" }, { "ImportPath": "github.com/DreamItGetIT/statuscake", diff --git a/builtin/providers/clc/provider.go b/builtin/providers/clc/provider.go index 32b1094e7e..0b2c808573 100644 --- a/builtin/providers/clc/provider.go +++ b/builtin/providers/clc/provider.go @@ -30,6 +30,12 @@ func Provider() terraform.ResourceProvider { DefaultFunc: schema.EnvDefaultFunc("CLC_PASSWORD", nil), Description: "Your CLC password", }, + "account": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("CLC_ACCOUNT", ""), + Description: "Account alias override", + }, }, ResourcesMap: map[string]*schema.Resource{ @@ -53,6 +59,10 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { return nil, fmt.Errorf("Failed to create CLC config with provided details: %v", err) } config.UserAgent = fmt.Sprintf("terraform-clc terraform/%s", terraform.Version) + // user requested alias override or sub-account + if al := d.Get("account").(string); al != "" { + config.Alias = al + } client := clc.New(config) if err := client.Authenticate(); err != nil { diff --git a/vendor/github.com/CenturyLinkCloud/clc-sdk/api/api.go b/vendor/github.com/CenturyLinkCloud/clc-sdk/api/api.go index 598609da76..0146179dc1 100644 --- a/vendor/github.com/CenturyLinkCloud/clc-sdk/api/api.go +++ b/vendor/github.com/CenturyLinkCloud/clc-sdk/api/api.go @@ -78,7 +78,7 @@ func (c *Client) Auth() error { } err = c.Do(req, &c.Token) - if err == nil { + if err == nil && c.config.Alias == "" { // set Alias from returned token c.config.Alias = c.Token.Alias } diff --git a/website/source/docs/providers/clc/index.html.markdown b/website/source/docs/providers/clc/index.html.markdown index 4486507e95..f82c0001a5 100644 --- a/website/source/docs/providers/clc/index.html.markdown +++ b/website/source/docs/providers/clc/index.html.markdown @@ -25,7 +25,7 @@ For additional documentation, see the [CLC Developer Center](https://www.ctl.io/ provider "clc" { username = "${var.clc_username}" password = "${var.clc_password}" - account = "${var.clc_account}" + account = "${var.clc_account}" # optional } # Create a server @@ -55,5 +55,5 @@ The following arguments are supported: * `clc_password` - (Required) This is the CLC account password. It must be provided, but it can also be sourced from the `CLC_PASSWORD` environment variable. -* `clc_account` - (Required) This is the CLC account alias. It must be provided, but - it can also be sourced from the `CLC_ACCOUNT` environment variable. +* `clc_account` - (Optional) Override CLC account alias. Also taken from the `CLC_ACCOUNT` + environment variable if provided. diff --git a/website/source/docs/providers/clc/r/load_balancer_pool.html.markdown b/website/source/docs/providers/clc/r/load_balancer_pool.html.markdown index 9cdc6086ca..6a18925bd1 100644 --- a/website/source/docs/providers/clc/r/load_balancer_pool.html.markdown +++ b/website/source/docs/providers/clc/r/load_balancer_pool.html.markdown @@ -29,6 +29,12 @@ resource "clc_load_balancer_pool" "pool" { ipAddress = "${clc_server.node.0.private_ip_address}" privatePort = 3000 } + nodes + { + status = "enabled" + ipAddress = "${clc_server.node.1.private_ip_address}" + privatePort = 3000 + } } output "pool" { diff --git a/website/source/docs/providers/clc/r/server.html.markdown b/website/source/docs/providers/clc/r/server.html.markdown index a3f97ed46a..14918c3d56 100644 --- a/website/source/docs/providers/clc/r/server.html.markdown +++ b/website/source/docs/providers/clc/r/server.html.markdown @@ -67,6 +67,7 @@ The following arguments are supported: One of "standard", "premium" * `additional_disks` - (Optional) See [Disks](#disks) below for details. * `custom_fields` - (Optional) See [CustomFields](#custom_fields) below for details. +* `metadata` - (Optional) Misc state storage for non-CLC metadata.