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

Commit

Permalink
Merge pull request weaveworks#36 from weaveworks/wcloud-service-flags
Browse files Browse the repository at this point in the history
Add wcloud deploy --service flag
  • Loading branch information
tomwilkie authored Aug 25, 2016
2 parents 3527b56 + 9cbab40 commit e030008
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ cover/cover
socks/proxy
socks/image.tar
runner/runner
cmd/wcloud/wcloud
*.pyc
*~
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ test:
- cd $SRCDIR/cover; make
- cd $SRCDIR/socks; make
- cd $SRCDIR/runner; make
- cd $SRCDIR/cmd/wcloud; make

11 changes: 11 additions & 0 deletions cmd/wcloud/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: all clean

all: wcloud

wcloud: *.go
go get ./$(@D)
go build -o $@ ./$(@D)

clean:
rm -rf wcloud
go clean ./...
22 changes: 19 additions & 3 deletions cmd/wcloud/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ import (
"gopkg.in/yaml.v2"
)

// ArrayFlags allows you to collect repeated flags
type ArrayFlags []string

func (a *ArrayFlags) String() string {
return strings.Join(*a, ",")
}

// Set implements flags.Value
func (a *ArrayFlags) Set(value string) error {
*a = append(*a, value)
return nil
}

func env(key, def string) string {
if val, ok := os.LookupEnv(key); ok {
return val
Expand Down Expand Up @@ -66,7 +79,9 @@ 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)")
services ArrayFlags
)
flag.Var(&services, "service", "Service to update (can be repeated)")
if err := flags.Parse(args); err != nil {
usage()
return
Expand All @@ -90,9 +105,10 @@ func deploy(c Client, args []string) {
*username = user.Username
}
deployment := Deployment{
ImageName: parts[0],
Version: parts[1],
TriggeringUser: *username,
ImageName: parts[0],
Version: parts[1],
TriggeringUser: *username,
IntendedServices: services,
}
if err := c.Deploy(deployment); err != nil {
fmt.Println(err.Error())
Expand Down
3 changes: 2 additions & 1 deletion cmd/wcloud/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ type Deployment struct {
Priority int `json:"priority"`
State string `json:"status"`

TriggeringUser string `json:"triggering_user"`
TriggeringUser string `json:"triggering_user"`
IntendedServices []string `json:"intended_services"`
}

// Config for the deployment system for a user.
Expand Down

0 comments on commit e030008

Please sign in to comment.