-
Notifications
You must be signed in to change notification settings - Fork 948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: add no-trunc flag for 'pouch ps' #909
Conversation
cli/ps.go
Outdated
@@ -65,7 +67,12 @@ func (p *PsCommand) runPs(args []string) error { | |||
|
|||
if p.flagQuiet { | |||
for _, c := range containers { | |||
fmt.Println(c.ID[:6]) | |||
switch p.flagNoTrunc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about
id := c.ID[:6]
if p.flagNoTrunc {
id = c.ID
}
fmt.Println(id)
This will make the code more clean,WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. Thx 👍
cli/ps.go
Outdated
@@ -79,7 +86,13 @@ func (p *PsCommand) runPs(args []string) error { | |||
return err | |||
} | |||
|
|||
display.AddRow([]string{c.Names[0], c.ID[:6], c.Status, created + " ago", c.Image, c.HostConfig.Runtime}) | |||
switch p.flagNoTrunc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
Codecov Report
@@ Coverage Diff @@
## master #909 +/- ##
==========================================
- Coverage 13.7% 13.66% -0.04%
==========================================
Files 121 121
Lines 7648 7667 +19
==========================================
Hits 1048 1048
- Misses 6510 6529 +19
Partials 90 90
Continue to review full report at Codecov.
|
@ZouRui89 Thanks for your work, we also should add some cli test case for the |
PTAL. @HusterWan |
test/cli_ps_test.go
Outdated
res := command.PouchRun("ps", "--no-trunc").Assert(c, icmd.Success) | ||
kv := psToKV(res.Combined()) | ||
|
||
c.Assert(kv[name].id, check.HasLen, 64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check maybe too simple:
we may execute pouch inspect CONTAINERNAME
to get the ContainerID, then execute pouch ps -q --no-trunc
to get the the ContainerID again, then we check whether the IDs are equaled. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Your opinion is more thoughtful. :)
Signed-off-by: Zou Rui <21751189@zju.edu.cn>
LGTM |
Signed-off-by: Zou Rui 21751189@zju.edu.cn
Ⅰ. Describe what this PR did
This pr adds no-trunc flag for 'pouch ps' command.
Ⅱ. Does this pull request fix one issue?
fixes #903
Ⅲ. Describe how you did it
add flag
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews