From c1fbc473a20d1c4e40d6e34985db36b242eb56e0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 6 Nov 2014 08:43:31 -0800 Subject: [PATCH] command/push: propagate token properly --- command/push.go | 10 +++++++--- packer/template.go | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/command/push.go b/command/push.go index 4e315f36c..8d85a9c99 100644 --- a/command/push.go +++ b/command/push.go @@ -57,6 +57,11 @@ func (c *PushCommand) Run(args []string) int { return 1 } + // Determine our token + if token == "" { + token = tpl.Push.Token + } + // Build our client defer func() { c.client = nil }() c.client = harmony.DefaultClient() @@ -68,6 +73,7 @@ func (c *PushCommand) Run(args []string) int { return 1 } } + c.client.Token = token // Build the archiving options var opts archive.ArchiveOpts @@ -92,7 +98,6 @@ func (c *PushCommand) Run(args []string) int { // Build the upload options var uploadOpts uploadOpts uploadOpts.Slug = tpl.Push.Name - uploadOpts.Token = token uploadOpts.Builds = make(map[string]string) for _, b := range tpl.Builders { uploadOpts.Builds[b.Name] = b.Type @@ -184,7 +189,7 @@ func (c *PushCommand) create(name string, create bool) error { if !create { return fmt.Errorf( "Push target doesn't exist: %s. Either create this online via\n" + - "the website or pass the -create flag.") + "the website or pass the -create flag.", name) } // Create it @@ -244,6 +249,5 @@ func (c *PushCommand) upload( type uploadOpts struct { URL string Slug string - Token string Builds map[string]string } diff --git a/packer/template.go b/packer/template.go index 0c0bd9bf0..a65dbcc90 100644 --- a/packer/template.go +++ b/packer/template.go @@ -49,6 +49,7 @@ type PushConfig struct { BaseDir string Include []string Exclude []string + Token string VCS bool }