From dbaf4d3f2a8dbb2fcefbb9dd322e7b9afeaacdb1 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 4 Dec 2014 18:48:48 -0800 Subject: [PATCH] remote: Standardize config names --- remote/atlas.go | 2 +- remote/consul.go | 2 +- remote/http.go | 4 ++-- remote/http_test.go | 12 ++++++------ remote/remote_test.go | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/remote/atlas.go b/remote/atlas.go index c59f4944d..2966dea12 100644 --- a/remote/atlas.go +++ b/remote/atlas.go @@ -36,7 +36,7 @@ func NewAtlasRemoteClient(conf map[string]string) (*AtlasRemoteClient, error) { } func (c *AtlasRemoteClient) validateConfig(conf map[string]string) error { - server, ok := conf["server"] + server, ok := conf["address"] if !ok || server == "" { server = defaultAtlasServer } diff --git a/remote/consul.go b/remote/consul.go index bbd51c4a4..0928935a9 100644 --- a/remote/consul.go +++ b/remote/consul.go @@ -24,7 +24,7 @@ func NewConsulRemoteClient(conf map[string]string) (*ConsulRemoteClient, error) func (c *ConsulRemoteClient) validateConfig(conf map[string]string) (err error) { config := consulapi.DefaultConfig() - if token, ok := conf["token"]; ok && token != "" { + if token, ok := conf["access_token"]; ok && token != "" { config.Token = token } if addr, ok := conf["address"]; ok && addr != "" { diff --git a/remote/http.go b/remote/http.go index e352cb8ad..75425baf3 100644 --- a/remote/http.go +++ b/remote/http.go @@ -26,9 +26,9 @@ func NewHTTPRemoteClient(conf map[string]string) (*HTTPRemoteClient, error) { } func (c *HTTPRemoteClient) validateConfig(conf map[string]string) error { - urlRaw, ok := conf["url"] + urlRaw, ok := conf["address"] if !ok || urlRaw == "" { - return fmt.Errorf("missing 'url' configuration") + return fmt.Errorf("missing 'address' configuration") } url, err := url.Parse(urlRaw) if err != nil { diff --git a/remote/http_test.go b/remote/http_test.go index 6c1ad2caf..3ad70d45c 100644 --- a/remote/http_test.go +++ b/remote/http_test.go @@ -25,17 +25,17 @@ func TestHTTPRemote_Validate(t *testing.T) { t.Fatalf("expect error") } - conf["url"] = "" + conf["address"] = "" if _, err := NewHTTPRemoteClient(conf); err == nil { t.Fatalf("expect error") } - conf["url"] = "*" + conf["address"] = "*" if _, err := NewHTTPRemoteClient(conf); err == nil { t.Fatalf("expect error") } - conf["url"] = "http://cool.com" + conf["address"] = "http://cool.com" if _, err := NewHTTPRemoteClient(conf); err != nil { t.Fatalf("err: %v", err) } @@ -90,7 +90,7 @@ func TestHTTPRemote_GetState(t *testing.T) { remote := &terraform.RemoteState{ Type: "http", Config: map[string]string{ - "url": s.URL, + "address": s.URL, }, } r, err := NewClientByState(remote) @@ -231,7 +231,7 @@ func TestHTTPRemote_PutState(t *testing.T) { remote := &terraform.RemoteState{ Type: "http", Config: map[string]string{ - "url": s.URL + "/foobar", + "address": s.URL + "/foobar", }, } r, err := NewClientByState(remote) @@ -311,7 +311,7 @@ func TestHTTPRemote_DeleteState(t *testing.T) { remote := &terraform.RemoteState{ Type: "http", Config: map[string]string{ - "url": s.URL + "/foobar", + "address": s.URL + "/foobar", }, } r, err := NewClientByState(remote) diff --git a/remote/remote_test.go b/remote/remote_test.go index 3b617fe62..c6e076594 100644 --- a/remote/remote_test.go +++ b/remote/remote_test.go @@ -306,7 +306,7 @@ func TestBlankState(t *testing.T) { remote := &terraform.RemoteState{ Type: "http", Config: map[string]string{ - "url": "http://foo.com/", + "address": "http://foo.com/", }, } r, err := blankState(remote) @@ -335,7 +335,7 @@ func TestPersist(t *testing.T) { remote := &terraform.RemoteState{ Type: "http", Config: map[string]string{ - "url": "http://foo.com/", + "address": "http://foo.com/", }, } blank, _ := blankState(remote) @@ -396,7 +396,7 @@ func testRemote(t *testing.T, s *terraform.State) (*terraform.RemoteState, *http remote := &terraform.RemoteState{ Type: "http", Config: map[string]string{ - "url": srv.URL, + "address": srv.URL, }, } return remote, srv @@ -412,7 +412,7 @@ func testRemotePush(t *testing.T, c int) (*terraform.RemoteState, *httptest.Serv remote := &terraform.RemoteState{ Type: "http", Config: map[string]string{ - "url": srv.URL, + "address": srv.URL, }, } return remote, srv