Commit 983b0b89 authored by Seth Vargo's avatar Seth Vargo

Allow specifying a -message when pushing

parent 7911d988
...@@ -38,6 +38,7 @@ func (c *PushCommand) Run(args []string) int { ...@@ -38,6 +38,7 @@ func (c *PushCommand) Run(args []string) int {
f := flag.NewFlagSet("push", flag.ContinueOnError) f := flag.NewFlagSet("push", flag.ContinueOnError)
f.Usage = func() { c.Ui.Error(c.Help()) } f.Usage = func() { c.Ui.Error(c.Help()) }
f.StringVar(&token, "token", "", "token") f.StringVar(&token, "token", "", "token")
f.StringVar(&message, "m", "", "message")
f.StringVar(&message, "message", "", "message") f.StringVar(&message, "message", "", "message")
if err := f.Parse(args); err != nil { if err := f.Parse(args); err != nil {
return 1 return 1
...@@ -149,6 +150,13 @@ func (c *PushCommand) Run(args []string) int { ...@@ -149,6 +150,13 @@ func (c *PushCommand) Run(args []string) int {
uploadOpts.Builds[b.Name] = info uploadOpts.Builds[b.Name] = info
} }
// Add the upload metadata
metadata := make(map[string]interface{})
if message != "" {
metadata["message"] = message
}
uploadOpts.Metadata = metadata
// Warn about builds not having post-processors. // Warn about builds not having post-processors.
var badBuilds []string var badBuilds []string
for name, b := range uploadOpts.Builds { for name, b := range uploadOpts.Builds {
...@@ -224,10 +232,10 @@ Usage: packer push [options] TEMPLATE ...@@ -224,10 +232,10 @@ Usage: packer push [options] TEMPLATE
Options: Options:
-message=<detail> A message to identify the purpose or changes in this -m, -message=<detail> A message to identify the purpose or changes in this
Packer template much like a VCS commit message Packer template much like a VCS commit message
-token=<token> The access token to use to when uploading -token=<token> The access token to use to when uploading
` `
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
...@@ -279,7 +287,7 @@ func (c *PushCommand) upload( ...@@ -279,7 +287,7 @@ func (c *PushCommand) upload(
// Start the upload // Start the upload
doneCh, errCh := make(chan struct{}), make(chan error) doneCh, errCh := make(chan struct{}), make(chan error)
go func() { go func() {
err := c.client.UploadBuildConfigVersion(&version, r, r.Size) err := c.client.UploadBuildConfigVersion(&version, opts.Metadata, r, r.Size)
if err != nil { if err != nil {
errCh <- err errCh <- err
return return
...@@ -292,9 +300,10 @@ func (c *PushCommand) upload( ...@@ -292,9 +300,10 @@ func (c *PushCommand) upload(
} }
type uploadOpts struct { type uploadOpts struct {
URL string URL string
Slug string Slug string
Builds map[string]*uploadBuildInfo Builds map[string]*uploadBuildInfo
Metadata map[string]interface{}
} }
type uploadBuildInfo struct { type uploadBuildInfo struct {
......
...@@ -25,6 +25,10 @@ must be completed within the template. ...@@ -25,6 +25,10 @@ must be completed within the template.
## Options ## Options
* `-message` - A message to identify the purpose or changes in this Packer
template much like a VCS commit message. This message will be passed to the
Packer build service. This option is also available as a short option `-m`.
* `-token` - An access token for authenticating the push to the Packer build * `-token` - An access token for authenticating the push to the Packer build
service such as Atlas. This can also be specified within the push service such as Atlas. This can also be specified within the push
configuration in the template. configuration in the template.
...@@ -34,7 +38,7 @@ must be completed within the template. ...@@ -34,7 +38,7 @@ must be completed within the template.
Push a Packer template: Push a Packer template:
```shell ```shell
$ packer push template.json $ packer push -m "Updating the apache version" template.json
``` ```
Push a Packer template with a custom token: Push a Packer template with a custom token:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment