diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/containers/ps.go | 4 | ||||
-rw-r--r-- | cmd/podman/machine/list.go | 1 | ||||
-rw-r--r-- | cmd/podman/networks/list.go | 4 | ||||
-rw-r--r-- | cmd/podman/pods/ps.go | 5 | ||||
-rw-r--r-- | cmd/podman/secrets/list.go | 1 | ||||
-rw-r--r-- | cmd/podman/system/service_abi.go | 17 | ||||
-rw-r--r-- | cmd/podman/volumes/list.go | 4 |
7 files changed, 29 insertions, 7 deletions
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index 70bfd3574..97451eb46 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -97,6 +97,7 @@ func listFlagSet(cmd *cobra.Command) { flags.BoolVar(&noTrunc, "no-trunc", false, "Display the extended information") flags.BoolVarP(&listOpts.Pod, "pod", "p", false, "Print the ID and name of the pod the containers are associated with") flags.BoolVarP(&listOpts.Quiet, "quiet", "q", false, "Print the numeric IDs of the containers only") + flags.Bool("noheading", false, "Do not print headers") flags.BoolVarP(&listOpts.Size, "size", "s", false, "Display the total file sizes") flags.BoolVar(&listOpts.Sync, "sync", false, "Sync container state with OCI runtime") @@ -242,7 +243,8 @@ func ps(cmd *cobra.Command, _ []string) error { defer w.Flush() headers := func() error { return nil } - if !(listOpts.Quiet || cmd.Flags().Changed("format")) { + noHeading, _ := cmd.Flags().GetBool("noheading") + if !(noHeading || listOpts.Quiet || cmd.Flags().Changed("format")) { headers = func() error { return tmpl.Execute(w, hdrs) } diff --git a/cmd/podman/machine/list.go b/cmd/podman/machine/list.go index ce4129e87..af4e2c807 100644 --- a/cmd/podman/machine/list.go +++ b/cmd/podman/machine/list.go @@ -61,6 +61,7 @@ func init() { formatFlagName := "format" flags.StringVar(&listFlag.format, formatFlagName, "{{.Name}}\t{{.VMType}}\t{{.Created}}\t{{.LastUp}}\n", "Format volume output using Go template") _ = lsCmd.RegisterFlagCompletionFunc(formatFlagName, completion.AutocompleteNone) + flags.BoolVar(&listFlag.noHeading, "noheading", false, "Do not print headers") } func list(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/networks/list.go b/cmd/podman/networks/list.go index fcbcb6722..bc100da8c 100644 --- a/cmd/podman/networks/list.go +++ b/cmd/podman/networks/list.go @@ -48,6 +48,7 @@ func networkListFlags(flags *pflag.FlagSet) { filterFlagName := "filter" flags.StringArrayVarP(&filters, filterFlagName, "f", nil, "Provide filter values (e.g. 'name=podman')") + flags.Bool("noheading", false, "Do not print headers") _ = networklistCommand.RegisterFlagCompletionFunc(filterFlagName, common.AutocompleteNetworkFilters) } @@ -140,7 +141,8 @@ func templateOut(responses []*entities.NetworkListReport, cmd *cobra.Command) er w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0) defer w.Flush() - if renderHeaders { + noHeading, _ := cmd.Flags().GetBool("noheading") + if !noHeading && renderHeaders { if err := tmpl.Execute(w, headers); err != nil { return err } diff --git a/cmd/podman/pods/ps.go b/cmd/podman/pods/ps.go index aeba80525..a4b6d1afa 100644 --- a/cmd/podman/pods/ps.go +++ b/cmd/podman/pods/ps.go @@ -63,6 +63,7 @@ func init() { flags.StringVar(&psInput.Format, formatFlagName, "", "Pretty-print pods to JSON or using a Go template") _ = psCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteJSONFormat) + flags.Bool("noheading", false, "Do not print headers") flags.BoolVar(&psInput.Namespace, "namespace", false, "Display namespace information of the pod") flags.BoolVar(&psInput.Namespace, "ns", false, "Display namespace information of the pod") flags.BoolVar(&noTrunc, "no-trunc", false, "Do not truncate pod and container IDs") @@ -134,6 +135,10 @@ func pods(cmd *cobra.Command, _ []string) error { renderHeaders = parse.HasTable(psInput.Format) row = report.NormalizeFormat(psInput.Format) } + noHeading, _ := cmd.Flags().GetBool("noheading") + if noHeading { + renderHeaders = false + } format := parse.EnforceRange(row) tmpl, err := template.New("listPods").Parse(format) diff --git a/cmd/podman/secrets/list.go b/cmd/podman/secrets/list.go index 849a8418e..2006fb0ee 100644 --- a/cmd/podman/secrets/list.go +++ b/cmd/podman/secrets/list.go @@ -48,6 +48,7 @@ func init() { formatFlagName := "format" flags.StringVar(&listFlag.format, formatFlagName, "{{.ID}}\t{{.Name}}\t{{.Driver}}\t{{.CreatedAt}}\t{{.UpdatedAt}}\t\n", "Format volume output using Go template") _ = lsCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteJSONFormat) + flags.BoolVar(&listFlag.noHeading, "noheading", false, "Do not print headers") } func ls(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/system/service_abi.go b/cmd/podman/system/service_abi.go index 9e8a9f9b4..364663323 100644 --- a/cmd/podman/system/service_abi.go +++ b/cmd/podman/system/service_abi.go @@ -6,11 +6,13 @@ import ( "context" "net" "os" + "path/filepath" "strings" api "github.com/containers/podman/v3/pkg/api/server" "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/domain/infra" + "github.com/containers/podman/v3/pkg/util" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/pflag" @@ -24,6 +26,17 @@ func restService(opts entities.ServiceOptions, flags *pflag.FlagSet, cfg *entiti ) if opts.URI != "" { + fields := strings.Split(opts.URI, ":") + if len(fields) == 1 { + return errors.Errorf("%s is an invalid socket destination", opts.URI) + } + path := opts.URI + if fields[0] == "unix" { + if path, err = filepath.Abs(fields[1]); err != nil { + return err + } + } + util.SetSocketPath(path) if os.Getenv("LISTEN_FDS") != "" { // If it is activated by systemd, use the first LISTEN_FD (3) // instead of opening the socket file. @@ -34,10 +47,6 @@ func restService(opts entities.ServiceOptions, flags *pflag.FlagSet, cfg *entiti } listener = &l } else { - fields := strings.Split(opts.URI, ":") - if len(fields) == 1 { - return errors.Errorf("%s is an invalid socket destination", opts.URI) - } network := fields[0] address := strings.Join(fields[1:], ":") l, err := net.Listen(network, address) diff --git a/cmd/podman/volumes/list.go b/cmd/podman/volumes/list.go index e04f452d4..0d764e988 100644 --- a/cmd/podman/volumes/list.go +++ b/cmd/podman/volumes/list.go @@ -62,6 +62,7 @@ func init() { flags.StringVar(&cliOpts.Format, formatFlagName, "{{.Driver}}\t{{.Name}}\n", "Format volume output using Go template") _ = lsCommand.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteJSONFormat) + flags.Bool("noheading", false, "Do not print headers") flags.BoolVarP(&cliOpts.Quiet, "quiet", "q", false, "Print volume output in quiet mode") } @@ -94,6 +95,7 @@ func list(cmd *cobra.Command, args []string) error { } func outputTemplate(cmd *cobra.Command, responses []*entities.VolumeListReport) error { + noHeading, _ := cmd.Flags().GetBool("noheading") headers := report.Headers(entities.VolumeListReport{}, map[string]string{ "Name": "VOLUME NAME", }) @@ -111,7 +113,7 @@ func outputTemplate(cmd *cobra.Command, responses []*entities.VolumeListReport) w := tabwriter.NewWriter(os.Stdout, 12, 2, 2, ' ', 0) defer w.Flush() - if !cliOpts.Quiet && !cmd.Flag("format").Changed { + if !(noHeading || cliOpts.Quiet || cmd.Flag("format").Changed) { if err := tmpl.Execute(w, headers); err != nil { return errors.Wrapf(err, "failed to write report column headers") } |