only sets default value for chef license when installing chef and the install command is not set

pull/7653/head
Aaron Walker 7 years ago
parent dfc5e5cf94
commit 85b8a654b0

@ -196,8 +196,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
errs, fmt.Errorf("server_url must be set"))
}
if p.config.ChefLicense == "" {
p.config.ChefLicense = "accept-silent"
if p.config.SkipInstall == false && p.config.InstallCommand == p.guestOSTypeConfig.installCommand {
if p.config.ChefLicense == "" {
p.config.ChefLicense = "accept-silent"
}
}
if p.config.EncryptedDataBagSecretPath != "" {

@ -164,6 +164,32 @@ func TestProvisionerPrepare_chefLicense(t *testing.T) {
if p.config.ChefLicense != "accept" {
t.Fatalf("unexpected: %#v", p.config.ChefLicense)
}
// Test set skipInstall true
config = testConfig()
config["skip_install"] = true
p = Provisioner{}
err = p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
if p.config.ChefLicense != "" {
t.Fatalf("unexpected: %#v", "empty string")
}
// Test set installCommand true
config = testConfig()
config["install_command"] = "install chef"
p = Provisioner{}
err = p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
if p.config.ChefLicense != "" {
t.Fatalf("unexpected: %#v", "empty string")
}
}
func TestProvisionerPrepare_encryptedDataBagSecretPath(t *testing.T) {

@ -146,8 +146,10 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
p.config.StagingDir = p.guestOSTypeConfig.stagingDir
}
if p.config.ChefLicense == "" {
p.config.ChefLicense = "accept-silent"
if p.config.SkipInstall == false && p.config.InstallCommand == p.guestOSTypeConfig.installCommand {
if p.config.ChefLicense == "" {
p.config.ChefLicense = "accept-silent"
}
}
var errs *packer.MultiError

@ -61,6 +61,32 @@ func TestProvisionerPrepare_chefLicense(t *testing.T) {
if p.config.ChefLicense != "accept" {
t.Fatalf("unexpected: %#v", p.config.ChefLicense)
}
// Test set skipInstall true
config = testConfig()
config["skip_install"] = true
p = Provisioner{}
err = p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
if p.config.ChefLicense != "" {
t.Fatalf("unexpected: %#v", "empty string")
}
// Test set installCommand true
config = testConfig()
config["install_command"] = "install chef"
p = Provisioner{}
err = p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
if p.config.ChefLicense != "" {
t.Fatalf("unexpected: %#v", "empty string")
}
}
func TestProvisionerPrepare_configTemplate(t *testing.T) {

Loading…
Cancel
Save