provisioner(converge): handle http error

This commit is contained in:
Brian Hicks 2016-12-27 14:58:41 -06:00
parent b46a402a18
commit 549ff50a3c
No known key found for this signature in database
GPG Key ID: FF1F407C0D3C2430
1 changed files with 3 additions and 1 deletions

View File

@ -137,13 +137,15 @@ func (p *Provisioner) maybeBootstrap(ui packer.Ui, comm packer.Communicator) err
ui.Message("bootstrapping converge")
bootstrap, err := http.Get("https://get.converge.sh")
defer bootstrap.Body.Close()
if err != nil {
return fmt.Errorf("Error downloading bootstrap script: %s", err) // TODO: is github.com/pkg/error allowed?
}
if err := comm.Upload("/tmp/install-converge.sh", bootstrap.Body, nil); err != nil {
return fmt.Errorf("Error uploading script: %s", err)
}
if err := bootstrap.Body.Close(); err != nil {
return fmt.Errorf("Error getting bootstrap script: %s", err)
}
// construct command
command := "/bin/sh /tmp/install-converge.sh"