Restore --format table header support
Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
parent
e439aec4fa
commit
d60a0ddcc1
|
|
@ -12,6 +12,7 @@ import (
|
||||||
|
|
||||||
tm "github.com/buger/goterm"
|
tm "github.com/buger/goterm"
|
||||||
"github.com/containers/common/pkg/report"
|
"github.com/containers/common/pkg/report"
|
||||||
|
"github.com/containers/podman/v2/cmd/podman/parse"
|
||||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v2/cmd/podman/utils"
|
"github.com/containers/podman/v2/cmd/podman/utils"
|
||||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||||
|
|
@ -42,7 +43,6 @@ var (
|
||||||
}
|
}
|
||||||
filters []string
|
filters []string
|
||||||
noTrunc bool
|
noTrunc bool
|
||||||
defaultHeaders = "CONTAINER ID\tIMAGE\tCOMMAND\tCREATED\tSTATUS\tPORTS\tNAMES"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -91,10 +91,6 @@ func checkFlags(c *cobra.Command) error {
|
||||||
if listOpts.Size || listOpts.Namespace {
|
if listOpts.Size || listOpts.Namespace {
|
||||||
return errors.Errorf("quiet conflicts with size and namespace")
|
return errors.Errorf("quiet conflicts with size and namespace")
|
||||||
}
|
}
|
||||||
if c.Flag("format").Changed && !report.IsJSON(listOpts.Format) {
|
|
||||||
// Quiet is overridden by Go template output.
|
|
||||||
listOpts.Quiet = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Size and namespace conflict with each other
|
// Size and namespace conflict with each other
|
||||||
if listOpts.Size && listOpts.Namespace {
|
if listOpts.Size && listOpts.Namespace {
|
||||||
|
|
@ -155,7 +151,7 @@ func getResponses() ([]entities.ListContainer, error) {
|
||||||
return responses, nil
|
return responses, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ps(cmd *cobra.Command, args []string) error {
|
func ps(cmd *cobra.Command, _ []string) error {
|
||||||
if err := checkFlags(cmd); err != nil {
|
if err := checkFlags(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -180,24 +176,22 @@ func ps(cmd *cobra.Command, args []string) error {
|
||||||
switch {
|
switch {
|
||||||
case report.IsJSON(listOpts.Format):
|
case report.IsJSON(listOpts.Format):
|
||||||
return jsonOut(listContainers)
|
return jsonOut(listContainers)
|
||||||
case listOpts.Quiet:
|
case listOpts.Quiet && !cmd.Flags().Changed("format"):
|
||||||
return quietOut(listContainers)
|
return quietOut(listContainers)
|
||||||
}
|
}
|
||||||
// Output table Watch > 0 will refresh screen
|
|
||||||
|
|
||||||
responses := make([]psReporter, 0, len(listContainers))
|
responses := make([]psReporter, 0, len(listContainers))
|
||||||
for _, r := range listContainers {
|
for _, r := range listContainers {
|
||||||
responses = append(responses, psReporter{r})
|
responses = append(responses, psReporter{r})
|
||||||
}
|
}
|
||||||
|
|
||||||
var headers, format string
|
hdrs, format := createPsOut()
|
||||||
if cmd.Flags().Changed("format") {
|
if cmd.Flags().Changed("format") {
|
||||||
headers = ""
|
|
||||||
format = report.NormalizeFormat(listOpts.Format)
|
format = report.NormalizeFormat(listOpts.Format)
|
||||||
} else {
|
format = parse.EnforceRange(format)
|
||||||
headers, format = createPsOut()
|
|
||||||
}
|
}
|
||||||
format = headers + "{{range . }}" + format + "{{end}}"
|
ns := strings.NewReplacer(".Namespaces.", ".")
|
||||||
|
format = ns.Replace(format)
|
||||||
|
|
||||||
tmpl, err := template.New("listContainers").Parse(format)
|
tmpl, err := template.New("listContainers").Parse(format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -206,13 +200,19 @@ func ps(cmd *cobra.Command, args []string) error {
|
||||||
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
||||||
defer w.Flush()
|
defer w.Flush()
|
||||||
|
|
||||||
if listOpts.Watch > 0 {
|
headers := func() error { return nil }
|
||||||
for {
|
if !(listOpts.Quiet || cmd.Flags().Changed("format")) {
|
||||||
var responses []psReporter
|
headers = func() error {
|
||||||
tm.Clear()
|
return tmpl.Execute(w, hdrs)
|
||||||
tm.MoveCursor(1, 1)
|
}
|
||||||
tm.Flush()
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
// Output table Watch > 0 will refresh screen
|
||||||
|
case listOpts.Watch > 0:
|
||||||
|
// responses will grow to the largest number of processes reported on, but will not thrash the gc
|
||||||
|
var responses []psReporter
|
||||||
|
for ; ; responses = responses[:0] {
|
||||||
if ctnrs, err := getResponses(); err != nil {
|
if ctnrs, err := getResponses(); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -221,18 +221,27 @@ func ps(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tm.Clear()
|
||||||
|
tm.MoveCursor(1, 1)
|
||||||
|
tm.Flush()
|
||||||
|
|
||||||
|
if err := headers(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := tmpl.Execute(w, responses); err != nil {
|
if err := tmpl.Execute(w, responses); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := w.Flush(); err != nil {
|
if err := w.Flush(); err != nil {
|
||||||
|
// we usually do not care about Flush() failures but here do not loop if Flush() has failed
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(time.Duration(listOpts.Watch) * time.Second)
|
time.Sleep(time.Duration(listOpts.Watch) * time.Second)
|
||||||
tm.Clear()
|
|
||||||
tm.MoveCursor(1, 1)
|
|
||||||
tm.Flush()
|
|
||||||
}
|
}
|
||||||
} else if listOpts.Watch < 1 {
|
default:
|
||||||
|
if err := headers(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := tmpl.Execute(w, responses); err != nil {
|
if err := tmpl.Execute(w, responses); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -241,30 +250,36 @@ func ps(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// cannot use report.Headers() as it doesn't support structures as fields
|
// cannot use report.Headers() as it doesn't support structures as fields
|
||||||
func createPsOut() (string, string) {
|
func createPsOut() ([]map[string]string, string) {
|
||||||
|
hdrs := report.Headers(psReporter{}, map[string]string{
|
||||||
|
"Cgroup": "cgroupns",
|
||||||
|
"CreatedHuman": "created",
|
||||||
|
"ID": "container id",
|
||||||
|
"IPC": "ipc",
|
||||||
|
"MNT": "mnt",
|
||||||
|
"NET": "net",
|
||||||
|
"PIDNS": "pidns",
|
||||||
|
"Pod": "pod id",
|
||||||
|
"PodName": "podname", // undo camelcase space break
|
||||||
|
"UTS": "uts",
|
||||||
|
"User": "userns",
|
||||||
|
})
|
||||||
|
|
||||||
var row string
|
var row string
|
||||||
if listOpts.Namespace {
|
if listOpts.Namespace {
|
||||||
headers := "CONTAINER ID\tNAMES\tPID\tCGROUPNS\tIPC\tMNT\tNET\tPIDNS\tUSERNS\tUTS\n"
|
row = "{{.ID}}\t{{.Names}}\t{{.Pid}}\t{{.Namespaces.Cgroup}}\t{{.Namespaces.IPC}}\t{{.Namespaces.MNT}}\t{{.Namespaces.NET}}\t{{.Namespaces.PIDNS}}\t{{.Namespaces.User}}\t{{.Namespaces.UTS}}"
|
||||||
row := "{{.ID}}\t{{.Names}}\t{{.Pid}}\t{{.Namespaces.Cgroup}}\t{{.Namespaces.IPC}}\t{{.Namespaces.MNT}}\t{{.Namespaces.NET}}\t{{.Namespaces.PIDNS}}\t{{.Namespaces.User}}\t{{.Namespaces.UTS}}\n"
|
} else {
|
||||||
return headers, row
|
row = "{{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedHuman}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}"
|
||||||
}
|
|
||||||
headers := defaultHeaders
|
|
||||||
row += "{{.ID}}"
|
|
||||||
row += "\t{{.Image}}\t{{.Command}}\t{{.CreatedHuman}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}"
|
|
||||||
|
|
||||||
if listOpts.Pod {
|
if listOpts.Pod {
|
||||||
headers += "\tPOD ID\tPODNAME"
|
|
||||||
row += "\t{{.Pod}}\t{{.PodName}}"
|
row += "\t{{.Pod}}\t{{.PodName}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
if listOpts.Size {
|
if listOpts.Size {
|
||||||
headers += "\tSIZE"
|
|
||||||
row += "\t{{.Size}}"
|
row += "\t{{.Size}}"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
headers = report.NormalizeFormat(headers)
|
return hdrs, "{{range .}}" + row + "\n{{end}}"
|
||||||
row = report.NormalizeFormat(row)
|
|
||||||
return headers, row
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type psReporter struct {
|
type psReporter struct {
|
||||||
|
|
@ -367,6 +382,41 @@ func (l psReporter) CreatedHuman() string {
|
||||||
return units.HumanDuration(time.Since(time.Unix(l.Created, 0))) + " ago"
|
return units.HumanDuration(time.Since(time.Unix(l.Created, 0))) + " ago"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cgroup exposes .Namespaces.Cgroup
|
||||||
|
func (l psReporter) Cgroup() string {
|
||||||
|
return l.Namespaces.Cgroup
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPC exposes .Namespaces.IPC
|
||||||
|
func (l psReporter) IPC() string {
|
||||||
|
return l.Namespaces.IPC
|
||||||
|
}
|
||||||
|
|
||||||
|
// MNT exposes .Namespaces.MNT
|
||||||
|
func (l psReporter) MNT() string {
|
||||||
|
return l.Namespaces.MNT
|
||||||
|
}
|
||||||
|
|
||||||
|
// NET exposes .Namespaces.NET
|
||||||
|
func (l psReporter) NET() string {
|
||||||
|
return l.Namespaces.NET
|
||||||
|
}
|
||||||
|
|
||||||
|
// PIDNS exposes .Namespaces.PIDNS
|
||||||
|
func (l psReporter) PIDNS() string {
|
||||||
|
return l.Namespaces.PIDNS
|
||||||
|
}
|
||||||
|
|
||||||
|
// User exposes .Namespaces.User
|
||||||
|
func (l psReporter) User() string {
|
||||||
|
return l.Namespaces.User
|
||||||
|
}
|
||||||
|
|
||||||
|
// UTS exposes .Namespaces.UTS
|
||||||
|
func (l psReporter) UTS() string {
|
||||||
|
return l.Namespaces.UTS
|
||||||
|
}
|
||||||
|
|
||||||
// portsToString converts the ports used to a string of the from "port1, port2"
|
// portsToString converts the ports used to a string of the from "port1, port2"
|
||||||
// and also groups a continuous list of ports into a readable format.
|
// and also groups a continuous list of ports into a readable format.
|
||||||
func portsToString(ports []ocicni.PortMapping) string {
|
func portsToString(ports []ocicni.PortMapping) string {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
tm "github.com/buger/goterm"
|
tm "github.com/buger/goterm"
|
||||||
"github.com/containers/common/pkg/report"
|
"github.com/containers/common/pkg/report"
|
||||||
|
"github.com/containers/podman/v2/cmd/podman/parse"
|
||||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||||
"github.com/containers/podman/v2/libpod/define"
|
"github.com/containers/podman/v2/libpod/define"
|
||||||
|
|
@ -59,7 +60,6 @@ type statsOptionsCLI struct {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
statsOptions statsOptionsCLI
|
statsOptions statsOptionsCLI
|
||||||
defaultStatsRow = "{{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}\t{{.NetIO}}\t{{.BlockIO}}\t{{.PIDS}}\n"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func statFlags(flags *pflag.FlagSet) {
|
func statFlags(flags *pflag.FlagSet) {
|
||||||
|
|
@ -159,19 +159,19 @@ func outputStats(reports []define.ContainerStats) error {
|
||||||
if report.IsJSON(statsOptions.Format) {
|
if report.IsJSON(statsOptions.Format) {
|
||||||
return outputJSON(stats)
|
return outputJSON(stats)
|
||||||
}
|
}
|
||||||
format := defaultStatsRow
|
format := "{{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}\t{{.NetIO}}\t{{.BlockIO}}\t{{.PIDS}}\n"
|
||||||
|
|
||||||
if len(statsOptions.Format) > 0 {
|
if len(statsOptions.Format) > 0 {
|
||||||
format = report.NormalizeFormat(statsOptions.Format)
|
format = report.NormalizeFormat(statsOptions.Format)
|
||||||
} else if len(statsOptions.Format) < 1 {
|
|
||||||
format = defaultStatsRow
|
|
||||||
}
|
}
|
||||||
format = "{{range . }}" + format + "{{end}}"
|
format = parse.EnforceRange(format)
|
||||||
|
|
||||||
tmpl, err := template.New("stats").Parse(format)
|
tmpl, err := template.New("stats").Parse(format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
||||||
|
defer w.Flush()
|
||||||
|
|
||||||
if len(statsOptions.Format) < 1 {
|
if len(statsOptions.Format) < 1 {
|
||||||
if err := tmpl.Execute(w, headers); err != nil {
|
if err := tmpl.Execute(w, headers); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -180,9 +180,6 @@ func outputStats(reports []define.ContainerStats) error {
|
||||||
if err := tmpl.Execute(w, stats); err != nil {
|
if err := tmpl.Execute(w, stats); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := w.Flush(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/report"
|
"github.com/containers/common/pkg/report"
|
||||||
|
"github.com/containers/podman/v2/cmd/podman/parse"
|
||||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
|
|
@ -119,7 +120,7 @@ func history(cmd *cobra.Command, args []string) error {
|
||||||
case opts.quiet:
|
case opts.quiet:
|
||||||
row = "{{.ID}}\n"
|
row = "{{.ID}}\n"
|
||||||
}
|
}
|
||||||
format := "{{range . }}" + row + "{{end}}"
|
format := parse.EnforceRange(row)
|
||||||
|
|
||||||
tmpl, err := template.New("report").Parse(format)
|
tmpl, err := template.New("report").Parse(format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import (
|
||||||
|
|
||||||
"github.com/containers/common/pkg/report"
|
"github.com/containers/common/pkg/report"
|
||||||
"github.com/containers/image/v5/docker/reference"
|
"github.com/containers/image/v5/docker/reference"
|
||||||
|
"github.com/containers/podman/v2/cmd/podman/parse"
|
||||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
|
|
@ -105,10 +106,10 @@ func images(cmd *cobra.Command, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case listFlag.quiet:
|
|
||||||
return writeID(imgs)
|
|
||||||
case report.IsJSON(listFlag.format):
|
case report.IsJSON(listFlag.format):
|
||||||
return writeJSON(imgs)
|
return writeJSON(imgs)
|
||||||
|
case listFlag.quiet:
|
||||||
|
return writeID(imgs)
|
||||||
default:
|
default:
|
||||||
if cmd.Flag("format").Changed {
|
if cmd.Flag("format").Changed {
|
||||||
listFlag.noHeading = true // V1 compatibility
|
listFlag.noHeading = true // V1 compatibility
|
||||||
|
|
@ -171,9 +172,13 @@ func writeTemplate(imgs []imageReporter) error {
|
||||||
} else {
|
} else {
|
||||||
row = report.NormalizeFormat(listFlag.format)
|
row = report.NormalizeFormat(listFlag.format)
|
||||||
}
|
}
|
||||||
|
format := parse.EnforceRange(row)
|
||||||
|
|
||||||
|
tmpl, err := template.New("list").Parse(format)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
format := "{{range . }}" + row + "{{end}}"
|
|
||||||
tmpl := template.Must(template.New("list").Parse(format))
|
|
||||||
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
||||||
defer w.Flush()
|
defer w.Flush()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/containers/common/pkg/auth"
|
"github.com/containers/common/pkg/auth"
|
||||||
"github.com/containers/common/pkg/report"
|
"github.com/containers/common/pkg/report"
|
||||||
"github.com/containers/image/v5/types"
|
"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/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
@ -130,26 +131,30 @@ func imageSearch(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
hdrs := report.Headers(entities.ImageSearchReport{}, nil)
|
hdrs := report.Headers(entities.ImageSearchReport{}, nil)
|
||||||
row := "{{.Index}}\t{{.Name}}\t{{.Description}}\t{{.Stars}}\t{{.Official}}\t{{.Automated}}\n"
|
renderHeaders := true
|
||||||
if searchOptions.ListTags {
|
var row string
|
||||||
|
switch {
|
||||||
|
case searchOptions.ListTags:
|
||||||
if len(searchOptions.Filters) != 0 {
|
if len(searchOptions.Filters) != 0 {
|
||||||
return errors.Errorf("filters are not applicable to list tags result")
|
return errors.Errorf("filters are not applicable to list tags result")
|
||||||
}
|
}
|
||||||
row = "{{.Name}}\t{{.Tag}}\n"
|
row = "{{.Name}}\t{{.Tag}}\n"
|
||||||
}
|
case cmd.Flags().Changed("format"):
|
||||||
if cmd.Flags().Changed("format") {
|
renderHeaders = parse.HasTable(searchOptions.Format)
|
||||||
row = report.NormalizeFormat(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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
||||||
defer w.Flush()
|
defer w.Flush()
|
||||||
|
|
||||||
if !cmd.Flags().Changed("format") {
|
if renderHeaders {
|
||||||
if err := tmpl.Execute(w, hdrs); err != nil {
|
if err := tmpl.Execute(w, hdrs); err != nil {
|
||||||
return errors.Wrapf(err, "failed to write search column headers")
|
return errors.Wrapf(err, "failed to write search column headers")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/containers/common/pkg/report"
|
||||||
|
"github.com/containers/podman/v2/cmd/podman/parse"
|
||||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||||
"github.com/containers/podman/v2/libpod/network"
|
"github.com/containers/podman/v2/libpod/network"
|
||||||
|
|
@ -30,8 +32,6 @@ var (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
networkListOptions entities.NetworkListOptions
|
networkListOptions entities.NetworkListOptions
|
||||||
headers = "NAME\tVERSION\tPLUGINS\n"
|
|
||||||
defaultListRow = "{{.Name}}\t{{.Version}}\t{{.Plugins}}\n"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func networkListFlags(flags *pflag.FlagSet) {
|
func networkListFlags(flags *pflag.FlagSet) {
|
||||||
|
|
@ -66,13 +66,12 @@ func networkList(cmd *cobra.Command, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// quiet means we only print the network names
|
switch {
|
||||||
if networkListOptions.Quiet {
|
case report.IsJSON(networkListOptions.Format):
|
||||||
return quietOut(responses)
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.ToLower(networkListOptions.Format) == "json" {
|
|
||||||
return jsonOut(responses)
|
return jsonOut(responses)
|
||||||
|
case networkListOptions.Quiet:
|
||||||
|
// quiet means we only print the network names
|
||||||
|
return quietOut(responses)
|
||||||
}
|
}
|
||||||
|
|
||||||
nlprs := make([]ListPrintReports, 0, len(responses))
|
nlprs := make([]ListPrintReports, 0, len(responses))
|
||||||
|
|
@ -80,27 +79,32 @@ func networkList(cmd *cobra.Command, args []string) error {
|
||||||
nlprs = append(nlprs, ListPrintReports{r})
|
nlprs = append(nlprs, ListPrintReports{r})
|
||||||
}
|
}
|
||||||
|
|
||||||
row := networkListOptions.Format
|
headers := report.Headers(ListPrintReports{}, map[string]string{
|
||||||
if len(row) < 1 {
|
"CNIVersion": "version",
|
||||||
row = defaultListRow
|
"Plugins": "plugins",
|
||||||
}
|
})
|
||||||
if !strings.HasSuffix(row, "\n") {
|
renderHeaders := true
|
||||||
row += "\n"
|
row := "{{.Name}}\t{{.Version}}\t{{.Plugins}}\n"
|
||||||
|
if cmd.Flags().Changed("format") {
|
||||||
|
renderHeaders = parse.HasTable(networkListOptions.Format)
|
||||||
|
row = report.NormalizeFormat(networkListOptions.Format)
|
||||||
}
|
}
|
||||||
|
format := parse.EnforceRange(row)
|
||||||
|
|
||||||
format := "{{range . }}" + row + "{{end}}"
|
|
||||||
if !cmd.Flag("format").Changed {
|
|
||||||
format = headers + format
|
|
||||||
}
|
|
||||||
tmpl, err := template.New("listNetworks").Parse(format)
|
tmpl, err := template.New("listNetworks").Parse(format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
||||||
if err := tmpl.Execute(w, nlprs); err != nil {
|
defer w.Flush()
|
||||||
|
|
||||||
|
if renderHeaders {
|
||||||
|
if err := tmpl.Execute(w, headers); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return w.Flush()
|
|
||||||
|
}
|
||||||
|
return tmpl.Execute(w, nlprs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func quietOut(responses []*entities.NetworkListReport) error {
|
func quietOut(responses []*entities.NetworkListReport) error {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package parse
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var rangeRegex = regexp.MustCompile(`{{\s*range\s*\.\s*}}.*{{\s*end\s*}}`)
|
||||||
|
|
||||||
|
// TODO move to github.com/containers/common/pkg/report
|
||||||
|
// EnforceRange ensures that the format string contains a range
|
||||||
|
func EnforceRange(format string) string {
|
||||||
|
if !rangeRegex.MatchString(format) {
|
||||||
|
return "{{range .}}" + format + "{{end}}"
|
||||||
|
}
|
||||||
|
return format
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnforceRange ensures that the format string contains a range
|
||||||
|
func HasTable(format string) bool {
|
||||||
|
return strings.HasPrefix(format, "table ")
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package parse
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestEnforceRange(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{"{{range .}}{{.ID}}{{end}}", "{{range .}}{{.ID}}{{end}}"},
|
||||||
|
{"{{.ID}}", "{{range .}}{{.ID}}{{end}}"},
|
||||||
|
{"{{ range . }}{{ .ID }}{{ end }}", "{{ range . }}{{ .ID }}{{ end }}"},
|
||||||
|
// EnforceRange does not verify syntax or semantics, that will happen later
|
||||||
|
{"{{range .}}{{.ID}}", "{{range .}}{{range .}}{{.ID}}{{end}}"},
|
||||||
|
{".ID", "{{range .}}.ID{{end}}"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tests {
|
||||||
|
tc := tc
|
||||||
|
label := "TestEnforceRange_" + tc.input
|
||||||
|
t.Run(label, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
assert.Equal(t, tc.expected, EnforceRange(tc.input))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/report"
|
"github.com/containers/common/pkg/report"
|
||||||
|
"github.com/containers/podman/v2/cmd/podman/parse"
|
||||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||||
|
|
@ -113,20 +114,22 @@ func pods(cmd *cobra.Command, _ []string) error {
|
||||||
"Created": "CREATED",
|
"Created": "CREATED",
|
||||||
"InfraID": "INFRA ID",
|
"InfraID": "INFRA ID",
|
||||||
})
|
})
|
||||||
|
renderHeaders := true
|
||||||
row := podPsFormat()
|
row := podPsFormat()
|
||||||
if cmd.Flags().Changed("format") {
|
if cmd.Flags().Changed("format") {
|
||||||
|
renderHeaders = parse.HasTable(psInput.Format)
|
||||||
row = report.NormalizeFormat(psInput.Format)
|
row = report.NormalizeFormat(psInput.Format)
|
||||||
}
|
}
|
||||||
row = "{{range . }}" + row + "{{end}}"
|
format := parse.EnforceRange(row)
|
||||||
|
|
||||||
tmpl, err := template.New("listPods").Parse(row)
|
tmpl, err := template.New("listPods").Parse(format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
||||||
defer w.Flush()
|
defer w.Flush()
|
||||||
|
|
||||||
if !psInput.Quiet && !cmd.Flag("format").Changed {
|
if renderHeaders {
|
||||||
if err := tmpl.Execute(w, headers); err != nil {
|
if err := tmpl.Execute(w, headers); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/buger/goterm"
|
"github.com/buger/goterm"
|
||||||
"github.com/containers/common/pkg/report"
|
"github.com/containers/common/pkg/report"
|
||||||
|
"github.com/containers/podman/v2/cmd/podman/parse"
|
||||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||||
|
|
@ -135,7 +136,7 @@ func printFormattedPodStatsLines(headerNames []map[string]string, row string, st
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
row = "{{range .}}" + row + "{{end}}"
|
row = parse.EnforceRange(row)
|
||||||
|
|
||||||
tmpl, err := template.New("pod stats").Parse(row)
|
tmpl, err := template.New("pod stats").Parse(row)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/report"
|
"github.com/containers/common/pkg/report"
|
||||||
|
"github.com/containers/podman/v2/cmd/podman/parse"
|
||||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||||
|
|
@ -55,7 +56,7 @@ func df(cmd *cobra.Command, args []string) error {
|
||||||
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
|
||||||
|
|
||||||
if dfOptions.Verbose {
|
if dfOptions.Verbose {
|
||||||
return printVerbose(cmd, w, reports)
|
return printVerbose(w, cmd, reports)
|
||||||
}
|
}
|
||||||
return printSummary(w, cmd, reports)
|
return printSummary(w, cmd, reports)
|
||||||
}
|
}
|
||||||
|
|
@ -131,20 +132,16 @@ func printSummary(w *tabwriter.Writer, cmd *cobra.Command, reports *entities.Sys
|
||||||
"Size": "SIZE",
|
"Size": "SIZE",
|
||||||
"Reclaimable": "RECLAIMABLE",
|
"Reclaimable": "RECLAIMABLE",
|
||||||
})
|
})
|
||||||
|
|
||||||
row := "{{.Type}}\t{{.Total}}\t{{.Active}}\t{{.Size}}\t{{.Reclaimable}}\n"
|
row := "{{.Type}}\t{{.Total}}\t{{.Active}}\t{{.Size}}\t{{.Reclaimable}}\n"
|
||||||
if cmd.Flags().Changed("format") {
|
if cmd.Flags().Changed("format") {
|
||||||
row = report.NormalizeFormat(dfOptions.Format)
|
row = report.NormalizeFormat(dfOptions.Format)
|
||||||
}
|
}
|
||||||
row = "{{range . }}" + row + "{{end}}"
|
return writeTemplate(w, cmd, hdrs, row, dfSummaries)
|
||||||
|
|
||||||
return writeTemplate(cmd, w, hdrs, row, dfSummaries)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func printVerbose(cmd *cobra.Command, w *tabwriter.Writer, reports *entities.SystemDfReport) error {
|
func printVerbose(w *tabwriter.Writer, cmd *cobra.Command, reports *entities.SystemDfReport) error {
|
||||||
defer w.Flush()
|
defer w.Flush()
|
||||||
|
|
||||||
// Images
|
|
||||||
fmt.Fprint(w, "Images space usage:\n\n")
|
fmt.Fprint(w, "Images space usage:\n\n")
|
||||||
// convert to dfImage for output
|
// convert to dfImage for output
|
||||||
dfImages := make([]*dfImage, 0, len(reports.Images))
|
dfImages := make([]*dfImage, 0, len(reports.Images))
|
||||||
|
|
@ -157,14 +154,11 @@ func printVerbose(cmd *cobra.Command, w *tabwriter.Writer, reports *entities.Sys
|
||||||
"UniqueSize": "UNIQUE SIZE",
|
"UniqueSize": "UNIQUE SIZE",
|
||||||
})
|
})
|
||||||
imageRow := "{{.Repository}}\t{{.Tag}}\t{{.ImageID}}\t{{.Created}}\t{{.Size}}\t{{.SharedSize}}\t{{.UniqueSize}}\t{{.Containers}}\n"
|
imageRow := "{{.Repository}}\t{{.Tag}}\t{{.ImageID}}\t{{.Created}}\t{{.Size}}\t{{.SharedSize}}\t{{.UniqueSize}}\t{{.Containers}}\n"
|
||||||
format := "{{range . }}" + imageRow + "{{end}}"
|
if err := writeTemplate(w, cmd, hdrs, imageRow, dfImages); err != nil {
|
||||||
if err := writeTemplate(cmd, w, hdrs, format, dfImages); err != nil {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Containers
|
|
||||||
fmt.Fprint(w, "\nContainers space usage:\n\n")
|
fmt.Fprint(w, "\nContainers space usage:\n\n")
|
||||||
|
|
||||||
// convert to dfContainers for output
|
// convert to dfContainers for output
|
||||||
dfContainers := make([]*dfContainer, 0, len(reports.Containers))
|
dfContainers := make([]*dfContainer, 0, len(reports.Containers))
|
||||||
for _, d := range reports.Containers {
|
for _, d := range reports.Containers {
|
||||||
|
|
@ -176,14 +170,11 @@ func printVerbose(cmd *cobra.Command, w *tabwriter.Writer, reports *entities.Sys
|
||||||
"RWSize": "SIZE",
|
"RWSize": "SIZE",
|
||||||
})
|
})
|
||||||
containerRow := "{{.ContainerID}}\t{{.Image}}\t{{.Command}}\t{{.LocalVolumes}}\t{{.RWSize}}\t{{.Created}}\t{{.Status}}\t{{.Names}}\n"
|
containerRow := "{{.ContainerID}}\t{{.Image}}\t{{.Command}}\t{{.LocalVolumes}}\t{{.RWSize}}\t{{.Created}}\t{{.Status}}\t{{.Names}}\n"
|
||||||
format = "{{range . }}" + containerRow + "{{end}}"
|
if err := writeTemplate(w, cmd, hdrs, containerRow, dfContainers); err != nil {
|
||||||
if err := writeTemplate(cmd, w, hdrs, format, dfContainers); err != nil {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Volumes
|
|
||||||
fmt.Fprint(w, "\nLocal Volumes space usage:\n\n")
|
fmt.Fprint(w, "\nLocal Volumes space usage:\n\n")
|
||||||
|
|
||||||
dfVolumes := make([]*dfVolume, 0, len(reports.Volumes))
|
dfVolumes := make([]*dfVolume, 0, len(reports.Volumes))
|
||||||
// convert to dfVolume for output
|
// convert to dfVolume for output
|
||||||
for _, d := range reports.Volumes {
|
for _, d := range reports.Volumes {
|
||||||
|
|
@ -193,14 +184,13 @@ func printVerbose(cmd *cobra.Command, w *tabwriter.Writer, reports *entities.Sys
|
||||||
"VolumeName": "VOLUME NAME",
|
"VolumeName": "VOLUME NAME",
|
||||||
})
|
})
|
||||||
volumeRow := "{{.VolumeName}}\t{{.Links}}\t{{.Size}}\n"
|
volumeRow := "{{.VolumeName}}\t{{.Links}}\t{{.Size}}\n"
|
||||||
format = "{{range . }}" + volumeRow + "{{end}}"
|
return writeTemplate(w, cmd, hdrs, volumeRow, dfVolumes)
|
||||||
return writeTemplate(cmd, w, hdrs, format, dfVolumes)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeTemplate(cmd *cobra.Command, w *tabwriter.Writer, hdrs []map[string]string, format string,
|
func writeTemplate(w *tabwriter.Writer, cmd *cobra.Command, hdrs []map[string]string, format string, output interface{}) error {
|
||||||
output interface{}) error {
|
|
||||||
defer w.Flush()
|
defer w.Flush()
|
||||||
|
|
||||||
|
format = parse.EnforceRange(format)
|
||||||
tmpl, err := template.New("df").Parse(format)
|
tmpl, err := template.New("df").Parse(format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/report"
|
"github.com/containers/common/pkg/report"
|
||||||
|
"github.com/containers/podman/v2/cmd/podman/parse"
|
||||||
"github.com/containers/podman/v2/cmd/podman/registry"
|
"github.com/containers/podman/v2/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v2/cmd/podman/validate"
|
"github.com/containers/podman/v2/cmd/podman/validate"
|
||||||
"github.com/containers/podman/v2/pkg/domain/entities"
|
"github.com/containers/podman/v2/pkg/domain/entities"
|
||||||
|
|
@ -91,9 +92,9 @@ func outputTemplate(cmd *cobra.Command, responses []*entities.VolumeListReport)
|
||||||
if cliOpts.Quiet {
|
if cliOpts.Quiet {
|
||||||
row = "{{.Name}}\n"
|
row = "{{.Name}}\n"
|
||||||
}
|
}
|
||||||
row = "{{range . }}" + row + "{{end}}"
|
format := parse.EnforceRange(row)
|
||||||
|
|
||||||
tmpl, err := template.New("list volume").Parse(row)
|
tmpl, err := template.New("list volume").Parse(format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/containers/storage/pkg/parsers/kernel"
|
"github.com/containers/storage/pkg/parsers/kernel"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/onsi/gomega/gexec"
|
. "github.com/onsi/gomega/gexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -48,7 +48,7 @@ type PodmanTest struct {
|
||||||
|
|
||||||
// PodmanSession wraps the gexec.session so we can extend it
|
// PodmanSession wraps the gexec.session so we can extend it
|
||||||
type PodmanSession struct {
|
type PodmanSession struct {
|
||||||
*gexec.Session
|
*Session
|
||||||
}
|
}
|
||||||
|
|
||||||
// HostOS is a simple struct for the test os
|
// HostOS is a simple struct for the test os
|
||||||
|
|
@ -96,7 +96,7 @@ func (p *PodmanTest) PodmanAsUserBase(args []string, uid, gid uint32, cwd string
|
||||||
|
|
||||||
command.ExtraFiles = extraFiles
|
command.ExtraFiles = extraFiles
|
||||||
|
|
||||||
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
|
session, err := Start(command, GinkgoWriter, GinkgoWriter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fail(fmt.Sprintf("unable to run podman command: %s\n%v", strings.Join(podmanOptions, " "), err))
|
Fail(fmt.Sprintf("unable to run podman command: %s\n%v", strings.Join(podmanOptions, " "), err))
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +125,7 @@ func (p *PodmanTest) NumberOfContainersRunning() int {
|
||||||
var containers []string
|
var containers []string
|
||||||
ps := p.PodmanBase([]string{"ps", "-q"}, false, true)
|
ps := p.PodmanBase([]string{"ps", "-q"}, false, true)
|
||||||
ps.WaitWithDefaultTimeout()
|
ps.WaitWithDefaultTimeout()
|
||||||
Expect(ps.ExitCode()).To(Equal(0))
|
Expect(ps).Should(Exit(0))
|
||||||
for _, i := range ps.OutputToStringArray() {
|
for _, i := range ps.OutputToStringArray() {
|
||||||
if i != "" {
|
if i != "" {
|
||||||
containers = append(containers, i)
|
containers = append(containers, i)
|
||||||
|
|
@ -318,7 +318,7 @@ func (s *PodmanSession) IsJSONOutputValid() bool {
|
||||||
|
|
||||||
// WaitWithDefaultTimeout waits for process finished with defaultWaitTimeout
|
// WaitWithDefaultTimeout waits for process finished with defaultWaitTimeout
|
||||||
func (s *PodmanSession) WaitWithDefaultTimeout() {
|
func (s *PodmanSession) WaitWithDefaultTimeout() {
|
||||||
Eventually(s, defaultWaitTimeout).Should(gexec.Exit())
|
Eventually(s, defaultWaitTimeout).Should(Exit())
|
||||||
os.Stdout.Sync()
|
os.Stdout.Sync()
|
||||||
os.Stderr.Sync()
|
os.Stderr.Sync()
|
||||||
fmt.Println("output:", s.OutputToString())
|
fmt.Println("output:", s.OutputToString())
|
||||||
|
|
@ -332,7 +332,7 @@ func CreateTempDirInTempDir() (string, error) {
|
||||||
// SystemExec is used to exec a system command to check its exit code or output
|
// SystemExec is used to exec a system command to check its exit code or output
|
||||||
func SystemExec(command string, args []string) *PodmanSession {
|
func SystemExec(command string, args []string) *PodmanSession {
|
||||||
c := exec.Command(command, args...)
|
c := exec.Command(command, args...)
|
||||||
session, err := gexec.Start(c, GinkgoWriter, GinkgoWriter)
|
session, err := Start(c, GinkgoWriter, GinkgoWriter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " ")))
|
Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " ")))
|
||||||
}
|
}
|
||||||
|
|
@ -343,7 +343,7 @@ func SystemExec(command string, args []string) *PodmanSession {
|
||||||
// StartSystemExec is used to start exec a system command
|
// StartSystemExec is used to start exec a system command
|
||||||
func StartSystemExec(command string, args []string) *PodmanSession {
|
func StartSystemExec(command string, args []string) *PodmanSession {
|
||||||
c := exec.Command(command, args...)
|
c := exec.Command(command, args...)
|
||||||
session, err := gexec.Start(c, GinkgoWriter, GinkgoWriter)
|
session, err := Start(c, GinkgoWriter, GinkgoWriter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " ")))
|
Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " ")))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue