summaryrefslogtreecommitdiff
path: root/cmd/podman/images/search.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/images/search.go')
-rw-r--r--cmd/podman/images/search.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go
index b1a1442a6..774b39d3a 100644
--- a/cmd/podman/images/search.go
+++ b/cmd/podman/images/search.go
@@ -8,6 +8,7 @@ import (
"github.com/containers/common/pkg/auth"
"github.com/containers/common/pkg/report"
"github.com/containers/image/v5/types"
+ "github.com/containers/podman/v2/cmd/podman/parse"
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/pkg/errors"
@@ -98,10 +99,6 @@ func imageSearch(cmd *cobra.Command, args []string) error {
return errors.Errorf("search requires exactly one argument")
}
- if searchOptions.Limit > 100 {
- return errors.Errorf("Limit %d is outside the range of [1, 100]", searchOptions.Limit)
- }
-
if searchOptions.ListTags && len(searchOptions.Filters) != 0 {
return errors.Errorf("filters are not applicable to list tags result")
}
@@ -116,7 +113,7 @@ func imageSearch(cmd *cobra.Command, args []string) error {
if searchOptions.Authfile != "" {
if _, err := os.Stat(searchOptions.Authfile); err != nil {
- return errors.Wrapf(err, "error getting authfile %s", searchOptions.Authfile)
+ return err
}
}
@@ -130,26 +127,30 @@ func imageSearch(cmd *cobra.Command, args []string) error {
}
hdrs := report.Headers(entities.ImageSearchReport{}, nil)
- row := "{{.Index}}\t{{.Name}}\t{{.Description}}\t{{.Stars}}\t{{.Official}}\t{{.Automated}}\n"
- if searchOptions.ListTags {
+ renderHeaders := true
+ var row string
+ switch {
+ case searchOptions.ListTags:
if len(searchOptions.Filters) != 0 {
return errors.Errorf("filters are not applicable to list tags result")
}
row = "{{.Name}}\t{{.Tag}}\n"
- }
- if cmd.Flags().Changed("format") {
+ case cmd.Flags().Changed("format"):
+ renderHeaders = parse.HasTable(searchOptions.Format)
row = report.NormalizeFormat(searchOptions.Format)
+ default:
+ row = "{{.Index}}\t{{.Name}}\t{{.Description}}\t{{.Stars}}\t{{.Official}}\t{{.Automated}}\n"
}
- row = "{{range .}}" + row + "{{end}}"
+ format := parse.EnforceRange(row)
- tmpl, err := template.New("search").Parse(row)
+ tmpl, err := template.New("search").Parse(format)
if err != nil {
return err
}
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
defer w.Flush()
- if !cmd.Flags().Changed("format") {
+ if renderHeaders {
if err := tmpl.Execute(w, hdrs); err != nil {
return errors.Wrapf(err, "failed to write search column headers")
}