Add --format to docker-search - #440
Conversation
|
|
||
| ### Format the output | ||
|
|
||
| The formatting option (`--format`) will pretty print search output |
| The formatting option (`--format`) will pretty print search output | ||
| using a Go template. | ||
|
|
||
| Valid placeholders for the Go template are listed below: |
There was a problem hiding this comment.
s/are listed below:/are:
| | `.IsOfficial` | "OK" if image is official | | ||
| | `.IsAutomated` | "OK" if image build was automated | | ||
|
|
||
| When using the `--format` option, the `search` command will either |
There was a problem hiding this comment.
s/when using/when you use
| | `.IsAutomated` | "OK" if image build was automated | | ||
|
|
||
| When using the `--format` option, the `search` command will either | ||
| output the data exactly as the template declares or, when using the |
There was a problem hiding this comment.
declares. If you use the `table directive, column headers are included as well.
| {% endraw %} | ||
| ``` | ||
|
|
||
| To search for images in a table format youcan use: |
There was a problem hiding this comment.
This example outputs a table format:
Codecov Report
@@ Coverage Diff @@
## master #440 +/- ##
==========================================
- Coverage 47.04% 46.84% -0.21%
==========================================
Files 198 198
Lines 16349 16339 -10
==========================================
- Hits 7692 7654 -38
- Misses 8262 8295 +33
+ Partials 395 390 -5 |
dnephin
left a comment
There was a problem hiding this comment.
Thanks! LGTM
some minor comments, but nothing blocking merge
| format := options.format | ||
| if len(format) == 0 { | ||
| format = formatter.TableFormatKey | ||
| } |
There was a problem hiding this comment.
minor: we could handle this default is formatter.NewSearchFormat()
| } | ||
| } | ||
| return official | ||
| } |
There was a problem hiding this comment.
Minor, a function could be used to remove the duplication in IsOfficial() and IsAutomated()
func (c *searchContext) formatBool(value bool) string {
switch {
case value && c.json:
return "true"
case value:
return "[OK]"
case c.json:
return "false"
}
return ""
}| } | ||
| } | ||
|
|
||
| func TestSearchContext_Description(t *testing.T) { |
There was a problem hiding this comment.
Minor: usually there are no underscores in test names: TestSearchContextDescription
|
@dnephin no problemo |
|
@mstanleyjones docs looks good now? |
mdlinville
left a comment
There was a problem hiding this comment.
Approved with one teensy little suggestion for improvement. Thanks! 🙌
|
|
||
| ### Format the output | ||
|
|
||
| The formatting option (`--format`) will pretty-print search output |
There was a problem hiding this comment.
s/will pretty-print/pretty-prints
|
@mstanleyjones done! thanks for your review 👍 🍡 |
|
GMail renders that 🍡 as a radish! |
|
|
||
| ### Format the output | ||
|
|
||
| The formatting option (`--format`) will pretty-prints search output |
There was a problem hiding this comment.
I think you forgot to take out the word "will" here.
Signed-off-by: Jeremy Chambers <jeremy@thehipbot.com> Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
|
@mstanleyjones ☕️ |
[18.03] Updating Changelog for 18.03
- What I did
This is a follow-up to Jeremy's PR moby/moby#31539.
This patch adds the
formatflag to thedocker searchcommand and by that completes moby/moby#30431.Signed-off-by: Jeremy Chambers jeremy@thehipbot.com
Signed-off-by: Boaz Shuster ripcurld.github@gmail.com
- How I did it
cli/command/formatter/search.goandcli/command/formatter/search_test.gocli/command/registry/search.goanddocs/reference/commandline/search.md- How to verify it
Run unit tests
- Description for the changelog
Add
formattodocker search- A picture of a cute animal (not mandatory but encouraged)