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 b46bef3e8..1e7d06ac5 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