command: warnings should not exit
also properly colorize error/warnings depends on https://github.com/mitchellh/cli/pull/15
This commit is contained in:
parent
000238835c
commit
4fc5ebf47e
|
@ -14,6 +14,7 @@ type ColorizeUi struct {
|
||||||
OutputColor string
|
OutputColor string
|
||||||
InfoColor string
|
InfoColor string
|
||||||
ErrorColor string
|
ErrorColor string
|
||||||
|
WarnColor string
|
||||||
Ui cli.Ui
|
Ui cli.Ui
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +34,10 @@ func (u *ColorizeUi) Error(message string) {
|
||||||
u.Ui.Error(u.colorize(message, u.ErrorColor))
|
u.Ui.Error(u.colorize(message, u.ErrorColor))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *ColorizeUi) Warn(message string) {
|
||||||
|
u.Ui.Warn(u.colorize(message, u.WarnColor))
|
||||||
|
}
|
||||||
|
|
||||||
func (u *ColorizeUi) colorize(message string, color string) string {
|
func (u *ColorizeUi) colorize(message string, color string) string {
|
||||||
if color == "" {
|
if color == "" {
|
||||||
return message
|
return message
|
||||||
|
|
|
@ -33,9 +33,9 @@ func validateContext(ctx *terraform.Context, ui cli.Ui) bool {
|
||||||
"fix these before continuing.\n")
|
"fix these before continuing.\n")
|
||||||
|
|
||||||
if len(ws) > 0 {
|
if len(ws) > 0 {
|
||||||
ui.Output("Warnings:\n")
|
ui.Warn("Warnings:\n")
|
||||||
for _, w := range ws {
|
for _, w := range ws {
|
||||||
ui.Output(fmt.Sprintf(" * %s", w))
|
ui.Warn(fmt.Sprintf(" * %s", w))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(es) > 0 {
|
if len(es) > 0 {
|
||||||
|
@ -44,13 +44,16 @@ func validateContext(ctx *terraform.Context, ui cli.Ui) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(es) > 0 {
|
if len(es) > 0 {
|
||||||
ui.Output("Errors:\n")
|
ui.Error("Errors:\n")
|
||||||
for _, e := range es {
|
for _, e := range es {
|
||||||
ui.Output(fmt.Sprintf(" * %s", e))
|
ui.Error(fmt.Sprintf(" * %s", e))
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
ui.Warn(fmt.Sprintf("\n"+
|
||||||
|
"No errors found. Continuing with %d warning(s).\n", len(ws)))
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -331,6 +331,7 @@ func (m *Meta) process(args []string, vars bool) []string {
|
||||||
Ui: &ColorizeUi{
|
Ui: &ColorizeUi{
|
||||||
Colorize: m.Colorize(),
|
Colorize: m.Colorize(),
|
||||||
ErrorColor: "[red]",
|
ErrorColor: "[red]",
|
||||||
|
WarnColor: "[yellow]",
|
||||||
Ui: m.oldUi,
|
Ui: m.oldUi,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue