Skip to content

Commit

Permalink
feat(cli): tk status improvements (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
Duologic authored Mar 18, 2021
1 parent 3cc514d commit fc049ab
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/tk/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"sort"
"text/tabwriter"

"github.com/fatih/structs"
Expand All @@ -19,11 +20,13 @@ func statusCmd() *cli.Command {
Args: workflowArgs,
}

vars := workflowFlags(cmd.Flags())
getJsonnetOpts := jsonnetFlags(cmd.Flags())

cmd.Run = func(cmd *cli.Command, args []string) error {
status, err := tanka.Status(args[0], tanka.Opts{
JsonnetOpts: getJsonnetOpts(),
Name: vars.name,
})
if err != nil {
return err
Expand All @@ -33,7 +36,15 @@ func statusCmd() *cli.Command {
fmt.Println("Context:", context.Name)
fmt.Println("Cluster:", context.Context.Cluster)
fmt.Println("Environment:")
for k, v := range structs.Map(status.Env.Spec) {

specMap := structs.Map(status.Env.Spec)
var keys []string
for k := range specMap {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
v := specMap[k]
fmt.Printf(" %s: %v\n", k, v)
}

Expand Down

0 comments on commit fc049ab

Please sign in to comment.