Add --authfile to podman search

Since podman search requires credentials to search private registries,
add the --authfile flag to allow users to pass in credentials from a
different authfile than the default one.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #998
Approved by: rhatdan
This commit is contained in:
umohnani8
2018-06-26 09:59:26 -04:00
committed by Atomic Bot
parent 143ea6e66e
commit c75f4d4e70
3 changed files with 20 additions and 9 deletions

View File

@ -23,6 +23,10 @@ const (
var ( var (
searchFlags = []cli.Flag{ searchFlags = []cli.Flag{
cli.StringFlag{
Name: "authfile",
Usage: "Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json",
},
cli.StringSliceFlag{ cli.StringSliceFlag{
Name: "filter, f", Name: "filter, f",
Usage: "filter output based on conditions provided (default [])", Usage: "filter output based on conditions provided (default [])",
@ -71,10 +75,11 @@ type searchParams struct {
} }
type searchOpts struct { type searchOpts struct {
filter []string filter []string
limit int limit int
noTrunc bool noTrunc bool
format string format string
authfile string
} }
type searchFilterParams struct { type searchFilterParams struct {
@ -105,10 +110,11 @@ func searchCmd(c *cli.Context) error {
format := genSearchFormat(c.String("format")) format := genSearchFormat(c.String("format"))
opts := searchOpts{ opts := searchOpts{
format: format, format: format,
noTrunc: c.Bool("no-trunc"), noTrunc: c.Bool("no-trunc"),
limit: c.Int("limit"), limit: c.Int("limit"),
filter: c.StringSlice("filter"), filter: c.StringSlice("filter"),
authfile: c.String("authfile"),
} }
regAndSkipTLS, err := getRegistriesAndSkipTLS(c) regAndSkipTLS, err := getRegistriesAndSkipTLS(c)
if err != nil { if err != nil {
@ -206,7 +212,7 @@ func getSearchOutput(term string, regAndSkipTLS map[string]bool, opts searchOpts
limit = opts.limit limit = opts.limit
} }
sc := common.GetSystemContext("", "", false) sc := common.GetSystemContext("", opts.authfile, false)
var paramsArr []searchParams var paramsArr []searchParams
for reg, skipTLS := range regAndSkipTLS { for reg, skipTLS := range regAndSkipTLS {
// set the SkipTLSVerify bool depending on the registry being searched through // set the SkipTLSVerify bool depending on the registry being searched through

View File

@ -1299,6 +1299,7 @@ _podman_pull() {
_podman_search() { _podman_search() {
local options_with_args=" local options_with_args="
--authfile
--filter -f --filter -f
--format --format
--limit --limit

View File

@ -29,6 +29,10 @@ using the **--filter** flag.
## OPTIONS ## OPTIONS
**--authfile**
Path of the authentication file. Default is ${XDG_\RUNTIME\_DIR}/containers/auth.json
**--filter, -f** **--filter, -f**
Filter output based on conditions provided (default []) Filter output based on conditions provided (default [])