command/push: propagate token properly

This commit is contained in:
Mitchell Hashimoto 2014-11-06 08:43:31 -08:00
parent 6bd8c6ca79
commit c1fbc473a2
2 changed files with 8 additions and 3 deletions

View File

@ -57,6 +57,11 @@ func (c *PushCommand) Run(args []string) int {
return 1 return 1
} }
// Determine our token
if token == "" {
token = tpl.Push.Token
}
// Build our client // Build our client
defer func() { c.client = nil }() defer func() { c.client = nil }()
c.client = harmony.DefaultClient() c.client = harmony.DefaultClient()
@ -68,6 +73,7 @@ func (c *PushCommand) Run(args []string) int {
return 1 return 1
} }
} }
c.client.Token = token
// Build the archiving options // Build the archiving options
var opts archive.ArchiveOpts var opts archive.ArchiveOpts
@ -92,7 +98,6 @@ func (c *PushCommand) Run(args []string) int {
// Build the upload options // Build the upload options
var uploadOpts uploadOpts var uploadOpts uploadOpts
uploadOpts.Slug = tpl.Push.Name uploadOpts.Slug = tpl.Push.Name
uploadOpts.Token = token
uploadOpts.Builds = make(map[string]string) uploadOpts.Builds = make(map[string]string)
for _, b := range tpl.Builders { for _, b := range tpl.Builders {
uploadOpts.Builds[b.Name] = b.Type uploadOpts.Builds[b.Name] = b.Type
@ -184,7 +189,7 @@ func (c *PushCommand) create(name string, create bool) error {
if !create { if !create {
return fmt.Errorf( return fmt.Errorf(
"Push target doesn't exist: %s. Either create this online via\n" + "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 // Create it
@ -244,6 +249,5 @@ func (c *PushCommand) upload(
type uploadOpts struct { type uploadOpts struct {
URL string URL string
Slug string Slug string
Token string
Builds map[string]string Builds map[string]string
} }

View File

@ -49,6 +49,7 @@ type PushConfig struct {
BaseDir string BaseDir string
Include []string Include []string
Exclude []string Exclude []string
Token string
VCS bool VCS bool
} }