Tidy up some planning/deployment messages
This commit is contained in:
parent
a70790b81a
commit
8465d39a02
|
@ -136,11 +136,15 @@ func deployLatest(cmd *cobra.Command, info *envCmdInfo, opts deployOptions) erro
|
|||
|
||||
// Print a summary.
|
||||
var footer bytes.Buffer
|
||||
if empty {
|
||||
cmdutil.Diag().Infof(diag.Message("no resources need to be updated"))
|
||||
} else {
|
||||
if !empty {
|
||||
// Print out the total number of steps performed (and their kinds), the duration, and any summary info.
|
||||
printSummary(&footer, progress.Ops, false)
|
||||
if c := printSummary(&footer, progress.Ops, false); c == 0 {
|
||||
empty = true
|
||||
}
|
||||
}
|
||||
if empty {
|
||||
cmdutil.Diag().Infof(diag.Message("no changes were made"))
|
||||
} else {
|
||||
footer.WriteString(fmt.Sprintf("%vDeployment duration: %v%v\n",
|
||||
colors.SpecUnimportant, time.Since(start), colors.Reset))
|
||||
}
|
||||
|
|
|
@ -210,11 +210,15 @@ func printPlan(result *planResult, opts deployOptions) error {
|
|||
}
|
||||
|
||||
// If we are doing an empty update, say so.
|
||||
if empty {
|
||||
cmdutil.Diag().Infof(diag.Message("no resources need to be updated"))
|
||||
} else {
|
||||
if !empty {
|
||||
// Print a summary of operation counts.
|
||||
printSummary(&summary, counts, true)
|
||||
if c := printSummary(&summary, counts, true); c == 0 {
|
||||
empty = true
|
||||
}
|
||||
}
|
||||
if empty {
|
||||
cmdutil.Diag().Infof(diag.Message("no changes are required"))
|
||||
} else {
|
||||
fmt.Print(colors.Colorize(&summary))
|
||||
}
|
||||
return nil
|
||||
|
@ -256,36 +260,39 @@ func printConfig(b *bytes.Buffer, config resource.ConfigMap) {
|
|||
}
|
||||
}
|
||||
|
||||
func printSummary(b *bytes.Buffer, counts map[deploy.StepOp]int, plan bool) {
|
||||
func printSummary(b *bytes.Buffer, counts map[deploy.StepOp]int, plan bool) int {
|
||||
total := 0
|
||||
for _, c := range counts {
|
||||
total += c
|
||||
}
|
||||
|
||||
var planned string
|
||||
if plan {
|
||||
planned = "planned "
|
||||
}
|
||||
var colon string
|
||||
if total != 0 {
|
||||
colon = ":"
|
||||
}
|
||||
b.WriteString(fmt.Sprintf("%v total %v%v%v\n", total, planned, plural("change", total), colon))
|
||||
if total > 0 {
|
||||
var kind string
|
||||
if plan {
|
||||
kind = "planned"
|
||||
} else {
|
||||
kind = "deployed"
|
||||
}
|
||||
b.WriteString(fmt.Sprintf("%vinfo%v: %v %v %v:\n",
|
||||
colors.SpecInfo, colors.Reset, total, kind, plural("change", total)))
|
||||
|
||||
var planTo string
|
||||
var pastTense string
|
||||
if plan {
|
||||
planTo = "to "
|
||||
} else {
|
||||
pastTense = "d"
|
||||
}
|
||||
var planTo string
|
||||
var pastTense string
|
||||
if plan {
|
||||
planTo = "to "
|
||||
} else {
|
||||
pastTense = "d"
|
||||
}
|
||||
|
||||
for _, op := range deploy.StepOps {
|
||||
if c := counts[op]; c > 0 {
|
||||
b.WriteString(fmt.Sprintf(" %v%v %v %v%v%v%v\n",
|
||||
op.Prefix(), c, plural("resource", c), planTo, op, pastTense, colors.Reset))
|
||||
for _, op := range deploy.StepOps {
|
||||
if c := counts[op]; c > 0 {
|
||||
b.WriteString(fmt.Sprintf(" %v%v %v %v%v%v%v\n",
|
||||
op.Prefix(), c, plural("resource", c), planTo, op, pastTense, colors.Reset))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
|
||||
func plural(s string, c int) string {
|
||||
|
|
Loading…
Reference in a new issue