-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from stelligent/develop
Release 0.1.2
- Loading branch information
Showing
43 changed files
with
3,291 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
*.iml | ||
.idea | ||
release/ | ||
.release/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.1.1 | ||
0.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.