-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add --format to docker-search #440
Conversation
docs/reference/commandline/search.md
Outdated
|
||
### Format the output | ||
|
||
The formatting option (`--format`) will pretty print search output |
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.
pretty-print
docs/reference/commandline/search.md
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/are listed below:/are:
docs/reference/commandline/search.md
Outdated
| `.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/when using/when you use
docs/reference/commandline/search.md
Outdated
| `.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declares. If you use the `table directive, column headers are included as well.
docs/reference/commandline/search.md
Outdated
{% endraw %} | ||
``` | ||
|
||
To search for images in a table format youcan use: |
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.
This example outputs a table format:
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.
LGTM 🐸
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 |
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.
Thanks! LGTM
some minor comments, but nothing blocking merge
cli/command/registry/search.go
Outdated
format := options.format | ||
if len(format) == 0 { | ||
format = formatter.TableFormatKey | ||
} |
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.
minor: we could handle this default is formatter.NewSearchFormat()
cli/command/formatter/search.go
Outdated
} | ||
} | ||
return official | ||
} |
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.
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 ""
}
cli/command/formatter/search_test.go
Outdated
} | ||
} | ||
|
||
func TestSearchContext_Description(t *testing.T) { |
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.
Minor: usually there are no underscores in test names: TestSearchContextDescription
@dnephin no problemo |
@mstanleyjones docs looks good now? |
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.
Approved with one teensy little suggestion for improvement. Thanks! 🙌
docs/reference/commandline/search.md
Outdated
|
||
### Format the output | ||
|
||
The formatting option (`--format`) will pretty-print search output |
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.
s/will pretty-print/pretty-prints
@mstanleyjones done! thanks for your review 👍 🍡 |
GMail renders that 🍡 as a radish! |
docs/reference/commandline/search.md
Outdated
|
||
### Format the output | ||
|
||
The formatting option (`--format`) will pretty-prints search output |
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.
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 ☕️ |
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.
🍦
- What I did
This is a follow-up to Jeremy's PR moby/moby#31539.
This patch adds the
format
flag to thedocker search
command 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.go
andcli/command/formatter/search_test.go
cli/command/registry/search.go
anddocs/reference/commandline/search.md
- How to verify it
Run unit tests
- Description for the changelog
Add
format
todocker search
- A picture of a cute animal (not mandatory but encouraged)