more fixes from errcheck
This commit is contained in:
parent
048e316645
commit
6f27f67346
|
@ -72,7 +72,11 @@ func (s *stepCreateServer) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
if datacenter.StatusCode > 299 {
|
if datacenter.StatusCode > 299 {
|
||||||
if datacenter.StatusCode > 299 {
|
if datacenter.StatusCode > 299 {
|
||||||
var restError RestError
|
var restError RestError
|
||||||
json.Unmarshal([]byte(datacenter.Response), &restError)
|
err := json.Unmarshal([]byte(datacenter.Response), &restError)
|
||||||
|
if err != nil {
|
||||||
|
ui.Error(fmt.Sprintf("Error decoding json response: %s", err.Error()))
|
||||||
|
return multistep.ActionHalt
|
||||||
|
}
|
||||||
if len(restError.Messages) > 0 {
|
if len(restError.Messages) > 0 {
|
||||||
ui.Error(restError.Messages[0].Message)
|
ui.Error(restError.Messages[0].Message)
|
||||||
} else {
|
} else {
|
||||||
|
@ -147,9 +151,11 @@ func (s *stepCreateServer) Cleanup(state multistep.StateBag) {
|
||||||
|
|
||||||
if dcId, ok := state.GetOk("datacenter_id"); ok {
|
if dcId, ok := state.GetOk("datacenter_id"); ok {
|
||||||
resp := profitbricks.DeleteDatacenter(dcId.(string))
|
resp := profitbricks.DeleteDatacenter(dcId.(string))
|
||||||
s.checkForErrors(resp)
|
if err := s.checkForErrors(resp); err != nil {
|
||||||
err := s.waitTillProvisioned(resp.Headers.Get("Location"), *c)
|
ui.Error(fmt.Sprintf(
|
||||||
if err != nil {
|
"Error deleting Virtual Data Center. Please destroy it manually: %s", err))
|
||||||
|
}
|
||||||
|
if err := s.waitTillProvisioned(resp.Headers.Get("Location"), *c); err != nil {
|
||||||
ui.Error(fmt.Sprintf(
|
ui.Error(fmt.Sprintf(
|
||||||
"Error deleting Virtual Data Center. Please destroy it manually: %s", err))
|
"Error deleting Virtual Data Center. Please destroy it manually: %s", err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,10 @@ func (s *stepTakeSnapshot) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
|
|
||||||
if snapshot.StatusCode > 299 {
|
if snapshot.StatusCode > 299 {
|
||||||
var restError RestError
|
var restError RestError
|
||||||
json.Unmarshal([]byte(snapshot.Response), &restError)
|
if err := json.Unmarshal([]byte(snapshot.Response), &restError); err != nil {
|
||||||
|
ui.Error(err.Error())
|
||||||
|
return multistep.ActionHalt
|
||||||
|
}
|
||||||
if len(restError.Messages) > 0 {
|
if len(restError.Messages) > 0 {
|
||||||
ui.Error(restError.Messages[0].Message)
|
ui.Error(restError.Messages[0].Message)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -239,7 +239,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
|
||||||
return nil, false, fmt.Errorf("Error waiting for AMI (%s): %s", *resp.ImageId, err)
|
return nil, false, fmt.Errorf("Error waiting for AMI (%s): %s", *resp.ImageId, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ec2conn.DeregisterImage(&ec2.DeregisterImageInput{
|
_, err = ec2conn.DeregisterImage(&ec2.DeregisterImageInput{
|
||||||
ImageId: &createdami,
|
ImageId: &createdami,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,9 @@ func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator, pri
|
||||||
go repeat(stderr)
|
go repeat(stderr)
|
||||||
|
|
||||||
log.Printf("Executing Ansible: %s", strings.Join(cmd.Args, " "))
|
log.Printf("Executing Ansible: %s", strings.Join(cmd.Args, " "))
|
||||||
cmd.Start()
|
if err := cmd.Start(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
err = cmd.Wait()
|
err = cmd.Wait()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -104,8 +104,7 @@ func (state *scpDownloadState) FileProtocol(path string, info os.FileInfo, in *b
|
||||||
size := info.Size()
|
size := info.Size()
|
||||||
perms := fmt.Sprintf("C%04o", info.Mode().Perm())
|
perms := fmt.Sprintf("C%04o", info.Mode().Perm())
|
||||||
fmt.Fprintln(out, perms, size, info.Name())
|
fmt.Fprintln(out, perms, size, info.Name())
|
||||||
err := scpResponse(in)
|
if err := scpResponse(in); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,8 +193,7 @@ func (state *scpUploadState) FileProtocol(in *bufio.Reader, out io.Writer) error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = scpResponse(in)
|
if err := scpResponse(in); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +258,9 @@ type scpDownloadState struct {
|
||||||
func (state *scpDownloadState) Protocol(in *bufio.Reader, out io.Writer) error {
|
func (state *scpDownloadState) Protocol(in *bufio.Reader, out io.Writer) error {
|
||||||
r := bufio.NewReader(in)
|
r := bufio.NewReader(in)
|
||||||
// read the byte sent by the other side to start the transfer
|
// read the byte sent by the other side to start the transfer
|
||||||
scpResponse(r)
|
if err := scpResponse(r); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return filepath.Walk(state.srcRoot, func(path string, info os.FileInfo, err error) error {
|
return filepath.Walk(state.srcRoot, func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue