From ba0f80275fa0d60b31a6f0093420ee503fa12193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 28 Mar 2017 11:18:03 +0200 Subject: [PATCH] Rancher: error when no api_url is provided (#13086) --- builtin/providers/rancher/provider.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builtin/providers/rancher/provider.go b/builtin/providers/rancher/provider.go index 9c176943f..8df36778d 100644 --- a/builtin/providers/rancher/provider.go +++ b/builtin/providers/rancher/provider.go @@ -2,6 +2,7 @@ package rancher import ( "encoding/json" + "fmt" "io/ioutil" "net/url" "os" @@ -87,7 +88,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { return config, err } - if apiURL == "" { + if apiURL == "" && config.URL != "" { u, err := url.Parse(config.URL) if err != nil { return config, err @@ -104,6 +105,10 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { } } + if apiURL == "" { + return &Config{}, fmt.Errorf("No api_url provided") + } + config := &Config{ APIURL: apiURL + "/v1", AccessKey: accessKey,