Skip to content

Commit ba0f802

Browse files
raphinkstack72
authored andcommitted
Rancher: error when no api_url is provided (hashicorp#13086)
1 parent ea71adb commit ba0f802

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

builtin/providers/rancher/provider.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package rancher
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"io/ioutil"
67
"net/url"
78
"os"
@@ -87,7 +88,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
8788
return config, err
8889
}
8990

90-
if apiURL == "" {
91+
if apiURL == "" && config.URL != "" {
9192
u, err := url.Parse(config.URL)
9293
if err != nil {
9394
return config, err
@@ -104,6 +105,10 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
104105
}
105106
}
106107

108+
if apiURL == "" {
109+
return &Config{}, fmt.Errorf("No api_url provided")
110+
}
111+
107112
config := &Config{
108113
APIURL: apiURL + "/v1",
109114
AccessKey: accessKey,

0 commit comments

Comments
 (0)