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 {
|
||||
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 {
|
||||
ui.Error(restError.Messages[0].Message)
|
||||
} else {
|
||||
|
@ -147,9 +151,11 @@ func (s *stepCreateServer) Cleanup(state multistep.StateBag) {
|
|||
|
||||
if dcId, ok := state.GetOk("datacenter_id"); ok {
|
||||
resp := profitbricks.DeleteDatacenter(dcId.(string))
|
||||
s.checkForErrors(resp)
|
||||
err := s.waitTillProvisioned(resp.Headers.Get("Location"), *c)
|
||||
if err != nil {
|
||||
if err := s.checkForErrors(resp); err != nil {
|
||||
ui.Error(fmt.Sprintf(
|
||||
"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(
|
||||
"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 {
|
||||
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 {
|
||||
ui.Error(restError.Messages[0].Message)
|
||||
} 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)
|
||||
}
|
||||
|
||||
ec2conn.DeregisterImage(&ec2.DeregisterImageInput{
|
||||
_, err = ec2conn.DeregisterImage(&ec2.DeregisterImageInput{
|
||||
ImageId: &createdami,
|
||||
})
|
||||
|
||||
|
|
|
@ -355,7 +355,9 @@ func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator, pri
|
|||
go repeat(stderr)
|
||||
|
||||
log.Printf("Executing Ansible: %s", strings.Join(cmd.Args, " "))
|
||||
cmd.Start()
|
||||
if err := cmd.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
wg.Wait()
|
||||
err = cmd.Wait()
|
||||
if err != nil {
|
||||
|
|
|
@ -104,8 +104,7 @@ func (state *scpDownloadState) FileProtocol(path string, info os.FileInfo, in *b
|
|||
size := info.Size()
|
||||
perms := fmt.Sprintf("C%04o", info.Mode().Perm())
|
||||
fmt.Fprintln(out, perms, size, info.Name())
|
||||
err := scpResponse(in)
|
||||
if err != nil {
|
||||
if err := scpResponse(in); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -194,8 +193,7 @@ func (state *scpUploadState) FileProtocol(in *bufio.Reader, out io.Writer) error
|
|||
return err
|
||||
}
|
||||
|
||||
err = scpResponse(in)
|
||||
if err != nil {
|
||||
if err := scpResponse(in); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -260,7 +258,9 @@ type scpDownloadState struct {
|
|||
func (state *scpDownloadState) Protocol(in *bufio.Reader, out io.Writer) error {
|
||||
r := bufio.NewReader(in)
|
||||
// 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 {
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue