-
Notifications
You must be signed in to change notification settings - Fork 949
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 --format option for pouch ps #2844
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2844 +/- ##
==========================================
- Coverage 69.09% 69.05% -0.04%
==========================================
Files 285 285
Lines 17844 17844
==========================================
- Hits 12330 12323 -7
- Misses 4114 4122 +8
+ Partials 1400 1399 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
We found this is your first time to contribute to Pouch, @aohang111 |
|
@aohang111 Could you use gofmt -s to format your source code as officially style? thanks |
Thank you greatly for your work. @aohang111 |
Could you squash previous four commits into one commits ? |
@allencloud |
1fec4f7
to
10c7c29
Compare
@allencloud ,I have added the integration test. please assign someone to review this code ASAP |
Well done. @aohang111 You've made this happen as your first contribution to pouch project |
@ZYecho ,modified and comments. pls review. thanks |
Thanks for your contribution, just minor suggestions. Good Job! |
5f7d9ee
to
00922cc
Compare
@ZYecho commit again. pls review. thanks |
@ZYecho .done. |
ping @aohang111 |
I also think it's needless to care about the output format in quite mode, please resolve some conflicts ASAP and latter it will be merged into master! |
@@ -5,6 +5,7 @@ import ( | |||
"os" | |||
"strconv" | |||
"text/tabwriter" | |||
"text/template" |
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.
There will be a merge conflict, please handle and rebase it!
if flagNoTrunc { | ||
id = c.ID | ||
} | ||
runningFor, err := utils.FormatTimeInterval(c.Created) |
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.
utils.FormatTimeInterval function have an extra new param, please fix it!
for _, c := range containers { | ||
created, err := utils.FormatTimeInterval(c.Created) | ||
containerContext, err := formatter.NewContainerContext(c, 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.
There is a merge conflict, please handle it!
format = formatter.PreFormat(format) | ||
if tableOrRaw { | ||
containerHeader := formatter.ContainerHeader | ||
p.cli.FormatDisplay(format, tmplH, containerHeader, w) |
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.
Should we handle the possible error at here and follow?
In my opinion, we should care about possible error during parsing the template, at least print some error messages.
} | ||
display.Flush() | ||
w.Flush() |
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.
please use _=w.Flush()
instead of it!
Thank you for your contribution! because you don't response for a long time, I will close this PR and reopen #3037. ❤️ |
Ⅰ. Describe what this PR did
for the issue #2827. CLI compatibility between Pouch and Docker
solve the pouch ps --format option.
if other command(such as pouch history/images/network/volume/stats/version) also need --format option.
can done similarly
Ⅱ. Does this pull request fix one issue?
fixes #2827,
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
have add unit test and integration test
Ⅳ. Describe how to verify it
root@ahsh-main:~/go/src/github.com/alibaba/pouch# pouch ps
Name ID Status Created Image Runtime
58b7de 58b7de Up 40 minutes 40 minutes ago registry.hub.docker.com/library/ubuntu:latest runc
root@ahsh-main:~/go/src/github.com/alibaba/pouch# pouch ps -a --format "table {{.ID}}\t{{.Status}}\t{{.Created}}"
ID Status Created
58b7de Up 11 seconds 11 seconds ago
root@ahsh-main:~/go/src/github.com/alibaba/pouch# pouch ps -a --format "table {{.ID}}\t{{.Status}}\t{{.Created}}\t{{.Name}}"
ID Status Created Name
58b7de Up 40 minutes 40 minutes ago 58b7de
root@ahsh-main:~/go/src/github.com/alibaba/pouch# pouch ps -a --format "raw"
Name:58b7de
ID:58b7de
Status:Up 4 seconds
Created:4 seconds ago
Image:registry.hub.docker.com/library/ubuntu:latest
Runtime:runc
Ⅴ. Special notes for reviews
with @houstar's help.