From 6d6b3e1ac2ae03546269744d788f5e631fb0f810 Mon Sep 17 00:00:00 2001 From: Samit Pal Date: Mon, 6 Jul 2015 09:32:08 +0000 Subject: [PATCH] The default image name in the code has a bug. It is being set to packer-{{timestamp}}, the {{timestamp}} part needs to be interpolated. Without the interpolation the GCE builder fails with the following error ==> googlecompute: Creating image... ==> googlecompute: Error waiting for image: googleapi: Error 400: Invalid value for field 'resource.name': 'packer-{{timestamp}}'. Must be a match of regex '(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)', invalid --- builder/googlecompute/config.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/builder/googlecompute/config.go b/builder/googlecompute/config.go index eebea011f..dc049aa1c 100644 --- a/builder/googlecompute/config.go +++ b/builder/googlecompute/config.go @@ -73,7 +73,13 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { } if c.ImageName == "" { - c.ImageName = "packer-{{timestamp}}" + img, err := interpolate.Render("packer-{{timestamp}}", nil) + if err != nil { + panic(err) + } + + // Default to packer-{{ unix timestamp (utc) }} + c.ImageName = img } if c.InstanceName == "" {