diff --git a/Makefile b/Makefile index 8affa8c..8fb649d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 0.8.5 +VERSION = 0.8.7 GO_FMT = gofmt -s -w -l . GO_XC = goxc -os="linux darwin windows" -tasks-="rmbin" diff --git a/commands/config.go b/commands/config.go index a5ed3b9..5bcf832 100644 --- a/commands/config.go +++ b/commands/config.go @@ -18,17 +18,16 @@ const ( {{end}}` ) - type ConfigEnvironments struct { DefaultEnv string Envs map[string]*cliconfig.ConfigEnvironment } type EnvironmentSummary struct { - Name string + Name string EnvType string HostURL string - Auth bool + Auth bool Default bool } @@ -173,7 +172,7 @@ type ConfigTemplate struct { } func templateFor(template string, data interface{}) ConfigTemplate { - return ConfigTemplate{cli.FormatData{ Template: template, Data: data, Funcs: buildFuncMap() }} + return ConfigTemplate{cli.FormatData{Template: template, Data: data, Funcs: buildFuncMap()}} } func (d ConfigTemplate) ToColumns(output io.Writer) error { @@ -195,10 +194,10 @@ func (e ConfigEnvironments) toEnvironmentMap() []*EnvironmentSummary { sc = *v.Marathon } arr = append(arr, &EnvironmentSummary{ - Name: k, + Name: k, EnvType: v.EnvironmentType(), HostURL: sc.HostUrl, - Auth: sc.Username != "", + Auth: sc.Username != "", Default: k == e.DefaultEnv, }) } @@ -207,7 +206,7 @@ func (e ConfigEnvironments) toEnvironmentMap() []*EnvironmentSummary { func buildFuncMap() template.FuncMap { funcMap := template.FuncMap{ - "defaultEnvToStr": defaultEnvToStr, + "defaultEnvToStr": defaultEnvToStr, } return funcMap } @@ -217,4 +216,4 @@ func defaultEnvToStr(b bool) string { return "true" } return "-" -} \ No newline at end of file +} diff --git a/commands/format.go b/commands/format.go index 1345a76..6fc207e 100644 --- a/commands/format.go +++ b/commands/format.go @@ -63,4 +63,3 @@ func printColumn(formatter cli.Formatter) { log.Error("Error: %s", err.Error()) } } - diff --git a/commands/marathon/app_bg_cmds.go b/commands/marathon/app_bg_cmds.go index 5ca9346..08a11fe 100644 --- a/commands/marathon/app_bg_cmds.go +++ b/commands/marathon/app_bg_cmds.go @@ -53,7 +53,7 @@ func deployBlueGreenCmd(cmd *cobra.Command, args []string) { cli.Output(nil, err) os.Exit(1) } - cli.Output(templateFor(T_APPLICATIONS, a), err) + cli.Output(templateFor(T_APPLICATION, a), err) } func bgc(c *cobra.Command) bluegreen.BlueGreen { diff --git a/commands/marathon/app_cmds.go b/commands/marathon/app_cmds.go index 92dc428..a4e7f5d 100644 --- a/commands/marathon/app_cmds.go +++ b/commands/marathon/app_cmds.go @@ -55,6 +55,7 @@ var appListCmd = &cobra.Command{ Short: "List all applications", Run: func(cmd *cobra.Command, args []string) { v, e := client(cmd).ListApplications() + cli.Output(templateFor(T_APPLICATIONS, v), e) }, } @@ -175,7 +176,7 @@ func createApp(cmd *cobra.Command, args []string) { } os.Exit(1) } - cli.Output(templateFor(T_APPLICATIONS, result), e) + cli.Output(templateFor(T_APPLICATION, result), e) } func parseParamsFile(filename string) (map[string]string, error) { @@ -251,7 +252,7 @@ func updateAppCPU(cmd *cobra.Command, args []string) { } update := marathon.NewApplication(args[0]).CPU(cpu) v, e := client(cmd).UpdateApplication(update, wait) - cli.Output(templateFor(T_APPLICATIONS, v), e) + cli.Output(templateFor(T_APPLICATION, v), e) } func updateAppMemory(cmd *cobra.Command, args []string) { @@ -268,7 +269,7 @@ func updateAppMemory(cmd *cobra.Command, args []string) { } update := marathon.NewApplication(args[0]).Memory(mem) v, e := client(cmd).UpdateApplication(update, wait) - cli.Output(templateFor(T_APPLICATIONS, v), e) + cli.Output(templateFor(T_APPLICATION, v), e) } func rollbackAppVersion(cmd *cobra.Command, args []string) { @@ -289,7 +290,7 @@ func rollbackAppVersion(cmd *cobra.Command, args []string) { } update := marathon.NewApplication(args[0]).RollbackVersion(version) v, e := client(cmd).UpdateApplication(update, wait) - cli.Output(templateFor(T_APPLICATIONS, v), e) + cli.Output(templateFor(T_APPLICATION, v), e) } func convertFile(cmd *cobra.Command, args []string) { diff --git a/commands/marathon/templates.go b/commands/marathon/templates.go index 0e7f064..f1a16e6 100644 --- a/commands/marathon/templates.go +++ b/commands/marathon/templates.go @@ -2,10 +2,10 @@ package marathon import ( "github.com/ContainX/depcon/marathon" - "github.com/ContainX/depcon/utils" - "text/template" "github.com/ContainX/depcon/pkg/cli" + "github.com/ContainX/depcon/utils" "io" + "text/template" ) const ( @@ -113,7 +113,7 @@ type Templated struct { } func templateFor(template string, data interface{}) Templated { - return Templated{cli.FormatData{ Template: template, Data: data, Funcs: buildFuncMap() }} + return Templated{cli.FormatData{Template: template, Data: data, Funcs: buildFuncMap()}} } func (d Templated) ToColumns(output io.Writer) error { @@ -124,13 +124,12 @@ func (d Templated) Data() cli.FormatData { return d.FormatData } - func buildFuncMap() template.FuncMap { funcMap := template.FuncMap{ - "intConcat": utils.ConcatInts, - "idConcat": utils.ConcatIdentifiers, - "dockerImage": dockerImageOrEmpty, - "hasDocker": hasDocker, + "intConcat": utils.ConcatInts, + "idConcat": utils.ConcatIdentifiers, + "dockerImage": dockerImageOrEmpty, + "hasDocker": hasDocker, } return funcMap } diff --git a/marathon/application.go b/marathon/application.go index 3e07b4d..3b26b7c 100644 --- a/marathon/application.go +++ b/marathon/application.go @@ -20,7 +20,6 @@ const ( var ( ErrorAppExists = errors.New("The application already exists") ErrorGroupExists = errors.New("The group already exists") - ErrorInvalidAppId = errors.New("The application identifier is invalid") ErrorInvalidGroupId = errors.New("The group identifier is invalid") ErrorNoAppExists = errors.New("The application does not exist. Create an application before updating") ErrorGropAppExists = errors.New("The group does not exist. Create a group before updating") diff --git a/pkg/cli/output.go b/pkg/cli/output.go index 9f4963c..2c8721e 100644 --- a/pkg/cli/output.go +++ b/pkg/cli/output.go @@ -3,8 +3,8 @@ package cli import ( "fmt" "io" - "text/tabwriter" "strconv" + "text/tabwriter" "text/template" "time" ) @@ -18,10 +18,9 @@ type Formatter interface { type FormatData struct { Data interface{} Template string - Funcs template.FuncMap + Funcs template.FuncMap } - // Handles writing the formatted type into the desired output and global formatting type CLIWriter struct { FormatWriter func(f Formatter) @@ -68,10 +67,10 @@ func buildFuncMap(userFuncs template.FuncMap) template.FuncMap { funcMap := template.FuncMap{ "floatToString": floatToString, "intToString": strconv.Itoa, - "valString": valueToString, + "valString": valueToString, "pad": padString, - "fdate": FormatDate, - "msDur": durationToMilliseconds, + "fdate": FormatDate, + "msDur": durationToMilliseconds, "boolToYesNo": boolToYesNo, }