From 60081c323a2e546717199ca12c83209eb375a6f7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 13 Jun 2015 17:51:27 -0400 Subject: [PATCH] helper/communicator: ssh settings aren't required if type is none --- helper/communicator/config.go | 6 ++++-- helper/communicator/config_test.go | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/helper/communicator/config.go b/helper/communicator/config.go index 28d1d3a43..a2719db13 100644 --- a/helper/communicator/config.go +++ b/helper/communicator/config.go @@ -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 diff --git a/helper/communicator/config_test.go b/helper/communicator/config_test.go index f57fb68ca..029c9fe35 100644 --- a/helper/communicator/config_test.go +++ b/helper/communicator/config_test.go @@ -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 }