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 {
|
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) {
|
func Run(ui packer.Ui, config *Config) (bool, error) {
|
||||||
// Check if shell-local can even execute against this runtime OS
|
// Check if shell-local can even execute against this runtime OS
|
||||||
runCommand := false
|
|
||||||
if len(config.OnlyOn) > 0 {
|
if len(config.OnlyOn) > 0 {
|
||||||
|
runCommand := false
|
||||||
for _, os := range config.OnlyOn {
|
for _, os := range config.OnlyOn {
|
||||||
if os == runtime.GOOS {
|
if os == runtime.GOOS {
|
||||||
runCommand = true
|
runCommand = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if !runCommand {
|
||||||
runCommand = true
|
ui.Say(fmt.Sprintf("Skipping shell-local due to runtime OS"))
|
||||||
}
|
log.Printf("[INFO] (shell-local): skipping shell-local due to missing runtime OS")
|
||||||
if !runCommand {
|
return true, nil
|
||||||
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))
|
scripts := make([]string, len(config.Scripts))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user