Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

Commit

Permalink
Allow wcloud users to override username
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwilkie committed Aug 18, 2016
1 parent 38037f8 commit 9f760ab
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions cmd/wcloud/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ func main() {
}

func deploy(c Client, args []string) {
var (
flags = flag.NewFlagSet("", flag.ContinueOnError)
username = flags.String("u", "", "Username to report to deploy service (default with be current user)")
)
if err := flags.Parse(args); err != nil {
usage()
return
}
args = flags.Args()
if len(args) != 1 {
usage()
return
Expand All @@ -72,15 +81,18 @@ func deploy(c Client, args []string) {
usage()
return
}
user, err := user.Current()
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
if *username == "" {
user, err := user.Current()
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
*username = user.Username
}
deployment := Deployment{
ImageName: parts[0],
Version: parts[1],
TriggeringUser: user.Username,
TriggeringUser: *username,
}
if err := c.Deploy(deployment); err != nil {
fmt.Println(err.Error())
Expand Down

0 comments on commit 9f760ab

Please sign in to comment.