From 0d973145f5111b9a5e7547c01ced33433be70be4 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Wed, 26 Aug 2015 12:00:13 -0700 Subject: [PATCH 1/2] Added a note to the push docs about dot being disallowed in atlas names --- website/source/docs/templates/push.html.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/source/docs/templates/push.html.markdown b/website/source/docs/templates/push.html.markdown index b46bef3e8..efc6029cb 100644 --- a/website/source/docs/templates/push.html.markdown +++ b/website/source/docs/templates/push.html.markdown @@ -38,7 +38,8 @@ each category, the available configuration keys are alphabetized. ### Required - `name` (string) - Name of the build configuration in the build service. If - this doesn't exist, it will be created (by default). + this doesn't exist, it will be created (by default). Note that the name can + cannot contain dots. `[a-zA-Z0-9-_]+` are safe. ### Optional From c834a00e22385681b48c3b1126f189c63000bffd Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Wed, 26 Aug 2015 12:16:18 -0700 Subject: [PATCH 2/2] Added a name validator to the push command --- command/push.go | 11 +++++++++++ website/source/docs/templates/push.html.markdown | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/command/push.go b/command/push.go index f888186de..dac5aa180 100644 --- a/command/push.go +++ b/command/push.go @@ -6,6 +6,7 @@ import ( "os" "os/signal" "path/filepath" + "regexp" "strings" "github.com/hashicorp/atlas-go/archive" @@ -16,6 +17,11 @@ import ( // archiveTemplateEntry is the name the template always takes within the slug. const archiveTemplateEntry = ".packer-template" +var ( + reName = regexp.MustCompile("^[a-zA-Z0-9-_/]+$") + errInvalidName = fmt.Errorf("Your build name can only contain these characters: [a-zA-Z0-9-_]+") +) + type PushCommand struct { Meta @@ -88,6 +94,11 @@ func (c *PushCommand) Run(args []string) int { return 1 } + if !reName.MatchString(name) { + c.Ui.Error(errInvalidName.Error()) + return 1 + } + // Determine our token if token == "" { token = push.Token diff --git a/website/source/docs/templates/push.html.markdown b/website/source/docs/templates/push.html.markdown index efc6029cb..1e7d06ac5 100644 --- a/website/source/docs/templates/push.html.markdown +++ b/website/source/docs/templates/push.html.markdown @@ -39,7 +39,7 @@ each category, the available configuration keys are alphabetized. - `name` (string) - Name of the build configuration in the build service. If this doesn't exist, it will be created (by default). Note that the name can - cannot contain dots. `[a-zA-Z0-9-_]+` are safe. + cannot contain dots. `[a-zA-Z0-9-_/]+` are safe. ### Optional