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
}
diff --git a/automation/state.go b/automation/state.go
index 23b5193..567897e 100644
--- a/automation/state.go
+++ b/automation/state.go
@@ -160,9 +160,11 @@
updateNodeName(client, node, options)
}
- options.Provisioner.Clear(node.ID())
-
- return nil
+ err := options.Provisioner.Clear(node.ID())
+ if err != nil {
+ log.Errorf("Attempting to clear provisioning state of node '%s' : %s", node.ID(), err)
+ }
+ return err
}
// Provision we are at the target state, nothing to do