orchard list vms: add "Created" row (#106)
This commit is contained in:
parent
d57d18d380
commit
0ba7db1a70
2
go.mod
2
go.mod
|
|
@ -7,7 +7,7 @@ require (
|
|||
github.com/avast/retry-go/v4 v4.3.3
|
||||
github.com/deckarep/golang-set/v2 v2.1.0
|
||||
github.com/dgraph-io/badger/v3 v3.2103.5
|
||||
github.com/dustin/go-humanize v1.0.0
|
||||
github.com/dustin/go-humanize v1.0.1
|
||||
github.com/gin-gonic/gin v1.9.0
|
||||
github.com/go-openapi/runtime v0.25.0
|
||||
github.com/gofrs/flock v0.8.1
|
||||
|
|
|
|||
3
go.sum
3
go.sum
|
|
@ -97,8 +97,9 @@ github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWa
|
|||
github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ package list
|
|||
import (
|
||||
"fmt"
|
||||
"github.com/cirruslabs/orchard/pkg/client"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/gosuri/uitable"
|
||||
"github.com/spf13/cobra"
|
||||
"time"
|
||||
)
|
||||
|
||||
func newListVMsCommand() *cobra.Command {
|
||||
|
|
@ -38,12 +40,13 @@ func runListVMs(cmd *cobra.Command, args []string) error {
|
|||
|
||||
table := uitable.New()
|
||||
|
||||
table.AddRow("Name", "Image", "Status", "Restart policy")
|
||||
table.AddRow("Name", "Created", "Image", "Status", "Restart policy")
|
||||
|
||||
for _, vm := range vms {
|
||||
restartPolicyInfo := fmt.Sprintf("%s (%d restarts)", vm.RestartPolicy, vm.RestartCount)
|
||||
createdAtInfo := humanize.RelTime(vm.CreatedAt, time.Now(), "ago", "in the future")
|
||||
|
||||
table.AddRow(vm.Name, vm.Image, vm.Status, restartPolicyInfo)
|
||||
table.AddRow(vm.Name, createdAtInfo, vm.Image, vm.Status, restartPolicyInfo)
|
||||
}
|
||||
|
||||
fmt.Println(table)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/dustin/go-humanize"
|
||||
"github.com/gosuri/uitable"
|
||||
"github.com/spf13/cobra"
|
||||
"time"
|
||||
)
|
||||
|
||||
func newListWorkersCommand() *cobra.Command {
|
||||
|
|
@ -42,7 +43,9 @@ func runListWorkers(cmd *cobra.Command, args []string) error {
|
|||
table.AddRow("Name", "Last seen", "Scheduling paused")
|
||||
|
||||
for _, worker := range workers {
|
||||
table.AddRow(worker.Name, humanize.Time(worker.LastSeen), worker.SchedulingPaused)
|
||||
lastSeenInfo := humanize.RelTime(worker.LastSeen, time.Now(), "ago", "in the future")
|
||||
|
||||
table.AddRow(worker.Name, lastSeenInfo, worker.SchedulingPaused)
|
||||
}
|
||||
|
||||
fmt.Println(table)
|
||||
|
|
|
|||
Loading…
Reference in New Issue