2015-06-19 18:06:06 -04:00
|
|
|
package shell
|
|
|
|
|
|
|
|
import (
|
2018-02-23 16:26:31 -05:00
|
|
|
sl "github.com/hashicorp/packer/common/shell-local"
|
2017-04-04 16:39:01 -04:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2015-06-19 18:06:06 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type Provisioner struct {
|
2018-02-27 15:50:42 -05:00
|
|
|
config sl.Config
|
2015-06-19 18:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Provisioner) Prepare(raws ...interface{}) error {
|
2018-02-27 15:50:42 -05:00
|
|
|
err := sl.Decode(&p.config, raws)
|
2015-06-19 18:06:06 -04:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-02-27 15:50:42 -05:00
|
|
|
return sl.Validate(&p.config)
|
2015-06-19 18:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Provisioner) Provision(ui packer.Ui, _ packer.Communicator) error {
|
2018-02-28 14:53:53 -05:00
|
|
|
_, retErr := sl.Run(ui, &p.config)
|
|
|
|
if retErr != nil {
|
|
|
|
return retErr
|
2015-06-19 18:06:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Provisioner) Cancel() {
|
|
|
|
// Just do nothing. When the process ends, so will our provisioner
|
|
|
|
}
|