Commit 2ee2850c authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #2353 from mitchellh/b-gce-comm-default

builder/googlecompute: default SSH settings properly [GH-2340]
parents 95f9391f 6c7a7b60
...@@ -97,6 +97,9 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { ...@@ -97,6 +97,9 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
} }
var errs *packer.MultiError var errs *packer.MultiError
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
}
// Process required parameters. // Process required parameters.
if c.ProjectId == "" { if c.ProjectId == "" {
......
...@@ -152,6 +152,35 @@ func TestConfigPrepare(t *testing.T) { ...@@ -152,6 +152,35 @@ func TestConfigPrepare(t *testing.T) {
} }
} }
func TestConfigDefaults(t *testing.T) {
cases := []struct {
Read func(c *Config) interface{}
Value interface{}
}{
{
func(c *Config) interface{} { return c.Comm.Type },
"ssh",
},
{
func(c *Config) interface{} { return c.Comm.SSHPort },
22,
},
}
for _, tc := range cases {
raw := testConfig(t)
c, warns, errs := NewConfig(raw)
testConfigOk(t, warns, errs)
actual := tc.Read(c)
if actual != tc.Value {
t.Fatalf("bad: %#v", actual)
}
}
}
func testAccountFile(t *testing.T) string { func testAccountFile(t *testing.T) string {
tf, err := ioutil.TempFile("", "packer") tf, err := ioutil.TempFile("", "packer")
if err != nil { if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment