aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-07-31 14:06:37 -0400
committerGitHub <noreply@github.com>2020-07-31 14:06:37 -0400
commit87955d8541e553567444b9f3cf2d09982fd9d419 (patch)
treee7e04c86432f498b815c7b1327464680e4318f97 /cmd/podman
parentb55a0ce42eb836b8d4a7091ea8bdd82e58f8352b (diff)
parenta9a55be991fa8f06cf266bd84a72589713a71ac9 (diff)
downloadpodman-87955d8541e553567444b9f3cf2d09982fd9d419.tar.gz
podman-87955d8541e553567444b9f3cf2d09982fd9d419.tar.bz2
podman-87955d8541e553567444b9f3cf2d09982fd9d419.zip
Merge pull request #7170 from mheon/204_backports
Extra backports for v2.0.4
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common/create_opts.go2
-rw-r--r--cmd/podman/common/specgen.go64
-rw-r--r--cmd/podman/containers/create.go2
-rw-r--r--cmd/podman/containers/ps.go4
-rw-r--r--cmd/podman/containers/start.go2
-rw-r--r--cmd/podman/containers/stats.go4
-rw-r--r--cmd/podman/images/history.go5
-rw-r--r--cmd/podman/images/list.go6
-rw-r--r--cmd/podman/networks/inspect.go2
-rw-r--r--cmd/podman/networks/list.go2
-rw-r--r--cmd/podman/registry/config.go2
-rw-r--r--cmd/podman/system/df.go2
-rw-r--r--cmd/podman/system/events.go2
-rw-r--r--cmd/podman/volumes/inspect.go2
-rw-r--r--cmd/podman/volumes/list.go2
15 files changed, 67 insertions, 36 deletions
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index 08ffa5544..bb50df8c9 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -10,7 +10,7 @@ type ContainerCLIOpts struct {
BlkIOWeightDevice []string
CapAdd []string
CapDrop []string
- CGroupsNS string
+ CgroupNS string
CGroupsMode string
CGroupParent string
CIDFile string
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index aa8669e7a..7716fc150 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -186,6 +186,46 @@ func getMemoryLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts) (*specs.Linu
return memory, nil
}
+func setNamespaces(s *specgen.SpecGenerator, c *ContainerCLIOpts) error {
+ var err error
+
+ if c.PID != "" {
+ s.PidNS, err = specgen.ParseNamespace(c.PID)
+ if err != nil {
+ return err
+ }
+ }
+ if c.IPC != "" {
+ s.IpcNS, err = specgen.ParseNamespace(c.IPC)
+ if err != nil {
+ return err
+ }
+ }
+ if c.UTS != "" {
+ s.UtsNS, err = specgen.ParseNamespace(c.UTS)
+ if err != nil {
+ return err
+ }
+ }
+ if c.CgroupNS != "" {
+ s.CgroupNS, err = specgen.ParseNamespace(c.CgroupNS)
+ if err != nil {
+ return err
+ }
+ }
+ // userns must be treated differently
+ if c.UserNS != "" {
+ s.UserNS, err = specgen.ParseUserNamespace(c.UserNS)
+ if err != nil {
+ return err
+ }
+ }
+ if c.Net != nil {
+ s.NetNS = c.Net.Network
+ }
+ return nil
+}
+
func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) error {
var (
err error
@@ -250,28 +290,8 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
}
s.Expose = expose
- for k, v := range map[string]*specgen.Namespace{
- c.IPC: &s.IpcNS,
- c.PID: &s.PidNS,
- c.UTS: &s.UtsNS,
- c.CGroupsNS: &s.CgroupNS,
- } {
- if k != "" {
- *v, err = specgen.ParseNamespace(k)
- if err != nil {
- return err
- }
- }
- }
- // userns must be treated differently
- if c.UserNS != "" {
- s.UserNS, err = specgen.ParseUserNamespace(c.UserNS)
- if err != nil {
- return err
- }
- }
- if c.Net != nil {
- s.NetNS = c.Net.Network
+ if err := setNamespaces(s, c); err != nil {
+ return err
}
if sig := c.StopSignal; len(sig) > 0 {
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index 10761be33..41e63da76 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -195,7 +195,7 @@ func createInit(c *cobra.Command) error {
cliVals.IPC = c.Flag("ipc").Value.String()
cliVals.UTS = c.Flag("uts").Value.String()
cliVals.PID = c.Flag("pid").Value.String()
- cliVals.CGroupsNS = c.Flag("cgroupns").Value.String()
+ cliVals.CgroupNS = c.Flag("cgroupns").Value.String()
if c.Flag("entrypoint").Changed {
val := c.Flag("entrypoint").Value.String()
cliVals.Entrypoint = &val
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go
index 7c84cbae1..34f06d349 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/start.go b/cmd/podman/containers/start.go
index 21f22b986..8f9984421 100644
--- a/cmd/podman/containers/start.go
+++ b/cmd/podman/containers/start.go
@@ -99,7 +99,7 @@ func start(cmd *cobra.Command, args []string) error {
}
for _, r := range responses {
- if r.Err == nil {
+ if r.Err == nil && !startOptions.Attach {
fmt.Println(r.RawInput)
} else {
errs = append(errs, r.Err)
diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go
index 86674cfc9..76a6ab46e 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 3732e6e03..1f0fd9a79 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 94d03bd6f..ea88b519b 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/networks/inspect.go b/cmd/podman/networks/inspect.go
index 0ce1b5e83..4afebf620 100644
--- a/cmd/podman/networks/inspect.go
+++ b/cmd/podman/networks/inspect.go
@@ -3,10 +3,10 @@ package network
import (
"encoding/json"
"fmt"
- "html/template"
"io"
"os"
"strings"
+ "text/template"
"github.com/containers/libpod/v2/cmd/podman/registry"
"github.com/containers/libpod/v2/pkg/domain/entities"
diff --git a/cmd/podman/networks/list.go b/cmd/podman/networks/list.go
index ad2ee98b1..105bd25c6 100644
--- a/cmd/podman/networks/list.go
+++ b/cmd/podman/networks/list.go
@@ -3,10 +3,10 @@ package network
import (
"encoding/json"
"fmt"
- "html/template"
"os"
"strings"
"text/tabwriter"
+ "text/template"
"github.com/containers/libpod/v2/cmd/podman/registry"
"github.com/containers/libpod/v2/cmd/podman/validate"
diff --git a/cmd/podman/registry/config.go b/cmd/podman/registry/config.go
index a7e368115..24e728bad 100644
--- a/cmd/podman/registry/config.go
+++ b/cmd/podman/registry/config.go
@@ -33,7 +33,7 @@ func PodmanConfig() *entities.PodmanConfig {
func newPodmanConfig() {
if err := setXdgDirs(); err != nil {
- fmt.Fprintf(os.Stderr, err.Error())
+ fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
diff --git a/cmd/podman/system/df.go b/cmd/podman/system/df.go
index c2308f0cc..a242c4f66 100644
--- a/cmd/podman/system/df.go
+++ b/cmd/podman/system/df.go
@@ -2,11 +2,11 @@ package system
import (
"fmt"
- "html/template"
"io"
"os"
"strings"
"text/tabwriter"
+ "text/template"
"time"
"github.com/containers/libpod/v2/cmd/podman/registry"
diff --git a/cmd/podman/system/events.go b/cmd/podman/system/events.go
index 246611c1a..0a46a4042 100644
--- a/cmd/podman/system/events.go
+++ b/cmd/podman/system/events.go
@@ -3,9 +3,9 @@ package system
import (
"bufio"
"context"
- "html/template"
"os"
"strings"
+ "text/template"
"github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/v2/cmd/podman/registry"
diff --git a/cmd/podman/volumes/inspect.go b/cmd/podman/volumes/inspect.go
index 9a8f4049b..235137fc7 100644
--- a/cmd/podman/volumes/inspect.go
+++ b/cmd/podman/volumes/inspect.go
@@ -2,9 +2,9 @@ package volumes
import (
"fmt"
- "html/template"
"os"
"strings"
+ "text/template"
"github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/v2/cmd/podman/registry"
diff --git a/cmd/podman/volumes/list.go b/cmd/podman/volumes/list.go
index 9e3a8f77b..804b9f319 100644
--- a/cmd/podman/volumes/list.go
+++ b/cmd/podman/volumes/list.go
@@ -3,11 +3,11 @@ package volumes
import (
"context"
"fmt"
- "html/template"
"io"
"os"
"strings"
"text/tabwriter"
+ "text/template"
"github.com/containers/libpod/v2/cmd/podman/registry"
"github.com/containers/libpod/v2/cmd/podman/validate"