update to propertly construct URL
Change-Id: I67a09d94d92fa8595c3ceed7bf598c6f6056bb56
diff --git a/automation/provisioner_api.go b/automation/provisioner_api.go
index 1f71d22..2f2fd26 100644
--- a/automation/provisioner_api.go
+++ b/automation/provisioner_api.go
@@ -18,6 +18,7 @@
"encoding/json"
"fmt"
"net/http"
+ "strings"
)
type ProvisionStatus int
@@ -65,12 +66,19 @@
Url string
}
+func buildUrl(base string, id string) string {
+ if strings.HasSuffix(base, "/") {
+ return base + id
+ }
+ return base + "/" + id
+}
+
func NewProvisioner(config *ProvisionerConfig) Provisioner {
return config
}
func (p *ProvisionerConfig) Get(id string) (*ProvisionRecord, error) {
- resp, err := http.Get(p.Url + "/" + id)
+ resp, err := http.Get(buildUrl(p.Url, id))
if err != nil {
return nil, err
}
@@ -117,7 +125,7 @@
func (p *ProvisionerConfig) Clear(id string) error {
hc := http.Client{}
- req, err := http.NewRequest("DELETE", p.Url+"/"+id, nil)
+ req, err := http.NewRequest("DELETE", buildUrl(p.Url, id), nil)
if err != nil {
return err
}