Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
cmd/scale: add meta info to status info output.
Browse files Browse the repository at this point in the history
Add the stored metadata when querying the status of a scaling
action. This provides additional user feedback.
  • Loading branch information
jrasell committed Nov 1, 2019
1 parent 0365cb5 commit 6e481b9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cmd/scale/status/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package status
import (
"fmt"
"os"
"strings"

"github.com/jrasell/sherpa/cmd/helper"

Expand All @@ -14,7 +15,7 @@ import (

const (
listOutputHeader = "ID|Job:Group|Status|Time"
infoOutputHeader = "Job:Group|ChangeCount|Direction"
infoOutputHeader = "Job:Group|ChangeCount|Direction|Meta"
)

func RegisterCommand(rootCmd *cobra.Command) error {
Expand Down Expand Up @@ -86,7 +87,8 @@ func runInfo(c *api.Client, id string) int {

events := []string{infoOutputHeader}
for jobGroup, event := range resp {
events = append(events, fmt.Sprintf("%s|%v|%v", jobGroup, event.Details.Count, event.Details.Direction))
events = append(events, fmt.Sprintf("%s|%v|%v|%s",
jobGroup, event.Details.Count, event.Details.Direction, strings.Join(metaToStrings(event.Meta), ",")))

if len(header) == 0 {
header = []string{
Expand All @@ -105,3 +107,11 @@ func runInfo(c *api.Client, id string) int {

return sysexits.OK
}

func metaToStrings(meta map[string]string) []string {
out := []string{}
for k, v := range meta {
out = append(out, k+"="+v)
}
return out
}

0 comments on commit 6e481b9

Please sign in to comment.