Addressing PR remarks
This commit is contained in:
parent
325401eaf0
commit
2008c6019a
@ -1,6 +1,7 @@
|
|||||||
package profitbricks
|
package profitbricks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
@ -62,7 +63,7 @@ func (s *stepCreateServer) Run(state multistep.StateBag) multistep.StepAction {
|
|||||||
|
|
||||||
datacenter = profitbricks.CompositeCreateDatacenter(datacenter)
|
datacenter = profitbricks.CompositeCreateDatacenter(datacenter)
|
||||||
if datacenter.StatusCode > 299 {
|
if datacenter.StatusCode > 299 {
|
||||||
ui.Error(datacenter.Response)
|
ui.Error(parseErrorMessage(datacenter.Response))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
s.waitTillProvisioned(datacenter.Headers.Get("Location"), *c)
|
s.waitTillProvisioned(datacenter.Headers.Get("Location"), *c)
|
||||||
@ -77,7 +78,7 @@ func (s *stepCreateServer) Run(state multistep.StateBag) multistep.StepAction {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if lan.StatusCode > 299 {
|
if lan.StatusCode > 299 {
|
||||||
ui.Error(fmt.Sprintf("Error occured %s", lan.Response))
|
ui.Error(fmt.Sprintf("Error occured %s", parseErrorMessage(lan.Response)))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ func (s *stepCreateServer) Run(state multistep.StateBag) multistep.StepAction {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if lan.StatusCode > 299 {
|
if lan.StatusCode > 299 {
|
||||||
ui.Error(fmt.Sprintf("Error occured %s", nic.Response))
|
ui.Error(fmt.Sprintf("Error occured %s", parseErrorMessage(nic.Response)))
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,3 +181,17 @@ func (d *stepCreateServer) getImageId(imageName string, c *Config) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseErrorMessage(raw string) (toreturn string) {
|
||||||
|
var tmp map[string]interface{}
|
||||||
|
json.Unmarshal([]byte(raw), &tmp)
|
||||||
|
|
||||||
|
for _, v := range tmp["messages"].([]interface{}) {
|
||||||
|
for index, i := range v.(map[string]interface{}) {
|
||||||
|
if index == "message" {
|
||||||
|
toreturn = toreturn + i.(string) + "\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return toreturn
|
||||||
|
}
|
||||||
|
@ -25,7 +25,7 @@ builder.
|
|||||||
|
|
||||||
### Required
|
### Required
|
||||||
|
|
||||||
- `image` (string) - ProfitBricks volume image
|
- `image` (string) - ProfitBricks volume image. Only Linux public images are supported. Defaults to "Ubuntu-16.04". To obtain full list of available images you can use [ProfitBricks CLI](https://github.com/profitbricks/profitbricks-cli#image).
|
||||||
|
|
||||||
- `password` (string) - ProfitBrucks password. This can be specified via environment variable `PROFITBRICKS_PASSWORD', if provided. The value definded in the config has precedence over environemnt variable.
|
- `password` (string) - ProfitBrucks password. This can be specified via environment variable `PROFITBRICKS_PASSWORD', if provided. The value definded in the config has precedence over environemnt variable.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user