mirror of
https://github.com/containers/podman.git
synced 2025-12-05 12:52:12 +08:00
\t was not being recognized as tab in --format
When doing kpod images --format "{{.ID}}\t{{.Tag}}"
the "\t" was being passed in as a string of "\" and "t"
instead of as a tab character.
Signed-off-by: umohnani8 <umohnani@redhat.com>
Closes: #123
Approved by: rhatdan
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package formats
|
package formats
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
@@ -8,7 +9,6 @@ import (
|
|||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"bytes"
|
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -92,10 +92,7 @@ func historyCmd(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
defer runtime.Shutdown(false)
|
defer runtime.Shutdown(false)
|
||||||
|
|
||||||
format := genHistoryFormat(c.Bool("quiet"))
|
format := genHistoryFormat(c.String("format"), c.Bool("quiet"))
|
||||||
if c.IsSet("format") {
|
|
||||||
format = c.String("format")
|
|
||||||
}
|
|
||||||
|
|
||||||
args := c.Args()
|
args := c.Args()
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
@@ -121,7 +118,12 @@ func historyCmd(c *cli.Context) error {
|
|||||||
return generateHistoryOutput(history, layers, imageID, opts)
|
return generateHistoryOutput(history, layers, imageID, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
func genHistoryFormat(quiet bool) (format string) {
|
func genHistoryFormat(format string, quiet bool) string {
|
||||||
|
if format != "" {
|
||||||
|
// "\t" from the command line is not being recognized as a tab
|
||||||
|
// replacing the string "\t" to a tab character if the user passes in "\t"
|
||||||
|
return strings.Replace(format, `\t`, "\t", -1)
|
||||||
|
}
|
||||||
if quiet {
|
if quiet {
|
||||||
return formats.IDString
|
return formats.IDString
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,12 +93,7 @@ func imagesCmd(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
defer runtime.Shutdown(false)
|
defer runtime.Shutdown(false)
|
||||||
|
|
||||||
var format string
|
format := genImagesFormat(c.String("format"), c.Bool("quiet"), c.Bool("noheading"), c.Bool("digests"))
|
||||||
if c.IsSet("format") {
|
|
||||||
format = c.String("format")
|
|
||||||
} else {
|
|
||||||
format = genImagesFormat(c.Bool("quiet"), c.Bool("noheading"), c.Bool("digests"))
|
|
||||||
}
|
|
||||||
|
|
||||||
opts := imagesOptions{
|
opts := imagesOptions{
|
||||||
quiet: c.Bool("quiet"),
|
quiet: c.Bool("quiet"),
|
||||||
@@ -137,7 +132,12 @@ func imagesCmd(c *cli.Context) error {
|
|||||||
return generateImagesOutput(runtime, images, opts)
|
return generateImagesOutput(runtime, images, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
func genImagesFormat(quiet, noHeading, digests bool) (format string) {
|
func genImagesFormat(format string, quiet, noHeading, digests bool) string {
|
||||||
|
if format != "" {
|
||||||
|
// "\t" from the command line is not being recognized as a tab
|
||||||
|
// replacing the string "\t" to a tab character if the user passes in "\t"
|
||||||
|
return strings.Replace(format, `\t`, "\t", -1)
|
||||||
|
}
|
||||||
if quiet {
|
if quiet {
|
||||||
return formats.IDString
|
return formats.IDString
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ func genImagesFormat(quiet, noHeading, digests bool) (format string) {
|
|||||||
format += "{{.Digest}}\t"
|
format += "{{.Digest}}\t"
|
||||||
}
|
}
|
||||||
format += "{{.ID}}\t{{.Created}}\t{{.Size}}\t"
|
format += "{{.ID}}\t{{.Created}}\t{{.Size}}\t"
|
||||||
return
|
return format
|
||||||
}
|
}
|
||||||
|
|
||||||
// imagesToGeneric creates an empty array of interfaces for output
|
// imagesToGeneric creates an empty array of interfaces for output
|
||||||
|
|||||||
@@ -160,10 +160,7 @@ func psCmd(c *cli.Context) error {
|
|||||||
return errors.Errorf("too many arguments, ps takes no arguments")
|
return errors.Errorf("too many arguments, ps takes no arguments")
|
||||||
}
|
}
|
||||||
|
|
||||||
format := genPsFormat(c.Bool("quiet"), c.Bool("size"), c.Bool("namespace"))
|
format := genPsFormat(c.String("format"), c.Bool("quiet"), c.Bool("size"), c.Bool("namespace"))
|
||||||
if c.IsSet("format") {
|
|
||||||
format = c.String("format")
|
|
||||||
}
|
|
||||||
|
|
||||||
opts := psOptions{
|
opts := psOptions{
|
||||||
all: c.Bool("all"),
|
all: c.Bool("all"),
|
||||||
@@ -302,19 +299,23 @@ func generateContainerFilterFuncs(filter, filterValue string, runtime *libpod.Ru
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate the template based on conditions given
|
// generate the template based on conditions given
|
||||||
func genPsFormat(quiet, size, namespace bool) (format string) {
|
func genPsFormat(format string, quiet, size, namespace bool) string {
|
||||||
|
if format != "" {
|
||||||
|
// "\t" from the command line is not being recognized as a tab
|
||||||
|
// replacing the string "\t" to a tab character if the user passes in "\t"
|
||||||
|
return strings.Replace(format, `\t`, "\t", -1)
|
||||||
|
}
|
||||||
if quiet {
|
if quiet {
|
||||||
return formats.IDString
|
return formats.IDString
|
||||||
}
|
}
|
||||||
if namespace {
|
if namespace {
|
||||||
format = "table {{.ID}}\t{{.Names}}\t{{.PID}}\t{{.Cgroup}}\t{{.IPC}}\t{{.MNT}}\t{{.NET}}\t{{.PIDNS}}\t{{.User}}\t{{.UTS}}\t"
|
return "table {{.ID}}\t{{.Names}}\t{{.PID}}\t{{.Cgroup}}\t{{.IPC}}\t{{.MNT}}\t{{.NET}}\t{{.PIDNS}}\t{{.User}}\t{{.UTS}}\t"
|
||||||
return
|
|
||||||
}
|
}
|
||||||
format = "table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}\t"
|
format = "table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}\t"
|
||||||
if size {
|
if size {
|
||||||
format += "{{.Size}}\t"
|
format += "{{.Size}}\t"
|
||||||
}
|
}
|
||||||
return
|
return format
|
||||||
}
|
}
|
||||||
|
|
||||||
func psToGeneric(templParams []psTemplateParams, JSONParams []psJSONParams) (genericParams []interface{}) {
|
func psToGeneric(templParams []psTemplateParams, JSONParams []psJSONParams) (genericParams []interface{}) {
|
||||||
|
|||||||
Reference in New Issue
Block a user