fix: condensed and simplified os check logic and added validate output
This commit is contained in:
parent
d408c9e69c
commit
23ad90f2c4
|
@ -175,7 +175,8 @@ func Validate(config *Config) error {
|
|||
}
|
||||
}
|
||||
if supported_os != true {
|
||||
return fmt.Errorf("Invalid OS specified in only_on: '%s'", provided_os)
|
||||
return fmt.Errorf("Invalid OS specified in only_on: '%s'\n"+
|
||||
"Supported OS names: %v", provided_os, supported_syslist)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,21 +29,19 @@ type EnvVarsTemplate struct {
|
|||
|
||||
func Run(ui packer.Ui, config *Config) (bool, error) {
|
||||
// Check if shell-local can even execute against this runtime OS
|
||||
runCommand := false
|
||||
if len(config.OnlyOn) > 0 {
|
||||
runCommand := false
|
||||
for _, os := range config.OnlyOn {
|
||||
if os == runtime.GOOS {
|
||||
runCommand = true
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
runCommand = true
|
||||
}
|
||||
if !runCommand {
|
||||
ui.Say(fmt.Sprintf("Skipping shell-local due to runtime OS"))
|
||||
log.Printf("[INFO] (shell-local): skipping shell-local due to missing runtime OS")
|
||||
return true, nil
|
||||
if !runCommand {
|
||||
ui.Say(fmt.Sprintf("Skipping shell-local due to runtime OS"))
|
||||
log.Printf("[INFO] (shell-local): skipping shell-local due to missing runtime OS")
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
scripts := make([]string, len(config.Scripts))
|
||||
|
|
Loading…
Reference in New Issue