diff --git a/builder/googlecompute/config.go b/builder/googlecompute/config.go index 4603f2769..eebea011f 100644 --- a/builder/googlecompute/config.go +++ b/builder/googlecompute/config.go @@ -97,6 +97,9 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { } var errs *packer.MultiError + if es := c.Comm.Prepare(&c.ctx); len(es) > 0 { + errs = packer.MultiErrorAppend(errs, es...) + } // Process required parameters. if c.ProjectId == "" { diff --git a/builder/googlecompute/config_test.go b/builder/googlecompute/config_test.go index c28c35a0f..93997912e 100644 --- a/builder/googlecompute/config_test.go +++ b/builder/googlecompute/config_test.go @@ -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 { tf, err := ioutil.TempFile("", "packer") if err != nil {