Skip to content

Commit

Permalink
Merge pull request #56 from stelligent/develop
Browse files Browse the repository at this point in the history
Release 0.1.2
  • Loading branch information
cplee committed Jan 17, 2017
2 parents a0f164f + 712bbfa commit 5b288d8
Show file tree
Hide file tree
Showing 43 changed files with 3,291 additions and 269 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.iml
.idea
release/
.release/
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ deploy:
on:
branch: master

## Send notifiations to 'builds' channel
## Send notifications to 'builds' channel
notifications:
email: false
slack:
rooms:
- secure: g7a0GZU36Ix+6IhwWoPZCTDIG4JrqQj4ZW5yYU+nIwLahrxWm2FknztNrNBS/akswVAZFfvgFRsPJWY2SdLcCYGWmVb62VRlKrKiiXUFjXG2/RXRRk3Ivmm7ZMEWe9xFbvK8OwwV6aVK/A+lepB0ory5EE5kwdYCvDj2OWj3Hjeoy7vVMrVcFn+MnUek81XWRzdN0aiTeGZrDA/eT1BNyytk90Mc7AYsAsuMlRelo9s3x9bk0dVqjIpVJZ13+R/Kdoc/N8q1GznwaXScTfhG0UW/aLYLhlWy76QISsQUqM1wOPtuuRmnkezR7NOyEh8Bdo4NfuYfDFWhDru9mHuNMMXJKdh6R51uWmiTNxflZ2la2IoONDsQ/5PAhyVBqGbc30vqVF3IkLNkI+w3rGxI6+1dcBB+otpvwm6e/dQ0azHT8t5bdT2XJXndsdbDeVyAr2XHG01tHRrxZFG2eeEXCqabvNPI0vRqdo193W0eP0fnUDHUMrx1wHbVSEDrbzwM3DcOE9ZYzVv0YByXf8HHsRHNDUj+WjeeGFbYcOaGw3XQYZZ4ooqa9ttvA6dKvbrS9+JeePgfT/vKhEdUqbRZtn8zUBbNiEmT0cIaiF73kmjZh3+kep66hTji/NchAroTD/VQzgTmj2+8/p/uqU/7jSMa0COevb+xx1rgMPpHLV0=
on_success: change
secure: g7a0GZU36Ix+6IhwWoPZCTDIG4JrqQj4ZW5yYU+nIwLahrxWm2FknztNrNBS/akswVAZFfvgFRsPJWY2SdLcCYGWmVb62VRlKrKiiXUFjXG2/RXRRk3Ivmm7ZMEWe9xFbvK8OwwV6aVK/A+lepB0ory5EE5kwdYCvDj2OWj3Hjeoy7vVMrVcFn+MnUek81XWRzdN0aiTeGZrDA/eT1BNyytk90Mc7AYsAsuMlRelo9s3x9bk0dVqjIpVJZ13+R/Kdoc/N8q1GznwaXScTfhG0UW/aLYLhlWy76QISsQUqM1wOPtuuRmnkezR7NOyEh8Bdo4NfuYfDFWhDru9mHuNMMXJKdh6R51uWmiTNxflZ2la2IoONDsQ/5PAhyVBqGbc30vqVF3IkLNkI+w3rGxI6+1dcBB+otpvwm6e/dQ0azHT8t5bdT2XJXndsdbDeVyAr2XHG01tHRrxZFG2eeEXCqabvNPI0vRqdo193W0eP0fnUDHUMrx1wHbVSEDrbzwM3DcOE9ZYzVv0YByXf8HHsRHNDUj+WjeeGFbYcOaGw3XQYZZ4ooqa9ttvA6dKvbrS9+JeePgfT/vKhEdUqbRZtn8zUBbNiEmT0cIaiF73kmjZh3+kep66hTji/NchAroTD/VQzgTmj2+8/p/uqU/7jSMa0COevb+xx1rgMPpHLV0=
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Stelligent
Copyright (c) 2016-2017 Stelligent

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,30 @@ BRANCH := $(or $(TRAVIS_BRANCH), $(shell git rev-parse --abbrev-ref HEAD))
IS_MASTER := $(filter master, $(BRANCH))
VERSION := $(shell cat VERSION)$(if $(IS_MASTER),,-$(BRANCH))
ARCH := $(shell go env GOARCH)
BUILD_FILES = $(foreach os, $(TARGET_OS), release/$(PACKAGE)-$(os)-$(ARCH))
BUILD_FILES = $(foreach os, $(TARGET_OS), .release/$(PACKAGE)-$(os)-$(ARCH))
UPLOAD_FILES = $(foreach os, $(TARGET_OS), $(PACKAGE)-$(os)-$(ARCH))
GOLDFLAGS = "-X main.version=$(VERSION)"
GOLDFLAGS = "-X common.version=$(VERSION)"
TAG_VERSION = v$(VERSION)

default: build

setup:
@echo "=== preparing $(VERSION) from $(BRANCH) ==="
mkdir -p release
mkdir -p .release
go get -u "github.com/golang/lint/golint"
go get -u "github.com/aktau/github-release"
go get -u "github.com/jteeuwen/go-bindata/..."
go get -t -d -v ./...
go generate ./...

lint: setup
@echo "=== linting ==="
go vet ./...
golint ./...
golint -set_exit_status ./...

test: lint
@echo "=== testing ==="
go test ./...
go test -cover ./...

build: test $(BUILD_FILES)

Expand All @@ -52,7 +54,7 @@ release-create: release-clean

$(TARGET_OS): release-create
@echo "=== uploading $@ ==="
github-release upload -u $(ORG) -r $(PACKAGE) -t $(TAG_VERSION) -n "$(PACKAGE)-$@-$(ARCH)" -f "release/$(PACKAGE)-$@-$(ARCH)"
github-release upload -u $(ORG) -r $(PACKAGE) -t $(TAG_VERSION) -n "$(PACKAGE)-$@-$(ARCH)" -f ".release/$(PACKAGE)-$@-$(ARCH)"

dev-release: $(TARGET_OS)

Expand All @@ -67,6 +69,6 @@ endif

clean:
@echo "=== cleaning ==="
rm -rf release
rm -rf .release

.PHONY: default lint test build setup clean release-clean release-create dev-release release $(UPLOAD_FILES) $(TARGET_OS)
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,37 @@ curl -s https://raw.githubusercontent.com/stelligent/mu/master/install.sh | INST
> mu pipeline terminate [-s <service_name>]
```

## Configuration
The definition of your environments, services and pipelines is done via a YAML file (default `./mu.yml`).

```
---
### Region to utilize
region: us-west-2
### Define a list of environments
environments:
# The unique name of the environment (required)
- name: dev
### Attributes for the ECS container instances
cluster:
imageId: ami-xxxxxx # The AMI to use for the ECS container instances (default: latest ECS optimized AMI)
instanceTenancy: default # Whether to use default or dedicated tenancy (default: default)
desiredCapacity: 1 # Desired number of ECS container instances (default 1)
maxSize: 2 # Max size to scale the ECS ASG to (default: 2)
keyName: my-keypair # name of EC2 keypair to associate with ECS container instances (default: none)
sshAllow: 0.0.0.0/0 # CIDR block to allow SSH access from (default: 0.0.0.0/0)
scaleOutThreshold: 80 # Threshold for % memory utilization to scale out ECS container instances (default: 80)
scaleInThreshold: 30 # Threshold for % memory utilization to scale in ECS container instances (default: 30)
### attributes for the VPC to target. If not defined, a VPC will be created. (default: none)
vpcTarget:
vpcId: vpc-xxxxx # The id of the VPC to launch ECS container instances into
publicSubnetIds: # The list of subnets to use for ECS container instances
- sg-xxxxx
- sg-xxxxy
- sg-xxxxz
```

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.1
0.1.2
68 changes: 68 additions & 0 deletions cli/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package cli

import (
"bufio"
"github.com/stelligent/mu/common"
"github.com/urfave/cli"
"os"
)

// NewApp creates a new CLI app
func NewApp() *cli.App {
context := common.NewContext()

app := cli.NewApp()
app.Name = "mu"
app.Usage = "Microservice Platform on AWS"
app.Version = common.GetVersion()
app.EnableBashCompletion = true

app.Commands = []cli.Command{
*newEnvironmentsCommand(context),
*newServicesCommand(context),
*newPipelinesCommand(context),
}

app.Before = func(c *cli.Context) error {
// setup logging
if c.Bool("verbose") {
common.SetupLogging(2)
} else if c.Bool("silent") {
common.SetupLogging(0)
} else {
common.SetupLogging(1)

}

// load yaml config
yamlFile, err := os.Open(c.String("config"))
if err != nil {
return err
}
defer func() {
yamlFile.Close()
}()

// initialize context
context.Initialize(bufio.NewReader(yamlFile))
return nil
}

app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Usage: "path to config file",
Value: "mu.yml",
},
cli.BoolFlag{
Name: "silent, s",
Usage: "silent mode, errors only",
},
cli.BoolFlag{
Name: "verbose, V",
Usage: "increase level of log verbosity",
},
}

return app
}
25 changes: 25 additions & 0 deletions cli/app_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cli

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestNewApp(t *testing.T) {
assert := assert.New(t)
app := NewApp()

assert.NotNil(app)
assert.Equal("mu", app.Name, "Name should match")
assert.Equal("0.0.0-local", app.Version, "Version should match")
assert.Equal("Microservice Platform on AWS", app.Usage, "usage should match")
assert.Equal(true, app.EnableBashCompletion, "bash completion should match")
assert.Equal(3, len(app.Flags), "Flags len should match")
assert.Equal("config, c", app.Flags[0].GetName(), "Flags name should match")
assert.Equal("silent, s", app.Flags[1].GetName(), "Flags name should match")
assert.Equal("verbose, V", app.Flags[2].GetName(), "Flags name should match")
assert.Equal(3, len(app.Commands), "Commands len should match")
assert.Equal("environment", app.Commands[0].Name, "Command[0].name should match")
assert.Equal("service", app.Commands[1].Name, "Command[1].name should match")
assert.Equal("pipeline", app.Commands[2].Name, "Command[2].name should match")
}
99 changes: 99 additions & 0 deletions cli/environments.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package cli

import (
"errors"
"github.com/stelligent/mu/common"
"github.com/stelligent/mu/workflows"
"github.com/urfave/cli"
"os"
)

func newEnvironmentsCommand(ctx *common.Context) *cli.Command {

cmd := &cli.Command{
Name: "environment",
Aliases: []string{"env"},
Usage: "options for managing environments",
Subcommands: []cli.Command{
*newEnvironmentsListCommand(ctx),
*newEnvironmentsShowCommand(ctx),
*newEnvironmentsUpsertCommand(ctx),
*newEnvironmentsTerminateCommand(ctx),
},
}

return cmd
}

func newEnvironmentsUpsertCommand(ctx *common.Context) *cli.Command {
cmd := &cli.Command{
Name: "upsert",
Aliases: []string{"up"},
Usage: "create/update an environment",
ArgsUsage: "<environment>",
Action: func(c *cli.Context) error {
environmentName := c.Args().First()
if len(environmentName) == 0 {
cli.ShowCommandHelp(c, "upsert")
return errors.New("environment must be provided")
}

workflow := workflows.NewEnvironmentUpserter(ctx, environmentName)
return workflow()
},
}

return cmd
}

func newEnvironmentsListCommand(ctx *common.Context) *cli.Command {
cmd := &cli.Command{
Name: "list",
Aliases: []string{"ls"},
Usage: "list environments",
Action: func(c *cli.Context) error {
workflow := workflows.NewEnvironmentLister(ctx, os.Stdout)
return workflow()
},
}

return cmd
}

func newEnvironmentsShowCommand(ctx *common.Context) *cli.Command {
cmd := &cli.Command{
Name: "show",
Usage: "show environment details",
ArgsUsage: "<environment>",
Action: func(c *cli.Context) error {
environmentName := c.Args().First()
if len(environmentName) == 0 {
cli.ShowCommandHelp(c, "show")
return errors.New("environment must be provided")
}
workflow := workflows.NewEnvironmentViewer(ctx, environmentName, os.Stdout)
return workflow()
},
}

return cmd
}
func newEnvironmentsTerminateCommand(ctx *common.Context) *cli.Command {
cmd := &cli.Command{
Name: "terminate",
Aliases: []string{"term"},
Usage: "terminate an environment",
ArgsUsage: "<environment>",
Action: func(c *cli.Context) error {
environmentName := c.Args().First()
if len(environmentName) == 0 {
cli.ShowCommandHelp(c, "terminate")
return errors.New("environment must be provided")
}
workflow := workflows.NewEnvironmentTerminator(ctx, environmentName)
return workflow()
},
}

return cmd
}
Loading

0 comments on commit 5b288d8

Please sign in to comment.