Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring package #29

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test:
go test $$(go list ./... | tr '\n' ' ')

build:
go build -o ./bin/kangol *.go
go build -o ./bin/kangol cmd/kangol/main.go

update:
go get -u=patch
Expand Down
17 changes: 17 additions & 0 deletions cmd/kangol/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
log "github.com/Sirupsen/logrus"
"github.com/recruit-mp/kangol/internal"
"os"
)

const version = "0.2.8"

func main() {
app := internal.NewApp(version)
err := app.Run(os.Args)
if err != nil {
log.Fatal(err.Error())
}
}
19 changes: 8 additions & 11 deletions main.go → internal/app.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package main
package internal

import (
"os"

"github.com/codegangsta/cli"
"github.com/recruit-mp/kangol/internal/operation"
)

func main() {
func NewApp(version string) *cli.App {
finished := make(chan bool)
go loading(finished)
go operation.Loading(finished)

app := cli.NewApp()
app.Name = "kangol"
app.Version = "0.2.8"
app.Version = version
app.Usage = "ECS deployment tool"
app.Flags = []cli.Flag{
cli.StringFlag{
Expand Down Expand Up @@ -49,7 +48,7 @@ func main() {
if c.Bool("loading") == false {
finished <- true
}
deploy(
operation.Deploy(
c.String("conf"),
c.String("tag"),
c.Bool("debug"),
Expand Down Expand Up @@ -89,11 +88,9 @@ func main() {
},
},
Action: func(c *cli.Context) {
runTask(c.String("conf"), c.String("tag"), c.String("command"), c.Int64("cpu"), c.Int64("memory"))
operation.RunTask(c.String("conf"), c.String("tag"), c.String("command"), c.Int64("cpu"), c.Int64("memory"))
},
},
}

app.Run(os.Args)

return app
}
File renamed without changes.
10 changes: 5 additions & 5 deletions deploy.go → internal/operation/deploy.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package main
package operation

import (
"fmt"
"strings"
"time"

log "github.com/Sirupsen/logrus"
"github.com/recruit-mp/kangol/awsecs"
"github.com/recruit-mp/kangol/task"
"github.com/recruit-mp/kangol/internal/awsecs"
"github.com/recruit-mp/kangol/internal/task"
)

func deploy(conf, tag string, debug bool, skipPolling bool, pollingTime int64) {
func Deploy(conf, tag string, debug bool, skipPolling bool, pollingTime int64) {

deployment, taskDefinition, err := task.ReadConfig(conf, appendTags(tag))

Expand Down Expand Up @@ -93,7 +93,7 @@ func appendTags(tag string) map[string]string {
return tags
}

func loading(finished chan bool) {
func Loading(finished chan bool) {
loop:
for {
select {
Expand Down
10 changes: 5 additions & 5 deletions run_task.go → internal/operation/run_task.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package main
package operation

import (
"fmt"
"strings"

log "github.com/Sirupsen/logrus"
"github.com/aws/aws-sdk-go/aws"
"github.com/recruit-mp/kangol/awscloudwatchlogs"
"github.com/recruit-mp/kangol/awsecs"
"github.com/recruit-mp/kangol/task"
"github.com/recruit-mp/kangol/internal/awscloudwatchlogs"
"github.com/recruit-mp/kangol/internal/awsecs"
"github.com/recruit-mp/kangol/internal/task"
)

func runTask(conf, tag string, command string, cpu int64, memory int64) {
func RunTask(conf, tag string, command string, cpu int64, memory int64) {

deployment, taskDefinition, err := task.ReadConfig(conf, appendTags(tag))

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.