Rename configuration `avoid_sudo` to `prevent_sudo`

This commit is contained in:
James Van Dyke 2013-07-06 00:37:59 -04:00
parent 3416f0760c
commit 69f0049a44
1 changed files with 9 additions and 9 deletions

View File

@ -38,7 +38,7 @@ type config struct {
Json map[string]interface{} Json map[string]interface{}
// Option to avoid sudo use when executing commands. Defaults to false. // Option to avoid sudo use when executing commands. Defaults to false.
AvoidSudo bool `mapstructure:"avoid_sudo"` PreventSudo bool `mapstructure:"prevent_sudo"`
// If true, skips installing Chef. Defaults to false. // If true, skips installing Chef. Defaults to false.
SkipInstall bool `mapstructure:"skip_install"` SkipInstall bool `mapstructure:"skip_install"`
@ -51,11 +51,11 @@ type Provisioner struct {
type ExecuteRecipeTemplate struct { type ExecuteRecipeTemplate struct {
SoloRbPath string SoloRbPath string
JsonPath string JsonPath string
UseSudo bool Sudo bool
} }
type ExecuteInstallChefTemplate struct { type ExecuteInstallChefTemplate struct {
AvoidSudo bool PreventSudo bool
} }
func (p *Provisioner) Prepare(raws ...interface{}) error { func (p *Provisioner) Prepare(raws ...interface{}) error {
@ -105,7 +105,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
Ui = ui Ui = ui
if !p.config.SkipInstall { if !p.config.SkipInstall {
err = InstallChefSolo(p.config.AvoidSudo, comm) err = InstallChefSolo(p.config.PreventSudo, comm)
if err != nil { if err != nil {
return fmt.Errorf("Error installing Chef Solo: %s", err) return fmt.Errorf("Error installing Chef Solo: %s", err)
} }
@ -140,8 +140,8 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
// Compile the command // Compile the command
var command bytes.Buffer var command bytes.Buffer
t := template.Must(template.New("chef-run").Parse("{{if .UseSudo}}sudo {{end}}chef-solo --no-color -c {{.SoloRbPath}} -j {{.JsonPath}}")) t := template.Must(template.New("chef-run").Parse("{{if .Sudo}}sudo {{end}}chef-solo --no-color -c {{.SoloRbPath}} -j {{.JsonPath}}"))
t.Execute(&command, &ExecuteRecipeTemplate{soloRbPath, jsonPath, !p.config.AvoidSudo}) t.Execute(&command, &ExecuteRecipeTemplate{soloRbPath, jsonPath, !p.config.PreventSudo})
err = executeCommand(command.String(), comm) err = executeCommand(command.String(), comm)
if err != nil { if err != nil {
@ -298,12 +298,12 @@ func CreateAttributesJson(jsonAttrs map[string]interface{}, recipes []string, co
return remotePath, nil return remotePath, nil
} }
func InstallChefSolo(avoidSudo bool, comm packer.Communicator) (err error) { func InstallChefSolo(preventSudo bool, comm packer.Communicator) (err error) {
Ui.Say(fmt.Sprintf("Installing Chef Solo")) Ui.Say(fmt.Sprintf("Installing Chef Solo"))
var command bytes.Buffer var command bytes.Buffer
t := template.Must(template.New("install-chef").Parse("curl -L https://www.opscode.com/chef/install.sh | {{if .UseSudo}}sudo {{end}}bash")) t := template.Must(template.New("install-chef").Parse("curl -L https://www.opscode.com/chef/install.sh | {{if .sudo}}sudo {{end}}bash"))
t.Execute(&command, map[string]bool{"UseSudo": !avoidSudo}) t.Execute(&command, map[string]bool{"sudo": !preventSudo})
err = executeCommand(command.String(), comm) err = executeCommand(command.String(), comm)
if err != nil { if err != nil {