|
|
|
|
@ -31,26 +31,30 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|
|
|
|
if es := c.CommConfig.Prepare(nil); len(es) > 0 {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, es...)
|
|
|
|
|
}
|
|
|
|
|
if c.CommConfig.Host() == "" {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs,
|
|
|
|
|
fmt.Errorf("a Host must be specified, please reference your communicator documentation"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.CommConfig.User() == "" {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs,
|
|
|
|
|
fmt.Errorf("a Username must be specified, please reference your communicator documentation"))
|
|
|
|
|
}
|
|
|
|
|
if c.CommConfig.Type != "none" {
|
|
|
|
|
if c.CommConfig.Host() == "" {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs,
|
|
|
|
|
fmt.Errorf("a Host must be specified, please reference your communicator documentation"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !c.CommConfig.SSHAgentAuth && c.CommConfig.Password() == "" && c.CommConfig.SSHPrivateKey == "" {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs,
|
|
|
|
|
fmt.Errorf("one authentication method must be specified, please reference your communicator documentation"))
|
|
|
|
|
}
|
|
|
|
|
if c.CommConfig.User() == "" {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs,
|
|
|
|
|
fmt.Errorf("a Username must be specified, please reference your communicator documentation"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !c.CommConfig.SSHAgentAuth && c.CommConfig.Password() == "" && c.CommConfig.SSHPrivateKey == "" {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs,
|
|
|
|
|
fmt.Errorf("one authentication method must be specified, please reference your communicator documentation"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (c.CommConfig.SSHAgentAuth &&
|
|
|
|
|
(c.CommConfig.SSHPassword != "" || c.CommConfig.SSHPrivateKey != "")) ||
|
|
|
|
|
(c.CommConfig.SSHPassword != "" && c.CommConfig.SSHPrivateKey != "") {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs,
|
|
|
|
|
fmt.Errorf("only one of ssh_agent_auth, ssh_password, and ssh_private_key_file must be specified"))
|
|
|
|
|
|
|
|
|
|
if (c.CommConfig.SSHAgentAuth &&
|
|
|
|
|
(c.CommConfig.SSHPassword != "" || c.CommConfig.SSHPrivateKey != "")) ||
|
|
|
|
|
(c.CommConfig.SSHPassword != "" && c.CommConfig.SSHPrivateKey != "") {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs,
|
|
|
|
|
fmt.Errorf("only one of ssh_agent_auth, ssh_password, and ssh_private_key_file must be specified"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if errs != nil && len(errs.Errors) > 0 {
|
|
|
|
|
|