diff options
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/containers/create.go | 13 | ||||
-rw-r--r-- | cmd/podman/containers/ps.go | 4 | ||||
-rw-r--r-- | cmd/podman/containers/run.go | 2 | ||||
-rw-r--r-- | cmd/podman/containers/stats.go | 4 | ||||
-rw-r--r-- | cmd/podman/images/history.go | 5 | ||||
-rw-r--r-- | cmd/podman/images/list.go | 6 | ||||
-rw-r--r-- | cmd/podman/system/connection/list.go | 6 | ||||
-rw-r--r-- | cmd/podman/system/df.go | 9 | ||||
-rw-r--r-- | cmd/podman/system/service.go | 5 |
9 files changed, 39 insertions, 15 deletions
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index dd77dc9d7..1516d15e9 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -124,7 +124,7 @@ func create(cmd *cobra.Command, args []string) error { return err } - if _, err := createPodIfNecessary(s); err != nil { + if _, err := createPodIfNecessary(s, cliVals.Net); err != nil { return err } @@ -283,7 +283,7 @@ func openCidFile(cidfile string) (*os.File, error) { // createPodIfNecessary automatically creates a pod when requested. if the pod name // has the form new:ID, the pod ID is created and the name in the spec generator is replaced // with ID. -func createPodIfNecessary(s *specgen.SpecGenerator) (*entities.PodCreateReport, error) { +func createPodIfNecessary(s *specgen.SpecGenerator, netOpts *entities.NetOptions) (*entities.PodCreateReport, error) { if !strings.HasPrefix(s.Pod, "new:") { return nil, nil } @@ -292,11 +292,10 @@ func createPodIfNecessary(s *specgen.SpecGenerator) (*entities.PodCreateReport, return nil, errors.Errorf("new pod name must be at least one character") } createOptions := entities.PodCreateOptions{ - Name: podName, - Infra: true, - Net: &entities.NetOptions{ - PublishPorts: s.PortMappings, - }, + Name: podName, + Infra: true, + Net: netOpts, + CreateCommand: os.Args, } s.Pod = podName return registry.ContainerEngine().PodCreate(context.Background(), createOptions) diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index 34fa4fab5..64271031d 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -307,6 +307,10 @@ func (l psReporter) Status() string { return l.State() } +func (l psReporter) RunningFor() string { + return l.CreatedHuman() +} + // Command returns the container command in string format func (l psReporter) Command() string { command := strings.Join(l.ListContainer.Command, " ") diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index 646c52645..d26aed826 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -176,7 +176,7 @@ func run(cmd *cobra.Command, args []string) error { } runOpts.Spec = s - if _, err := createPodIfNecessary(s); err != nil { + if _, err := createPodIfNecessary(s, cliVals.Net); err != nil { return err } diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go index 2b4c46647..ddb5f32ef 100644 --- a/cmd/podman/containers/stats.go +++ b/cmd/podman/containers/stats.go @@ -230,8 +230,8 @@ func outputJSON(stats []*containerStats) error { Id: j.ID(), Name: j.Name, CpuPercent: j.CPUPerc(), - MemUsage: j.MemPerc(), - MemPerc: j.MemUsage(), + MemUsage: j.MemUsage(), + MemPerc: j.MemPerc(), NetIO: j.NetIO(), BlockIO: j.BlockIO(), Pids: j.PIDS(), diff --git a/cmd/podman/images/history.go b/cmd/podman/images/history.go index ef5b4be26..f3a41f6b9 100644 --- a/cmd/podman/images/history.go +++ b/cmd/podman/images/history.go @@ -125,7 +125,10 @@ func history(cmd *cobra.Command, args []string) error { } format := hdr + "{{range . }}" + row + "{{end}}" - tmpl := template.Must(template.New("report").Parse(format)) + tmpl, err := template.New("report").Parse(format) + if err != nil { + return err + } w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0) err = tmpl.Execute(w, hr) if err != nil { diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go index 4552901f7..ee0f64d99 100644 --- a/cmd/podman/images/list.go +++ b/cmd/podman/images/list.go @@ -168,7 +168,11 @@ func writeTemplate(imgs []imageReporter) error { } } format := hdr + "{{range . }}" + row + "{{end}}" - tmpl := template.Must(template.New("list").Parse(format)) + tmpl, err := template.New("list").Parse(format) + if err != nil { + return err + } + tmpl = template.Must(tmpl, nil) w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0) defer w.Flush() return tmpl.Execute(w, imgs) diff --git a/cmd/podman/system/connection/list.go b/cmd/podman/system/connection/list.go index 6d3d85d11..9010ec803 100644 --- a/cmd/podman/system/connection/list.go +++ b/cmd/podman/system/connection/list.go @@ -75,7 +75,11 @@ func list(_ *cobra.Command, _ []string) error { // TODO: Allow user to override format format := "{{range . }}{{.Name}}\t{{.Identity}}\t{{.URI}}\n{{end}}" - tmpl := template.Must(template.New("connection").Parse(format)) + tmpl, err := template.New("connection").Parse(format) + if err != nil { + return err + } + w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0) defer w.Flush() diff --git a/cmd/podman/system/df.go b/cmd/podman/system/df.go index a320eb5c7..03991101e 100644 --- a/cmd/podman/system/df.go +++ b/cmd/podman/system/df.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "strconv" "strings" "text/tabwriter" "text/template" @@ -69,6 +70,14 @@ func printSummary(reports *entities.SystemDfReport, userFormat string) error { // Images if len(userFormat) > 0 { + if !strings.HasSuffix(userFormat, `\n`) { + userFormat += `\n` + } + // should be Unquoto from cmd line + userFormat, err := strconv.Unquote(`"` + userFormat + `"`) + if err != nil { + return err + } format = userFormat } diff --git a/cmd/podman/system/service.go b/cmd/podman/system/service.go index 2d511f0ec..7c692b07e 100644 --- a/cmd/podman/system/service.go +++ b/cmd/podman/system/service.go @@ -49,7 +49,7 @@ func init() { flags := srvCmd.Flags() flags.Int64VarP(&srvArgs.Timeout, "time", "t", 5, "Time until the service session expires in seconds. Use 0 to disable the timeout") - flags.BoolVar(&srvArgs.Varlink, "varlink", false, "Use legacy varlink service instead of REST") + flags.BoolVar(&srvArgs.Varlink, "varlink", false, "Use legacy varlink service instead of REST. Unit of --time changes from seconds to milliseconds.") _ = flags.MarkDeprecated("varlink", "valink API is deprecated.") flags.SetNormalizeFunc(aliasTimeoutFlag) @@ -88,14 +88,15 @@ func service(cmd *cobra.Command, args []string) error { opts := entities.ServiceOptions{ URI: apiURI, - Timeout: time.Duration(srvArgs.Timeout) * time.Second, Command: cmd, } if srvArgs.Varlink { + opts.Timeout = time.Duration(srvArgs.Timeout) * time.Millisecond return registry.ContainerEngine().VarlinkService(registry.GetContext(), opts) } + opts.Timeout = time.Duration(srvArgs.Timeout) * time.Second return restService(opts, cmd.Flags(), registry.PodmanConfig()) } |