Skip to content

Commit

Permalink
[gp-cli] support workspace class in top command
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Aug 24, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9a7119d commit 8fd8d7e
Showing 7 changed files with 375 additions and 151 deletions.
13 changes: 13 additions & 0 deletions components/gitpod-cli/cmd/top.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ package cmd

import (
"context"
"encoding/json"
"fmt"
"log"
"os"
@@ -22,7 +23,12 @@ import (
"github.com/olekukonko/tablewriter"
)

var opts struct {
Json bool
}

func outputTable(workspaceResources *supervisor.ResourcesStatusResponse) {
fmt.Printf("Workspace Class: %s\n", workspaceResources.WorkspaceClass)
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"CPU (millicores)", "Memory (bytes)"})
table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: false})
@@ -69,11 +75,18 @@ var topCmd = &cobra.Command{
log.Fatalf("cannot get workspace resources: %s", err)
}

if opts.Json {
content, _ := json.Marshal(workspaceResources)
fmt.Println(string(content))
return
}

outputTable(workspaceResources)
},
}

func init() {
topCmd.Flags().BoolVarP(&noColor, "no-color", "", false, "Disable output colorization")
topCmd.Flags().BoolVarP(&opts.Json, "json", "j", false, "print like json")
rootCmd.AddCommand(topCmd)
}
220 changes: 116 additions & 104 deletions components/supervisor-api/go/status.pb.go

Large diffs are not rendered by default.

Loading

0 comments on commit 8fd8d7e

Please sign in to comment.