helper/communicator: ssh settings aren't required if type is none

This commit is contained in:
Mitchell Hashimoto 2015-06-13 17:51:27 -04:00
parent 4b4fe2280d
commit 60081c323a
2 changed files with 11 additions and 2 deletions

View File

@ -35,8 +35,10 @@ func (c *Config) Prepare(ctx *interpolate.Context) []error {
// Validation
var errs []error
if c.SSHUsername == "" {
errs = append(errs, errors.New("An ssh_username must be specified"))
if c.Type == "ssh" {
if c.SSHUsername == "" {
errs = append(errs, errors.New("An ssh_username must be specified"))
}
}
return errs

View File

@ -23,6 +23,13 @@ func TestConfigType(t *testing.T) {
}
}
func TestConfig_none(t *testing.T) {
c := &Config{Type: "none"}
if err := c.Prepare(testContext(t)); len(err) > 0 {
t.Fatalf("bad: %#v", err)
}
}
func testContext(t *testing.T) *interpolate.Context {
return nil
}