Skip to content

Commit

Permalink
Merge pull request #13 from kayac/run-task
Browse files Browse the repository at this point in the history
Run task
  • Loading branch information
fujiwara authored Apr 5, 2018
2 parents 39c61f9 + 1e01d4b commit 7283598
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DATE := $(shell date +%Y-%m-%dT%H:%M:%S%z)
.PHONY: test get-deps get-deps-amd64 binary install clean

cmd/ecspresso/ecspresso: *.go cmd/ecspresso/*.go
cd cmd/ecspresso && go build -ldflags "-s -w -X main.version=${GIT_VER} -X main.buildDate=${DATE}" -gcflags="-trimpath=${PWD}"
cd cmd/ecspresso && go build -ldflags "-s -w -X main.Version=${GIT_VER} -X main.buildDate=${DATE}" -gcflags="-trimpath=${PWD}"

install: cmd/ecspresso/ecspresso
install cmd/ecspresso/ecspresso ${GOPATH}/bin
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Commands:
delete [<flags>]
delete service
run [<flags>]
run task
```

For more options for sub-commands, See `ecspresso sub-command --help`.
Expand Down Expand Up @@ -59,6 +62,7 @@ ecspresso works as below.
- If "FOO" is not defined, abort immediately.
- Update a service definition.
- Wait a service stable.
- Run a new task.

## Example of deploy

Expand Down Expand Up @@ -130,6 +134,11 @@ Keys are same format as `aws ecs describe-services` output.
- placementStrategy
- role

## Example of run task

```console
$ ecspresso run --config config.yaml --task-def=db-migrate.json
```
# Notes

## Deploy to Fargate
Expand Down
19 changes: 18 additions & 1 deletion cmd/ecspresso/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"log"
"os"

Expand All @@ -9,12 +10,16 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var Version = "current"

func main() {
os.Exit(_main())
}

func _main() int {
conf := kingpin.Flag("config", "config file").Required().String()
kingpin.Command("version", "show version")

conf := kingpin.Flag("config", "config file").String()

deploy := kingpin.Command("deploy", "deploy service")
deployOption := ecspresso.DeployOption{
Expand Down Expand Up @@ -47,7 +52,17 @@ func _main() int {
Force: delete.Flag("force", "force delete. not confirm").Bool(),
}

run := kingpin.Command("run", "run task")
runOption := ecspresso.RunOption{
DryRun: run.Flag("dry-run", "dry-run").Bool(),
TaskDefinition: run.Flag("task-def", "task definition json for run task").String(),
}

sub := kingpin.Parse()
if sub == "version" {
fmt.Println("ecspresso", Version)
return 0
}

c := ecspresso.NewDefaultConfig()
if err := config.Load(c, *conf); err != nil {
Expand All @@ -72,6 +87,8 @@ func _main() int {
err = app.Create(createOption)
case "delete":
err = app.Delete(deleteOption)
case "run":
err = app.Run(runOption)
default:
kingpin.Usage()
return 1
Expand Down
Loading

0 comments on commit 7283598

Please sign in to comment.