Skip to content

Commit 86d9696

Browse files
authored
feat(ps): pod list add ready and restarts (#42)
1 parent 733b63a commit 86d9696

4 files changed

Lines changed: 31 additions & 21 deletions

File tree

cmd/ps.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,16 @@ func printProcesses(d *DryccCmd, appID string, input []api.Pods) {
212212
if len(processes) == 0 {
213213
d.Println(fmt.Sprintf("No processes found in %s app.", appID))
214214
} else {
215-
table := d.getDefaultFormatTable([]string{"NAME", "RELEASE", "STATE", "PTYPE", "STARTED"})
215+
table := d.getDefaultFormatTable([]string{"NAME", "RELEASE", "STATE", "PTYPE", "READY", "RESTARTS", "STARTED"})
216216
for _, process := range processes {
217217
for _, pod := range process.PodsList {
218218
table.Append([]string{
219219
pod.Name,
220220
pod.Release,
221221
pod.State,
222222
pod.Type,
223+
pod.Ready,
224+
fmt.Sprintf("%v", pod.Restarts),
223225
pod.Started.Format("2006-01-02T15:04:05MST"),
224226
})
225227
}

cmd/ps_test.go

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,22 @@ func TestPrintProcesses(t *testing.T) {
2323
}
2424
pods := []api.Pods{
2525
{
26-
Release: "v3",
27-
Name: "benign-quilting-web-4084101150-c871y",
28-
Type: "web",
29-
State: "up",
30-
Started: dtime.Time{Time: &d},
26+
Release: "v3",
27+
Name: "benign-quilting-web-4084101150-c871y",
28+
Type: "web",
29+
State: "up",
30+
Ready: "1/1",
31+
Restarts: 0,
32+
Started: dtime.Time{Time: &d},
3133
},
3234
{
33-
Release: "v3",
34-
Name: "benign-quilting-worker-4084101150-c871y",
35-
Type: "worker",
36-
State: "up",
37-
Started: dtime.Time{Time: &d},
35+
Release: "v3",
36+
Name: "benign-quilting-worker-4084101150-c871y",
37+
Type: "worker",
38+
State: "up",
39+
Ready: "1/1",
40+
Restarts: 0,
41+
Started: dtime.Time{Time: &d},
3842
},
3943
}
4044
cf, server, err := testutil.NewTestServerAndClient()
@@ -45,9 +49,9 @@ func TestPrintProcesses(t *testing.T) {
4549

4650
printProcesses(&DryccCmd{WOut: &b, ConfigFile: cf}, "appname", pods)
4751

48-
assert.Equal(t, b.String(), `NAME RELEASE STATE PTYPE STARTED
49-
benign-quilting-web-4084101150-c871y v3 up web 2023-11-15T11:55:16CST
50-
benign-quilting-worker-4084101150-c871y v3 up worker 2023-11-15T11:55:16CST
52+
assert.Equal(t, b.String(), `NAME RELEASE STATE PTYPE READY RESTARTS STARTED
53+
benign-quilting-web-4084101150-c871y v3 up web 1/1 0 2023-11-15T11:55:16CST
54+
benign-quilting-worker-4084101150-c871y v3 up worker 1/1 0 2023-11-15T11:55:16CST
5155
`, "output")
5256
}
5357

@@ -73,6 +77,8 @@ func TestPsList(t *testing.T) {
7377
"type": "web",
7478
"name": "foo-web-4084101150-c871y",
7579
"state": "up",
80+
"ready": "1/1",
81+
"restarts": 0,
7682
"started": "2016-02-13T00:47:52"
7783
}
7884
]
@@ -82,8 +88,8 @@ func TestPsList(t *testing.T) {
8288
err = cmdr.PsList("foo", -1)
8389
assert.NoError(t, err)
8490

85-
assert.Equal(t, b.String(), `NAME RELEASE STATE PTYPE STARTED
86-
foo-web-4084101150-c871y v2 up web 2016-02-13T00:47:52UTC
91+
assert.Equal(t, b.String(), `NAME RELEASE STATE PTYPE READY RESTARTS STARTED
92+
foo-web-4084101150-c871y v2 up web 1/1 0 2016-02-13T00:47:52UTC
8793
`, "output")
8894
}
8995

@@ -180,6 +186,8 @@ func TestPsScale(t *testing.T) {
180186
"type": "web",
181187
"name": "foo-web-4084101150-c871y",
182188
"state": "up",
189+
"ready": "1/1",
190+
"restarts": 0,
183191
"started": "2016-02-13T00:47:52"
184192
}
185193
]
@@ -198,8 +206,8 @@ func TestPsScale(t *testing.T) {
198206
assert.Equal(t, testutil.StripProgress(b.String()), `Scaling processes... but first, coffee!
199207
done in 0s
200208
201-
NAME RELEASE STATE PTYPE STARTED
202-
foo-web-4084101150-c871y v2 up web 2016-02-13T00:47:52UTC
209+
NAME RELEASE STATE PTYPE READY RESTARTS STARTED
210+
foo-web-4084101150-c871y v2 up web 1/1 0 2016-02-13T00:47:52UTC
203211
`, "output")
204212
}
205213

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.22
55
require (
66
github.com/containerd/console v1.0.4
77
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
8-
github.com/drycc/controller-sdk-go v0.0.0-20240522092128-9ed47aac090e
8+
github.com/drycc/controller-sdk-go v0.0.0-20240523052610-656dcb6b9db3
99
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f
1010
github.com/olekukonko/tablewriter v0.0.5
1111
github.com/stretchr/testify v1.9.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
66
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
7-
github.com/drycc/controller-sdk-go v0.0.0-20240522092128-9ed47aac090e h1:4gZBm6S2nsHH2JvX7Ky92XEM0JGPmVv6p6W7Phehz34=
8-
github.com/drycc/controller-sdk-go v0.0.0-20240522092128-9ed47aac090e/go.mod h1:n6eQe1irJqjwLo/7t9+Dhdv6faSESQN+ATnZRBP3/Uc=
7+
github.com/drycc/controller-sdk-go v0.0.0-20240523052610-656dcb6b9db3 h1:eITOqdzcBH/QQVDD/zwHyq5JY1+xXr3MsPg066uR4fk=
8+
github.com/drycc/controller-sdk-go v0.0.0-20240523052610-656dcb6b9db3/go.mod h1:n6eQe1irJqjwLo/7t9+Dhdv6faSESQN+ATnZRBP3/Uc=
99
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f h1:kgjvUQJeAszDoU1Vo4vTTE92KI8Av3JPb6Qn890niXg=
1010
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f/go.mod h1:n+QxGif6ha9CEoxVnlipxb9IdmerybcUSzTEDFkvjiA=
1111
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=

0 commit comments

Comments
 (0)