builder/googlecompute: fix image name defaults

This commit is contained in:
Ryan Uber 2016-01-19 11:12:19 -08:00
parent 76c49f6ed0
commit 7732cf45a0
2 changed files with 4 additions and 0 deletions

View File

@ -81,6 +81,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
if err != nil { if err != nil {
errs = packer.MultiErrorAppend(errs, errs = packer.MultiErrorAppend(errs,
fmt.Errorf("Unable to parse image name: %s ", err)) fmt.Errorf("Unable to parse image name: %s ", err))
} else {
c.ImageName = img c.ImageName = img
} }
} }

View File

@ -160,6 +160,9 @@ func TestConfigDefaults(t *testing.T) {
func TestImageName(t *testing.T) { func TestImageName(t *testing.T) {
c, _, _ := NewConfig(testConfig(t)) c, _, _ := NewConfig(testConfig(t))
if !strings.HasPrefix(c.ImageName, "packer-") {
t.Fatalf("ImageName should have 'packer-' prefix, found %s", c.ImageName)
}
if strings.Contains(c.ImageName, "{{timestamp}}") { if strings.Contains(c.ImageName, "{{timestamp}}") {
t.Errorf("ImageName should be interpolated; found %s", c.ImageName) t.Errorf("ImageName should be interpolated; found %s", c.ImageName)
} }