Skip to content

Commit

Permalink
Merge pull request juju#6186 from howbazaar/more-status-updates
Browse files Browse the repository at this point in the history
Align scale and rev columns right.

Also only shows n/m for scale when they are different.
Highlights different numbers with color.

Fixes http://pad.lv/1620062
  • Loading branch information
jujubot authored Sep 8, 2016
2 parents 3214914 + 9541286 commit 33f0f3e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
7 changes: 5 additions & 2 deletions cmd/juju/status/formatted.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type unitStatus struct {
Subordinates map[string]unitStatus `json:"subordinates,omitempty" yaml:"subordinates,omitempty"`
}

func (s *formattedStatus) applicationScale(name string) string {
func (s *formattedStatus) applicationScale(name string) (string, bool) {
// The current unit count are units that are either in Idle or Executing status.
// In other words, units that are active and available.
currentUnitCount := 0
Expand Down Expand Up @@ -151,7 +151,10 @@ func (s *formattedStatus) applicationScale(name string) string {
match(u)
}
}
return fmt.Sprintf("%d/%d", currentUnitCount, desiredUnitCount)
if currentUnitCount == desiredUnitCount {
return fmt.Sprint(currentUnitCount), false
}
return fmt.Sprintf("%d/%d", currentUnitCount, desiredUnitCount), true
}

type statusInfoContents struct {
Expand Down
11 changes: 9 additions & 2 deletions cmd/juju/status/output_tabular.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func FormatTabular(writer io.Writer, forceColor bool, value interface{}) error {
metering := false
relations := newRelationFormatter()
outputHeaders("APP", "VERSION", "STATUS", "SCALE", "CHARM", "STORE", "REV", "OS", "NOTES")
tw.SetColumnAlignRight(3)
tw.SetColumnAlignRight(6)
for _, appName := range utils.SortStringsNaturally(stringKeysFromMap(fs.Applications)) {
app := fs.Applications[appName]
version := app.Version
Expand All @@ -135,8 +137,13 @@ func FormatTabular(writer io.Writer, forceColor bool, value interface{}) error {
}
w.Print(appName, version)
w.PrintStatus(app.StatusInfo.Current)
p(fs.applicationScale(appName),
app.CharmName,
scale, warn := fs.applicationScale(appName)
if warn {
w.PrintColor(output.WarningHighlight, scale)
} else {
w.Print(scale)
}
p(app.CharmName,
app.CharmOrigin,
app.CharmRev,
app.OS,
Expand Down
10 changes: 5 additions & 5 deletions cmd/juju/status/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3498,9 +3498,9 @@ MODEL CONTROLLER CLOUD/REGION VERSION NOTES
controller kontroll dummy/dummy-region 1.2.3 upgrade available: 1.2.4
APP VERSION STATUS SCALE CHARM STORE REV OS NOTES
logging a bi... error 2/2 logging jujucharms 1 ubuntu exposed
mysql 5.7.13 maintenance 1/1 mysql jujucharms 1 ubuntu exposed
wordpress 4.5.3 active 1/1 wordpress jujucharms 3 ubuntu exposed
logging a bi... error 2 logging jujucharms 1 ubuntu exposed
mysql 5.7.13 maintenance 1 mysql jujucharms 1 ubuntu exposed
wordpress 4.5.3 active 1 wordpress jujucharms 3 ubuntu exposed
RELATION PROVIDES CONSUMES TYPE
juju-info logging mysql regular
Expand Down Expand Up @@ -3565,7 +3565,7 @@ MODEL CONTROLLER CLOUD/REGION VERSION
APP VERSION STATUS SCALE CHARM STORE REV OS NOTES
foo 2/2 0
foo 2 0
UNIT WORKLOAD AGENT MACHINE PUBLIC-ADDRESS PORTS MESSAGE
foo/0 maintenance executing (config-changed) doing some work
Expand Down Expand Up @@ -3659,7 +3659,7 @@ MODEL CONTROLLER CLOUD/REGION VERSION
APP VERSION STATUS SCALE CHARM STORE REV OS NOTES
foo 0/2 0
foo 0/2 0
UNIT WORKLOAD AGENT MACHINE PUBLIC-ADDRESS PORTS MESSAGE
foo/0
Expand Down
2 changes: 1 addition & 1 deletion dependencies.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ github.com/gosuri/uitable git 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 2016-04-0
github.com/joyent/gocommon git ade826b8b54e81a779ccb29d358a45ba24b7809c 2016-03-20T19:31:33Z
github.com/joyent/gosdc git 2f11feadd2d9891e92296a1077c3e2e56939547d 2014-05-24T00:08:15Z
github.com/joyent/gosign git 0da0d5f1342065321c97812b1f4ac0c2b0bab56c 2014-05-24T00:07:34Z
github.com/juju/ansiterm git c4ce98b1cd3195b2d6a3069a2445bee608de04a2 2016-08-23T04:14:03Z
github.com/juju/ansiterm git b99631de12cf04a906c1d4e4ec54fb86eae5863d 2016-09-07T23:45:32Z
github.com/juju/blobstore git 06056004b3d7b54bbb7984d830c537bad00fec21 2015-07-29T11:18:58Z
github.com/juju/bundlechanges git 6791af0ab78efe88ff99c2a0095208b3b7a32055 2016-07-20T09:32:50Z
github.com/juju/cmd git 1c6973d59b804e4d3c293fbf240f067e73436bc9 2016-08-23T10:31:14Z
Expand Down

0 comments on commit 33f0f3e

Please sign in to comment.