summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/attach.go2
-rw-r--r--cmd/podman/build.go2
-rw-r--r--cmd/podman/checkpoint.go11
-rw-r--r--cmd/podman/cleanup.go2
-rw-r--r--cmd/podman/commands.go1
-rw-r--r--cmd/podman/commit.go8
-rw-r--r--cmd/podman/common.go62
-rw-r--r--cmd/podman/common_libpod.go65
-rw-r--r--cmd/podman/containers_prune.go4
-rw-r--r--cmd/podman/cp.go13
-rw-r--r--cmd/podman/exec.go70
-rw-r--r--cmd/podman/exists.go14
-rw-r--r--cmd/podman/healthcheck_run.go12
-rw-r--r--cmd/podman/history.go2
-rw-r--r--cmd/podman/images.go2
-rw-r--r--cmd/podman/info.go8
-rw-r--r--cmd/podman/libpodruntime/runtime.go19
-rw-r--r--cmd/podman/logs.go7
-rw-r--r--cmd/podman/main.go5
-rw-r--r--cmd/podman/main_local.go3
-rw-r--r--cmd/podman/pause.go9
-rw-r--r--cmd/podman/play_kube.go306
-rw-r--r--cmd/podman/pod_create.go9
-rw-r--r--cmd/podman/pod_kill.go2
-rw-r--r--cmd/podman/pod_ps.go14
-rw-r--r--cmd/podman/pod_stats.go5
-rw-r--r--cmd/podman/pod_top.go6
-rw-r--r--cmd/podman/ps.go64
-rw-r--r--cmd/podman/pull.go2
-rw-r--r--cmd/podman/remoteclientconfig/configfile.go2
-rw-r--r--cmd/podman/restart.go10
-rw-r--r--cmd/podman/restore.go10
-rw-r--r--cmd/podman/rm.go4
-rw-r--r--cmd/podman/run.go2
-rw-r--r--cmd/podman/runlabel.go4
-rw-r--r--cmd/podman/shared/container.go31
-rw-r--r--cmd/podman/shared/container_inspect.go2
-rw-r--r--cmd/podman/shared/create.go4
-rw-r--r--cmd/podman/shared/create_cli.go4
-rw-r--r--cmd/podman/shared/intermediate.go2
-rw-r--r--cmd/podman/shared/pod.go13
-rw-r--r--cmd/podman/start.go6
-rw-r--r--cmd/podman/stats.go7
-rw-r--r--cmd/podman/stop.go6
-rw-r--r--cmd/podman/system_df.go7
-rw-r--r--cmd/podman/top.go6
-rw-r--r--cmd/podman/tree.go8
-rw-r--r--cmd/podman/unpause.go9
-rw-r--r--cmd/podman/unshare.go15
-rw-r--r--cmd/podman/version.go6
50 files changed, 249 insertions, 638 deletions
diff --git a/cmd/podman/attach.go b/cmd/podman/attach.go
index 37f8afbad..48a25a3e2 100644
--- a/cmd/podman/attach.go
+++ b/cmd/podman/attach.go
@@ -31,7 +31,7 @@ func init() {
attachCommand.SetHelpTemplate(HelpTemplate())
attachCommand.SetUsageTemplate(UsageTemplate())
flags := attachCommand.Flags()
- flags.StringVar(&attachCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _")
+ flags.StringVar(&attachCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
flags.BoolVar(&attachCommand.NoStdin, "no-stdin", false, "Do not attach STDIN. The default is false")
flags.BoolVar(&attachCommand.SigProxy, "sig-proxy", true, "Proxy received signals to the process")
flags.BoolVarP(&attachCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
diff --git a/cmd/podman/build.go b/cmd/podman/build.go
index 6e70c6540..5e2b1aa82 100644
--- a/cmd/podman/build.go
+++ b/cmd/podman/build.go
@@ -62,7 +62,7 @@ func init() {
layerFlags := buildahcli.GetLayerFlags(&layerValues)
flag = layerFlags.Lookup("layers")
flag.Value.Set(useLayers())
- flag.DefValue = (useLayers())
+ flag.DefValue = useLayers()
flag = layerFlags.Lookup("force-rm")
flag.Value.Set("true")
flag.DefValue = "true"
diff --git a/cmd/podman/checkpoint.go b/cmd/podman/checkpoint.go
index 86bc8b973..bfb5b49d4 100644
--- a/cmd/podman/checkpoint.go
+++ b/cmd/podman/checkpoint.go
@@ -2,7 +2,6 @@ package main
import (
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/adapter"
"github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
@@ -59,13 +58,7 @@ func checkpointCmd(c *cliconfig.CheckpointValues) error {
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
- defer runtime.Shutdown(false)
- options := libpod.ContainerCheckpointOptions{
- Keep: c.Keep,
- KeepRunning: c.LeaveRunning,
- TCPEstablished: c.TcpEstablished,
- TargetFile: c.Export,
- }
- return runtime.Checkpoint(c, options)
+ defer runtime.Shutdown(false)
+ return runtime.Checkpoint(c)
}
diff --git a/cmd/podman/cleanup.go b/cmd/podman/cleanup.go
index 4ff744ae5..9544b75b0 100644
--- a/cmd/podman/cleanup.go
+++ b/cmd/podman/cleanup.go
@@ -1,3 +1,5 @@
+//+build !remoteclient
+
package main
import (
diff --git a/cmd/podman/commands.go b/cmd/podman/commands.go
index 18b0b7857..9229191ff 100644
--- a/cmd/podman/commands.go
+++ b/cmd/podman/commands.go
@@ -19,6 +19,7 @@ func getMainCommands() []*cobra.Command {
_refreshCommand,
_searchCommand,
_statsCommand,
+ _umountCommand,
_unshareCommand,
}
diff --git a/cmd/podman/commit.go b/cmd/podman/commit.go
index db0b8241e..c49645a1d 100644
--- a/cmd/podman/commit.go
+++ b/cmd/podman/commit.go
@@ -5,7 +5,6 @@ import (
"strings"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/adapter"
"github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
@@ -30,6 +29,9 @@ var (
podman commit -q --author "firstName lastName" reverent_golick image-committed
podman commit -q --pause=false containerID image-committed`,
}
+
+ // ChangeCmds is the list of valid Changes commands to passed to the Commit call
+ ChangeCmds = []string{"CMD", "ENTRYPOINT", "ENV", "EXPOSE", "LABEL", "ONBUILD", "STOPSIGNAL", "USER", "VOLUME", "WORKDIR"}
)
func init() {
@@ -37,7 +39,7 @@ func init() {
commitCommand.SetHelpTemplate(HelpTemplate())
commitCommand.SetUsageTemplate(UsageTemplate())
flags := commitCommand.Flags()
- flags.StringArrayVarP(&commitCommand.Change, "change", "c", []string{}, fmt.Sprintf("Apply the following possible instructions to the created image (default []): %s", strings.Join(libpod.ChangeCmds, " | ")))
+ flags.StringArrayVarP(&commitCommand.Change, "change", "c", []string{}, fmt.Sprintf("Apply the following possible instructions to the created image (default []): %s", strings.Join(ChangeCmds, " | ")))
flags.StringVarP(&commitCommand.Format, "format", "f", "oci", "`Format` of the image manifest and metadata")
flags.StringVarP(&commitCommand.Message, "message", "m", "", "Set commit message for imported image")
flags.StringVarP(&commitCommand.Author, "author", "a", "", "Set the author for the image committed")
@@ -66,7 +68,7 @@ func commitCmd(c *cliconfig.CommitValues) error {
if len(splitChange) == 1 {
splitChange = strings.Split(strings.ToUpper(change), " ")
}
- if !util.StringInSlice(splitChange[0], libpod.ChangeCmds) {
+ if !util.StringInSlice(splitChange[0], ChangeCmds) {
return errors.Errorf("invalid syntax for --change: %s", change)
}
}
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index 054b01247..3cc645f95 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -9,7 +9,7 @@ import (
"github.com/containers/buildah"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/storage"
"github.com/fatih/camelcase"
@@ -80,58 +80,6 @@ func commandRunE() func(*cobra.Command, []string) error {
}
}
-// getAllOrLatestContainers tries to return the correct list of containers
-// depending if --all, --latest or <container-id> is used.
-// It requires the Context (c) and the Runtime (runtime). As different
-// commands are using different container state for the --all option
-// the desired state has to be specified in filterState. If no filter
-// is desired a -1 can be used to get all containers. For a better
-// error message, if the filter fails, a corresponding verb can be
-// specified which will then appear in the error message.
-func getAllOrLatestContainers(c *cliconfig.PodmanCommand, runtime *libpod.Runtime, filterState libpod.ContainerStatus, verb string) ([]*libpod.Container, error) {
- var containers []*libpod.Container
- var lastError error
- var err error
- if c.Bool("all") {
- if filterState != -1 {
- var filterFuncs []libpod.ContainerFilter
- filterFuncs = append(filterFuncs, func(c *libpod.Container) bool {
- state, _ := c.State()
- return state == filterState
- })
- containers, err = runtime.GetContainers(filterFuncs...)
- } else {
- containers, err = runtime.GetContainers()
- }
- if err != nil {
- return nil, errors.Wrapf(err, "unable to get %s containers", verb)
- }
- } else if c.Bool("latest") {
- lastCtr, err := runtime.GetLatestContainer()
- if err != nil {
- return nil, errors.Wrapf(err, "unable to get latest container")
- }
- containers = append(containers, lastCtr)
- } else {
- args := c.InputArgs
- for _, i := range args {
- container, err := runtime.LookupContainer(i)
- if err != nil {
- if lastError != nil {
- fmt.Fprintln(os.Stderr, lastError)
- }
- lastError = errors.Wrapf(err, "unable to find container %s", i)
- }
- if container != nil {
- // This is here to make sure this does not return [<nil>] but only nil
- containers = append(containers, container)
- }
- }
- }
-
- return containers, lastError
-}
-
// getContext returns a non-nil, empty context
func getContext() context.Context {
if Ctx != nil {
@@ -233,7 +181,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
)
createFlags.String(
"detach-keys", "",
- "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`",
+ "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`",
)
createFlags.StringSlice(
"device", []string{},
@@ -333,7 +281,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
createFlags.String(
"init-path", "",
// Do not use the Value field for setting the default value to determine user input (i.e., non-empty string)
- fmt.Sprintf("Path to the container-init binary (default: %q)", libpod.DefaultInitPath),
+ fmt.Sprintf("Path to the container-init binary (default: %q)", define.DefaultInitPath),
)
createFlags.BoolP(
"interactive", "i", false,
@@ -472,7 +420,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
"Signal to stop a container. Default is SIGTERM",
)
createFlags.Uint(
- "stop-timeout", libpod.CtrRemoveTimeout,
+ "stop-timeout", define.CtrRemoveTimeout,
"Timeout (in seconds) to stop a container. Default is 10",
)
createFlags.StringSlice(
@@ -496,7 +444,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
"systemd", cliconfig.DefaultSystemD,
"Run container in systemd mode if the command executable is systemd or init",
)
- createFlags.StringSlice(
+ createFlags.StringArray(
"tmpfs", []string{},
"Mount a temporary filesystem (`tmpfs`) into a container (default [])",
)
diff --git a/cmd/podman/common_libpod.go b/cmd/podman/common_libpod.go
new file mode 100644
index 000000000..5deea15d3
--- /dev/null
+++ b/cmd/podman/common_libpod.go
@@ -0,0 +1,65 @@
+//build !remoteclient
+
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/containers/libpod/cmd/podman/cliconfig"
+ "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
+ "github.com/pkg/errors"
+)
+
+// getAllOrLatestContainers tries to return the correct list of containers
+// depending if --all, --latest or <container-id> is used.
+// It requires the Context (c) and the Runtime (runtime). As different
+// commands are using different container state for the --all option
+// the desired state has to be specified in filterState. If no filter
+// is desired a -1 can be used to get all containers. For a better
+// error message, if the filter fails, a corresponding verb can be
+// specified which will then appear in the error message.
+func getAllOrLatestContainers(c *cliconfig.PodmanCommand, runtime *libpod.Runtime, filterState define.ContainerStatus, verb string) ([]*libpod.Container, error) {
+ var containers []*libpod.Container
+ var lastError error
+ var err error
+ if c.Bool("all") {
+ if filterState != -1 {
+ var filterFuncs []libpod.ContainerFilter
+ filterFuncs = append(filterFuncs, func(c *libpod.Container) bool {
+ state, _ := c.State()
+ return state == filterState
+ })
+ containers, err = runtime.GetContainers(filterFuncs...)
+ } else {
+ containers, err = runtime.GetContainers()
+ }
+ if err != nil {
+ return nil, errors.Wrapf(err, "unable to get %s containers", verb)
+ }
+ } else if c.Bool("latest") {
+ lastCtr, err := runtime.GetLatestContainer()
+ if err != nil {
+ return nil, errors.Wrapf(err, "unable to get latest container")
+ }
+ containers = append(containers, lastCtr)
+ } else {
+ args := c.InputArgs
+ for _, i := range args {
+ container, err := runtime.LookupContainer(i)
+ if err != nil {
+ if lastError != nil {
+ fmt.Fprintln(os.Stderr, lastError)
+ }
+ lastError = errors.Wrapf(err, "unable to find container %s", i)
+ }
+ if container != nil {
+ // This is here to make sure this does not return [<nil>] but only nil
+ containers = append(containers, container)
+ }
+ }
+ }
+
+ return containers, lastError
+}
diff --git a/cmd/podman/containers_prune.go b/cmd/podman/containers_prune.go
index b052bda36..97481fb35 100644
--- a/cmd/podman/containers_prune.go
+++ b/cmd/podman/containers_prune.go
@@ -3,7 +3,7 @@ package main
import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/shared"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -51,7 +51,7 @@ func pruneContainersCmd(c *cliconfig.PruneContainersValues) error {
}
ok, failures, err := runtime.Prune(getContext(), maxWorkers, c.Force)
if err != nil {
- if errors.Cause(err) == libpod.ErrNoSuchCtr {
+ if errors.Cause(err) == define.ErrNoSuchCtr {
if len(c.InputArgs) > 1 {
exitCode = 125
} else {
diff --git a/cmd/podman/cp.go b/cmd/podman/cp.go
index efe343bfd..f6ac5f8f7 100644
--- a/cmd/podman/cp.go
+++ b/cmd/podman/cp.go
@@ -13,14 +13,15 @@ import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/storage"
"github.com/containers/storage/pkg/archive"
"github.com/containers/storage/pkg/chrootarchive"
"github.com/containers/storage/pkg/idtools"
securejoin "github.com/cyphar/filepath-securejoin"
- digest "github.com/opencontainers/go-digest"
- specs "github.com/opencontainers/runtime-spec/specs-go"
+ "github.com/opencontainers/go-digest"
+ "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -85,7 +86,7 @@ func copyBetweenHostAndContainer(runtime *libpod.Runtime, src string, dest strin
return errors.Errorf("invalid arguments %s, %s you must specify paths", src, dest)
}
ctr := srcCtr
- isFromHostToCtr := (ctr == nil)
+ isFromHostToCtr := ctr == nil
if isFromHostToCtr {
ctr = destCtr
}
@@ -102,7 +103,7 @@ func copyBetweenHostAndContainer(runtime *libpod.Runtime, src string, dest strin
if err != nil {
return err
}
- if state == libpod.ContainerStateRunning {
+ if state == define.ContainerStateRunning {
return errors.Errorf("cannot copy into running rootless container with pause set - pass --pause=false to force copying")
}
}
@@ -114,7 +115,7 @@ func copyBetweenHostAndContainer(runtime *libpod.Runtime, src string, dest strin
// TODO: We can potentially start the container while
// the copy is running, which still allows a race where
// malicious code could mess with the symlink.
- if errors.Cause(err) != libpod.ErrCtrStateInvalid {
+ if errors.Cause(err) != define.ErrCtrStateInvalid {
return err
}
} else if err == nil {
@@ -306,7 +307,7 @@ func copy(src, destPath, dest string, idMappingOpts storage.IDMappingOptions, ch
if err != nil && !os.IsNotExist(err) {
return errors.Wrapf(err, "error checking directory %q", destdir)
}
- destDirIsExist := (err == nil)
+ destDirIsExist := err == nil
if err = os.MkdirAll(destdir, 0755); err != nil {
return errors.Wrapf(err, "error creating directory %q", destdir)
}
diff --git a/cmd/podman/exec.go b/cmd/podman/exec.go
index 0684da842..bf8de69fc 100644
--- a/cmd/podman/exec.go
+++ b/cmd/podman/exec.go
@@ -1,15 +1,9 @@
package main
import (
- "fmt"
- "io/ioutil"
- "os"
- "strconv"
-
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
- "github.com/containers/libpod/cmd/podman/shared/parse"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
+ "github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -55,8 +49,6 @@ func init() {
func execCmd(c *cliconfig.ExecValues) error {
args := c.InputArgs
- var ctr *libpod.Container
- var err error
argStart := 1
if len(args) < 1 && !c.Latest {
return errors.Errorf("you must provide one container name or id")
@@ -68,67 +60,15 @@ func execCmd(c *cliconfig.ExecValues) error {
argStart = 0
}
cmd := args[argStart:]
- runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand)
+ runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "error creating libpod runtime")
}
defer runtime.Shutdown(false)
- if c.Latest {
- ctr, err = runtime.GetLatestContainer()
- } else {
- ctr, err = runtime.LookupContainer(args[0])
- }
- if err != nil {
- return errors.Wrapf(err, "unable to exec into %s", args[0])
- }
-
- if c.PreserveFDs > 0 {
- entries, err := ioutil.ReadDir("/proc/self/fd")
- if err != nil {
- return errors.Wrapf(err, "unable to read /proc/self/fd")
- }
- m := make(map[int]bool)
- for _, e := range entries {
- i, err := strconv.Atoi(e.Name())
- if err != nil {
- if err != nil {
- return errors.Wrapf(err, "cannot parse %s in /proc/self/fd", e.Name())
- }
- }
- m[i] = true
- }
- for i := 3; i < 3+c.PreserveFDs; i++ {
- if _, found := m[i]; !found {
- return errors.New("invalid --preserve-fds=N specified. Not enough FDs available")
- }
- }
-
- }
-
- // ENVIRONMENT VARIABLES
- env := map[string]string{}
-
- if err := parse.ReadKVStrings(env, []string{}, c.Env); err != nil {
- return errors.Wrapf(err, "unable to process environment variables")
- }
- envs := []string{}
- for k, v := range env {
- envs = append(envs, fmt.Sprintf("%s=%s", k, v))
- }
-
- streams := new(libpod.AttachStreams)
- streams.OutputStream = os.Stdout
- streams.ErrorStream = os.Stderr
- streams.InputStream = os.Stdin
- streams.AttachOutput = true
- streams.AttachError = true
- streams.AttachInput = true
-
- err = ctr.Exec(c.Tty, c.Privileged, envs, cmd, c.User, c.Workdir, streams, c.PreserveFDs)
- if errors.Cause(err) == libpod.ErrCtrStateInvalid {
+ err = runtime.Exec(c, cmd)
+ if errors.Cause(err) == define.ErrCtrStateInvalid {
exitCode = 126
}
-
return err
}
diff --git a/cmd/podman/exists.go b/cmd/podman/exists.go
index 6619522b6..1e052e25f 100644
--- a/cmd/podman/exists.go
+++ b/cmd/podman/exists.go
@@ -1,14 +1,14 @@
package main
import (
- "github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/spf13/cobra"
"os"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/cmd/podman/cliconfig"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/image"
"github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
+ "github.com/spf13/cobra"
)
var (
@@ -107,13 +107,13 @@ func containerExistsCmd(c *cliconfig.ContainerExistsValues) error {
if len(args) > 1 || len(args) < 1 {
return errors.New("you may only check for the existence of one container at a time")
}
- runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
+ runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
defer runtime.Shutdown(false)
if _, err := runtime.LookupContainer(args[0]); err != nil {
- if errors.Cause(err) == libpod.ErrNoSuchCtr || err.Error() == "io.podman.ContainerNotFound" {
+ if errors.Cause(err) == define.ErrNoSuchCtr || err.Error() == "io.podman.ContainerNotFound" {
os.Exit(1)
}
return err
@@ -126,14 +126,14 @@ func podExistsCmd(c *cliconfig.PodExistsValues) error {
if len(args) > 1 || len(args) < 1 {
return errors.New("you may only check for the existence of one pod at a time")
}
- runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
+ runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
defer runtime.Shutdown(false)
if _, err := runtime.LookupPod(args[0]); err != nil {
- if errors.Cause(err) == libpod.ErrNoSuchPod || err.Error() == "io.podman.PodNotFound" {
+ if errors.Cause(err) == define.ErrNoSuchPod || err.Error() == "io.podman.PodNotFound" {
os.Exit(1)
}
return err
diff --git a/cmd/podman/healthcheck_run.go b/cmd/podman/healthcheck_run.go
index 111318d9c..aaeed93c6 100644
--- a/cmd/podman/healthcheck_run.go
+++ b/cmd/podman/healthcheck_run.go
@@ -2,8 +2,8 @@ package main
import (
"fmt"
+
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -43,12 +43,6 @@ func healthCheckCmd(c *cliconfig.HealthCheckValues) error {
return errors.Wrap(err, "could not get runtime")
}
status, err := runtime.HealthCheck(c)
- if err != nil {
- if status == libpod.HealthCheckFailure {
- fmt.Println("\nunhealthy")
- }
- return err
- }
- fmt.Println("healthy")
- return nil
+ fmt.Println(status)
+ return err
}
diff --git a/cmd/podman/history.go b/cmd/podman/history.go
index cebf99a9f..0998a023c 100644
--- a/cmd/podman/history.go
+++ b/cmd/podman/history.go
@@ -154,7 +154,7 @@ func getHistoryTemplateOutput(history []*image.History, opts historyOptions) (hi
}
if opts.human {
- createdTime = units.HumanDuration(time.Since((*hist.Created))) + " ago"
+ createdTime = units.HumanDuration(time.Since(*hist.Created)) + " ago"
outputSize = units.HumanSize(float64(hist.Size))
} else {
createdTime = (hist.Created).Format(time.RFC3339)
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index 3f755efc1..33cf11ab7 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -280,7 +280,7 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
ID: imageID,
Digest: img.Digest(),
CreatedTime: createdTime,
- Created: units.HumanDuration(time.Since((createdTime))) + " ago",
+ Created: units.HumanDuration(time.Since(createdTime)) + " ago",
Size: sizeStr,
}
imagesOutput = append(imagesOutput, params)
diff --git a/cmd/podman/info.go b/cmd/podman/info.go
index 823303354..e24fe3c77 100644
--- a/cmd/podman/info.go
+++ b/cmd/podman/info.go
@@ -6,7 +6,7 @@ import (
"github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
"github.com/containers/libpod/version"
"github.com/pkg/errors"
@@ -74,12 +74,12 @@ func infoCmd(c *cliconfig.InfoValues) error {
remoteClientInfo["RemoteAPI Version"] = version.RemoteAPIVersion
remoteClientInfo["Podman Version"] = version.Version
remoteClientInfo["OS Arch"] = fmt.Sprintf("%s/%s", rt.GOOS, rt.GOARCH)
- infoArr = append(infoArr, libpod.InfoData{Type: "client", Data: remoteClientInfo})
+ infoArr = append(infoArr, define.InfoData{Type: "client", Data: remoteClientInfo})
}
if !runtime.Remote && c.Debug {
debugInfo := debugInfo(c)
- infoArr = append(infoArr, libpod.InfoData{Type: "debug", Data: debugInfo})
+ infoArr = append(infoArr, define.InfoData{Type: "debug", Data: debugInfo})
}
for _, currInfo := range infoArr {
@@ -108,7 +108,7 @@ func debugInfo(c *cliconfig.InfoValues) map[string]interface{} {
info["compiler"] = rt.Compiler
info["go version"] = rt.Version()
info["podman version"] = version.Version
- version, _ := libpod.GetVersion()
+ version, _ := define.GetVersion()
info["git commit"] = version.GitCommit
return info
}
diff --git a/cmd/podman/libpodruntime/runtime.go b/cmd/podman/libpodruntime/runtime.go
index d83a71250..570288837 100644
--- a/cmd/podman/libpodruntime/runtime.go
+++ b/cmd/podman/libpodruntime/runtime.go
@@ -5,6 +5,7 @@ import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/cgroups"
"github.com/containers/libpod/pkg/namespaces"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/libpod/pkg/util"
@@ -14,20 +15,25 @@ import (
// GetRuntimeMigrate gets a libpod runtime that will perform a migration of existing containers
func GetRuntimeMigrate(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
- return getRuntime(ctx, c, false, true)
+ return getRuntime(ctx, c, false, true, false)
}
// GetRuntimeRenumber gets a libpod runtime that will perform a lock renumber
func GetRuntimeRenumber(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
- return getRuntime(ctx, c, true, false)
+ return getRuntime(ctx, c, true, false, false)
}
// GetRuntime generates a new libpod runtime configured by command line options
func GetRuntime(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
- return getRuntime(ctx, c, false, false)
+ return getRuntime(ctx, c, false, false, false)
}
-func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber bool, migrate bool) (*libpod.Runtime, error) {
+// GetRuntimeNoStore generates a new libpod runtime configured by command line options
+func GetRuntimeNoStore(ctx context.Context, c *cliconfig.PodmanCommand) (*libpod.Runtime, error) {
+ return getRuntime(ctx, c, false, false, true)
+}
+
+func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber, migrate, noStore bool) (*libpod.Runtime, error) {
options := []libpod.RuntimeOption{}
storageOpts := storage.StoreOptions{}
storageSet := false
@@ -88,6 +94,9 @@ func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber bool,
options = append(options, libpod.WithStorageConfig(storageOpts))
}
+ if !storageSet && noStore {
+ options = append(options, libpod.WithNoStore())
+ }
// TODO CLI flags for image config?
// TODO CLI flag for signature policy?
@@ -112,7 +121,7 @@ func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber bool,
if c.Flags().Changed("cgroup-manager") {
options = append(options, libpod.WithCgroupManager(c.GlobalFlags.CGroupManager))
} else {
- unified, err := util.IsCgroup2UnifiedMode()
+ unified, err := cgroups.IsCgroup2UnifiedMode()
if err != nil {
return nil, err
}
diff --git a/cmd/podman/logs.go b/cmd/podman/logs.go
index a1ec9f4ee..25248db21 100644
--- a/cmd/podman/logs.go
+++ b/cmd/podman/logs.go
@@ -4,7 +4,7 @@ import (
"time"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/logs"
"github.com/containers/libpod/pkg/adapter"
"github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
@@ -80,13 +80,12 @@ func logsCmd(c *cliconfig.LogsValues) error {
sinceTime = since
}
- opts := &libpod.LogOptions{
+ options := &logs.LogOptions{
Details: c.Details,
Follow: c.Follow,
Since: sinceTime,
Tail: c.Tail,
Timestamps: c.Timestamps,
}
-
- return runtime.Log(c, opts)
+ return runtime.Log(c, options)
}
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index 847cc0731..248d63753 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -2,11 +2,11 @@ package main
import (
"context"
+ "github.com/containers/libpod/libpod"
"io"
"os"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
_ "github.com/containers/libpod/pkg/hooks/0.1.0"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/libpod/version"
@@ -59,7 +59,6 @@ var mainCommands = []*cobra.Command{
_stopCommand,
_tagCommand,
_topCommand,
- _umountCommand,
_unpauseCommand,
_versionCommand,
_waitCommand,
@@ -100,7 +99,7 @@ func initConfig() {
}
func before(cmd *cobra.Command, args []string) error {
- if err := libpod.SetXdgRuntimeDir(""); err != nil {
+ if err := libpod.SetXdgRuntimeDir(); err != nil {
logrus.Errorf(err.Error())
os.Exit(1)
}
diff --git a/cmd/podman/main_local.go b/cmd/podman/main_local.go
index 7a062cb4b..d5f70a28f 100644
--- a/cmd/podman/main_local.go
+++ b/cmd/podman/main_local.go
@@ -13,6 +13,7 @@ import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/cgroups"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/libpod/pkg/tracing"
"github.com/containers/libpod/pkg/util"
@@ -31,7 +32,7 @@ func init() {
cgroupManager = runtimeConfig.CgroupManager
}
cgroupHelp := "Cgroup manager to use (cgroupfs or systemd)"
- cgroupv2, _ := util.IsCgroup2UnifiedMode()
+ cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
if rootless.IsRootless() && !cgroupv2 {
cgroupManager = ""
cgroupHelp = "Cgroup manager is not supported in rootless mode"
diff --git a/cmd/podman/pause.go b/cmd/podman/pause.go
index cd8370082..ee5fd352d 100644
--- a/cmd/podman/pause.go
+++ b/cmd/podman/pause.go
@@ -1,11 +1,10 @@
package main
import (
- "os"
-
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
+ "github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -39,7 +38,7 @@ func init() {
}
func pauseCmd(c *cliconfig.PauseValues) error {
- if os.Geteuid() != 0 {
+ if rootless.IsRootless() && !remoteclient {
return errors.New("pause is not supported for rootless containers")
}
@@ -55,7 +54,7 @@ func pauseCmd(c *cliconfig.PauseValues) error {
}
ok, failures, err := runtime.PauseContainers(getContext(), c)
if err != nil {
- if errors.Cause(err) == libpod.ErrNoSuchCtr {
+ if errors.Cause(err) == define.ErrNoSuchCtr {
if len(c.InputArgs) > 1 {
exitCode = 125
} else {
diff --git a/cmd/podman/play_kube.go b/cmd/podman/play_kube.go
index b0f4a44eb..8a611dffa 100644
--- a/cmd/podman/play_kube.go
+++ b/cmd/podman/play_kube.go
@@ -1,35 +1,12 @@
package main
import (
- "context"
"fmt"
- "io"
- "io/ioutil"
- "os"
- "strings"
- "github.com/containers/image/types"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
- "github.com/containers/libpod/cmd/podman/shared"
- "github.com/containers/libpod/libpod"
- "github.com/containers/libpod/libpod/image"
- ns "github.com/containers/libpod/pkg/namespaces"
- "github.com/containers/libpod/pkg/spec"
- "github.com/containers/storage"
- "github.com/cri-o/ocicni/pkg/ocicni"
- "github.com/ghodss/yaml"
+ "github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
- "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
- "k8s.io/api/core/v1"
-)
-
-const (
- // https://kubernetes.io/docs/concepts/storage/volumes/#hostpath
- createDirectoryPermission = 0755
- // https://kubernetes.io/docs/concepts/storage/volumes/#hostpath
- createFilePermission = 0644
)
var (
@@ -81,289 +58,12 @@ func playKubeCmd(c *cliconfig.KubePlayValues) error {
}
ctx := getContext()
- runtime, err := libpodruntime.GetRuntime(ctx, &c.PodmanCommand)
+ runtime, err := adapter.GetRuntime(ctx, &c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
defer runtime.Shutdown(false)
- pod, err := playKubeYAMLCmd(c, ctx, runtime, args[0])
- if err != nil && pod != nil {
- if err2 := runtime.RemovePod(ctx, pod, true, true); err2 != nil {
- logrus.Errorf("unable to remove pod %s after failing to play kube", pod.ID())
- }
- }
+ _, err = runtime.PlayKubeYAML(ctx, c, args[0])
return err
}
-
-func playKubeYAMLCmd(c *cliconfig.KubePlayValues, ctx context.Context, runtime *libpod.Runtime, yamlFile string) (*libpod.Pod, error) {
- var (
- containers []*libpod.Container
- pod *libpod.Pod
- podOptions []libpod.PodCreateOption
- podYAML v1.Pod
- registryCreds *types.DockerAuthConfig
- writer io.Writer
- )
-
- content, err := ioutil.ReadFile(yamlFile)
- if err != nil {
- return nil, err
- }
-
- if err := yaml.Unmarshal(content, &podYAML); err != nil {
- return nil, errors.Wrapf(err, "unable to read %s as YAML", yamlFile)
- }
-
- // check for name collision between pod and container
- podName := podYAML.ObjectMeta.Name
- for _, n := range podYAML.Spec.Containers {
- if n.Name == podName {
- fmt.Printf("a container exists with the same name (%s) as the pod in your YAML file; changing pod name to %s_pod\n", podName, podName)
- podName = fmt.Sprintf("%s_pod", podName)
- }
- }
-
- podOptions = append(podOptions, libpod.WithInfraContainer())
- podOptions = append(podOptions, libpod.WithPodName(podName))
- // TODO for now we just used the default kernel namespaces; we need to add/subtract this from yaml
-
- nsOptions, err := shared.GetNamespaceOptions(strings.Split(shared.DefaultKernelNamespaces, ","))
- if err != nil {
- return nil, err
- }
- podOptions = append(podOptions, nsOptions...)
- podPorts := getPodPorts(podYAML.Spec.Containers)
- podOptions = append(podOptions, libpod.WithInfraContainerPorts(podPorts))
-
- // Create the Pod
- pod, err = runtime.NewPod(ctx, podOptions...)
- if err != nil {
- return pod, err
- }
-
- podInfraID, err := pod.InfraContainerID()
- if err != nil {
- return pod, err
- }
-
- namespaces := map[string]string{
- // Disabled during code review per mheon
- //"pid": fmt.Sprintf("container:%s", podInfraID),
- "net": fmt.Sprintf("container:%s", podInfraID),
- "user": fmt.Sprintf("container:%s", podInfraID),
- "ipc": fmt.Sprintf("container:%s", podInfraID),
- "uts": fmt.Sprintf("container:%s", podInfraID),
- }
- if !c.Quiet {
- writer = os.Stderr
- }
-
- dockerRegistryOptions := image.DockerRegistryOptions{
- DockerRegistryCreds: registryCreds,
- DockerCertPath: c.CertDir,
- }
- if c.Flag("tls-verify").Changed {
- dockerRegistryOptions.DockerInsecureSkipTLSVerify = types.NewOptionalBool(!c.TlsVerify)
- }
-
- // map from name to mount point
- volumes := make(map[string]string)
- for _, volume := range podYAML.Spec.Volumes {
- hostPath := volume.VolumeSource.HostPath
- if hostPath == nil {
- return pod, errors.Errorf("HostPath is currently the only supported VolumeSource")
- }
- if hostPath.Type != nil {
- switch *hostPath.Type {
- case v1.HostPathDirectoryOrCreate:
- if _, err := os.Stat(hostPath.Path); os.IsNotExist(err) {
- if err := os.Mkdir(hostPath.Path, createDirectoryPermission); err != nil {
- return pod, errors.Errorf("Error creating HostPath %s at %s", volume.Name, hostPath.Path)
- }
- }
- // unconditionally label a newly created volume as private
- if err := libpod.LabelVolumePath(hostPath.Path, false); err != nil {
- return pod, errors.Wrapf(err, "Error giving %s a label", hostPath.Path)
- }
- break
- case v1.HostPathFileOrCreate:
- if _, err := os.Stat(hostPath.Path); os.IsNotExist(err) {
- f, err := os.OpenFile(hostPath.Path, os.O_RDONLY|os.O_CREATE, createFilePermission)
- if err != nil {
- return pod, errors.Errorf("Error creating HostPath %s at %s", volume.Name, hostPath.Path)
- }
- if err := f.Close(); err != nil {
- logrus.Warnf("Error in closing newly created HostPath file: %v", err)
- }
- }
- // unconditionally label a newly created volume as private
- if err := libpod.LabelVolumePath(hostPath.Path, false); err != nil {
- return pod, errors.Wrapf(err, "Error giving %s a label", hostPath.Path)
- }
- break
- case v1.HostPathDirectory:
- case v1.HostPathFile:
- case v1.HostPathUnset:
- // do nothing here because we will verify the path exists in validateVolumeHostDir
- break
- default:
- return pod, errors.Errorf("Directories are the only supported HostPath type")
- }
- }
-
- if err := createconfig.ValidateVolumeHostDir(hostPath.Path); err != nil {
- return pod, errors.Wrapf(err, "Error in parsing HostPath in YAML")
- }
- volumes[volume.Name] = hostPath.Path
- }
-
- for _, container := range podYAML.Spec.Containers {
- newImage, err := runtime.ImageRuntime().New(ctx, container.Image, c.SignaturePolicy, c.Authfile, writer, &dockerRegistryOptions, image.SigningOptions{}, false, nil)
- if err != nil {
- return pod, err
- }
- createConfig, err := kubeContainerToCreateConfig(ctx, container, runtime, newImage, namespaces, volumes, pod.ID())
- if err != nil {
- return pod, err
- }
- ctr, err := shared.CreateContainerFromCreateConfig(runtime, createConfig, ctx, pod)
- if err != nil {
- return pod, err
- }
- containers = append(containers, ctr)
- }
-
- // start the containers
- for _, ctr := range containers {
- if err := ctr.Start(ctx, true); err != nil {
- // Making this a hard failure here to avoid a mess
- // the other containers are in created status
- return pod, err
- }
- }
-
- // We've now successfully converted this YAML into a pod
- // print our pod and containers, signifying we succeeded
- fmt.Printf("Pod:\n%s\n", pod.ID())
- if len(containers) == 1 {
- fmt.Printf("Container:\n")
- }
- if len(containers) > 1 {
- fmt.Printf("Containers:\n")
- }
- for _, ctr := range containers {
- fmt.Println(ctr.ID())
- }
-
- return pod, nil
-}
-
-// getPodPorts converts a slice of kube container descriptions to an
-// array of ocicni portmapping descriptions usable in libpod
-func getPodPorts(containers []v1.Container) []ocicni.PortMapping {
- var infraPorts []ocicni.PortMapping
- for _, container := range containers {
- for _, p := range container.Ports {
- portBinding := ocicni.PortMapping{
- HostPort: p.HostPort,
- ContainerPort: p.ContainerPort,
- Protocol: strings.ToLower(string(p.Protocol)),
- }
- if p.HostIP != "" {
- logrus.Debug("HostIP on port bindings is not supported")
- }
- infraPorts = append(infraPorts, portBinding)
- }
- }
- return infraPorts
-}
-
-// kubeContainerToCreateConfig takes a v1.Container and returns a createconfig describing a container
-func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container, runtime *libpod.Runtime, newImage *image.Image, namespaces map[string]string, volumes map[string]string, podID string) (*createconfig.CreateConfig, error) {
- var (
- containerConfig createconfig.CreateConfig
- )
-
- // The default for MemorySwappiness is -1, not 0
- containerConfig.Resources.MemorySwappiness = -1
-
- containerConfig.Image = containerYAML.Image
- containerConfig.ImageID = newImage.ID()
- containerConfig.Name = containerYAML.Name
- containerConfig.Tty = containerYAML.TTY
- containerConfig.WorkDir = containerYAML.WorkingDir
-
- containerConfig.Pod = podID
-
- imageData, _ := newImage.Inspect(ctx)
-
- containerConfig.User = "0"
- if imageData != nil {
- containerConfig.User = imageData.Config.User
- }
-
- if containerConfig.SecurityOpts != nil {
- if containerYAML.SecurityContext.ReadOnlyRootFilesystem != nil {
- containerConfig.ReadOnlyRootfs = *containerYAML.SecurityContext.ReadOnlyRootFilesystem
- }
- if containerYAML.SecurityContext.Privileged != nil {
- containerConfig.Privileged = *containerYAML.SecurityContext.Privileged
- }
-
- if containerYAML.SecurityContext.AllowPrivilegeEscalation != nil {
- containerConfig.NoNewPrivs = !*containerYAML.SecurityContext.AllowPrivilegeEscalation
- }
- }
-
- containerConfig.Command = []string{}
- if imageData != nil && imageData.Config != nil {
- containerConfig.Command = append(containerConfig.Command, imageData.Config.Entrypoint...)
- }
- if len(containerConfig.Command) != 0 {
- containerConfig.Command = append(containerConfig.Command, containerYAML.Command...)
- } else if imageData != nil && imageData.Config != nil {
- containerConfig.Command = append(containerConfig.Command, imageData.Config.Cmd...)
- }
- if imageData != nil && len(containerConfig.Command) == 0 {
- return nil, errors.Errorf("No command specified in container YAML or as CMD or ENTRYPOINT in this image for %s", containerConfig.Name)
- }
-
- containerConfig.StopSignal = 15
-
- // If the user does not pass in ID mappings, just set to basics
- if containerConfig.IDMappings == nil {
- containerConfig.IDMappings = &storage.IDMappingOptions{}
- }
-
- containerConfig.NetMode = ns.NetworkMode(namespaces["net"])
- containerConfig.IpcMode = ns.IpcMode(namespaces["ipc"])
- containerConfig.UtsMode = ns.UTSMode(namespaces["uts"])
- // disabled in code review per mheon
- //containerConfig.PidMode = ns.PidMode(namespaces["pid"])
- containerConfig.UsernsMode = ns.UsernsMode(namespaces["user"])
- if len(containerConfig.WorkDir) == 0 {
- containerConfig.WorkDir = "/"
- }
-
- // Set default environment variables and incorporate data from image, if necessary
- envs := shared.EnvVariablesFromData(imageData)
-
- // Environment Variables
- for _, e := range containerYAML.Env {
- envs[e.Name] = e.Value
- }
- containerConfig.Env = envs
-
- for _, volume := range containerYAML.VolumeMounts {
- host_path, exists := volumes[volume.Name]
- if !exists {
- return nil, errors.Errorf("Volume mount %s specified for container but not configured in volumes", volume.Name)
- }
- if err := createconfig.ValidateVolumeCtrDir(volume.MountPath); err != nil {
- return nil, errors.Wrapf(err, "error in parsing MountPath")
- }
- containerConfig.Volumes = append(containerConfig.Volumes, fmt.Sprintf("%s:%s", host_path, volume.MountPath))
- }
- return &containerConfig, nil
-}
diff --git a/cmd/podman/pod_create.go b/cmd/podman/pod_create.go
index c891f2c7b..0abf84756 100644
--- a/cmd/podman/pod_create.go
+++ b/cmd/podman/pod_create.go
@@ -6,8 +6,9 @@ import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/shared"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
+ "github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -45,8 +46,8 @@ func init() {
flags.StringVar(&podCreateCommand.CgroupParent, "cgroup-parent", "", "Set parent cgroup for the pod")
flags.BoolVar(&podCreateCommand.Infra, "infra", true, "Create an infra container associated with the pod to share namespaces with")
- flags.StringVar(&podCreateCommand.InfraImage, "infra-image", libpod.DefaultInfraImage, "The image of the infra container to associate with the pod")
- flags.StringVar(&podCreateCommand.InfraCommand, "infra-command", libpod.DefaultInfraCommand, "The command to run on the infra container when the pod is started")
+ flags.StringVar(&podCreateCommand.InfraImage, "infra-image", define.DefaultInfraImage, "The image of the infra container to associate with the pod")
+ flags.StringVar(&podCreateCommand.InfraCommand, "infra-command", define.DefaultInfraCommand, "The command to run on the infra container when the pod is started")
flags.StringSliceVar(&podCreateCommand.LabelFile, "label-file", []string{}, "Read in a line delimited file of labels")
flags.StringSliceVarP(&podCreateCommand.Labels, "label", "l", []string{}, "Set metadata on pod (default [])")
flags.StringVarP(&podCreateCommand.Name, "name", "n", "", "Assign a name to the pod")
@@ -78,7 +79,7 @@ func podCreateCmd(c *cliconfig.PodCreateValues) error {
return errors.Errorf("You cannot share kernel namespaces on the pod level without an infra container")
}
if c.Flag("pod-id-file").Changed && os.Geteuid() == 0 {
- podIdFile, err = libpod.OpenExclusiveFile(c.PodIDFile)
+ podIdFile, err = util.OpenExclusiveFile(c.PodIDFile)
if err != nil && os.IsExist(err) {
return errors.Errorf("pod id file exists. Ensure another pod is not using it or delete %s", c.PodIDFile)
}
diff --git a/cmd/podman/pod_kill.go b/cmd/podman/pod_kill.go
index c1ea66126..6be79363a 100644
--- a/cmd/podman/pod_kill.go
+++ b/cmd/podman/pod_kill.go
@@ -55,7 +55,7 @@ func podKillCmd(c *cliconfig.PodKillValues) error {
}
defer runtime.Shutdown(false)
- var killSignal uint = uint(syscall.SIGTERM)
+ killSignal := uint(syscall.SIGTERM)
if c.Signal != "" {
// Check if the signalString provided by the user is valid
diff --git a/cmd/podman/pod_ps.go b/cmd/podman/pod_ps.go
index b9dcbc05d..fbea5124e 100644
--- a/cmd/podman/pod_ps.go
+++ b/cmd/podman/pod_ps.go
@@ -11,7 +11,7 @@ import (
"github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/shared"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
"github.com/containers/libpod/pkg/util"
"github.com/docker/go-units"
@@ -282,7 +282,7 @@ func generatePodFilterFuncs(filter, filterValue string) (func(pod *adapter.Pod)
}
for _, ctr_status := range ctr_statuses {
state := ctr_status.String()
- if ctr_status == libpod.ContainerStateConfigured {
+ if ctr_status == define.ContainerStateConfigured {
state = "created"
}
if state == filterValue {
@@ -504,15 +504,15 @@ func getAndSortPodJSONParams(pods []*adapter.Pod, opts podPsOptions) ([]podPsJSO
}
var status string
switch batchInfo.ConState {
- case libpod.ContainerStateExited:
+ case define.ContainerStateExited:
fallthrough
- case libpod.ContainerStateStopped:
+ case define.ContainerStateStopped:
status = EXITED
- case libpod.ContainerStateRunning:
+ case define.ContainerStateRunning:
status = RUNNING
- case libpod.ContainerStatePaused:
+ case define.ContainerStatePaused:
status = PAUSED
- case libpod.ContainerStateCreated, libpod.ContainerStateConfigured:
+ case define.ContainerStateCreated, define.ContainerStateConfigured:
status = CREATED
default:
status = ERROR
diff --git a/cmd/podman/pod_stats.go b/cmd/podman/pod_stats.go
index e0e5ca24e..97aa52f5d 100644
--- a/cmd/podman/pod_stats.go
+++ b/cmd/podman/pod_stats.go
@@ -13,6 +13,7 @@ import (
"github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -153,7 +154,7 @@ func podStatsCmd(c *cliconfig.PodStatsValues) error {
for _, p := range pods {
prevStat := getPreviousPodContainerStats(p.ID(), previousPodStats)
newPodStats, err := p.GetPodStats(prevStat)
- if errors.Cause(err) == libpod.ErrNoSuchPod {
+ if errors.Cause(err) == define.ErrNoSuchPod {
continue
}
if err != nil {
@@ -270,7 +271,7 @@ func printPSFormat(format string, stats []*podStatOut, headerNames map[string]st
func outputToStdOut(stats []*podStatOut) {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
- outFormat := ("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n")
+ outFormat := "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
fmt.Fprintf(w, outFormat, "POD", "CID", "NAME", "CPU %", "MEM USAGE/ LIMIT", "MEM %", "NET IO", "BLOCK IO", "PIDS")
for _, i := range stats {
if len(stats) == 0 {
diff --git a/cmd/podman/pod_top.go b/cmd/podman/pod_top.go
index 64e32318e..72137b5a7 100644
--- a/cmd/podman/pod_top.go
+++ b/cmd/podman/pod_top.go
@@ -2,13 +2,13 @@ package main
import (
"fmt"
- "github.com/containers/libpod/pkg/adapter"
"os"
"strings"
"text/tabwriter"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/adapter"
+ "github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -55,7 +55,7 @@ func podTopCmd(c *cliconfig.PodTopValues) error {
args := c.InputArgs
if c.ListDescriptors {
- descriptors, err := libpod.GetContainerPidInformationDescriptors()
+ descriptors, err := util.GetContainerPidInformationDescriptors()
if err != nil {
return err
}
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go
index eb5181126..75e07d325 100644
--- a/cmd/podman/ps.go
+++ b/cmd/podman/ps.go
@@ -197,7 +197,11 @@ func init() {
}
func psCmd(c *cliconfig.PsValues) error {
- var watch bool
+ var (
+ watch bool
+ runtime *adapter.LocalRuntime
+ err error
+ )
if c.Watch > 0 {
watch = true
@@ -210,8 +214,11 @@ func psCmd(c *cliconfig.PsValues) error {
if err := checkFlagsPassed(c); err != nil {
return errors.Wrapf(err, "error with flags passed")
}
-
- runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
+ if !c.Size {
+ runtime, err = adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand)
+ } else {
+ runtime, err = adapter.GetRuntime(getContext(), &c.PodmanCommand)
+ }
if err != nil {
return errors.Wrapf(err, "error creating libpod runtime")
}
@@ -308,57 +315,6 @@ func sortPsOutput(sortBy string, psOutput psSorted) (psSorted, error) {
return psOutput, nil
}
-// getLabels converts the labels to a string of the form "key=value, key2=value2"
-func formatLabels(labels map[string]string) string {
- var arr []string
- if len(labels) > 0 {
- for key, val := range labels {
- temp := key + "=" + val
- arr = append(arr, temp)
- }
- return strings.Join(arr, ",")
- }
- return ""
-}
-
-// getMounts converts the volumes mounted to a string of the form "mount1, mount2"
-// it truncates it if noTrunc is false
-func getMounts(mounts []string, noTrunc bool) string {
- return strings.Join(getMountsArray(mounts, noTrunc), ",")
-}
-
-func getMountsArray(mounts []string, noTrunc bool) []string {
- var arr []string
- if len(mounts) == 0 {
- return mounts
- }
- for _, mount := range mounts {
- splitArr := strings.Split(mount, ":")
- if len(splitArr[0]) > mountTruncLength && !noTrunc {
- arr = append(arr, splitArr[0][:mountTruncLength]+"...")
- continue
- }
- arr = append(arr, splitArr[0])
- }
- return arr
-}
-
-// portsToString converts the ports used to a string of the from "port1, port2"
-func portsToString(ports []ocicni.PortMapping) string {
- var portDisplay []string
- if len(ports) == 0 {
- return ""
- }
- for _, v := range ports {
- hostIP := v.HostIP
- if hostIP == "" {
- hostIP = "0.0.0.0"
- }
- portDisplay = append(portDisplay, fmt.Sprintf("%s:%d->%d/%s", hostIP, v.HostPort, v.ContainerPort, v.Protocol))
- }
- return strings.Join(portDisplay, ", ")
-}
-
func printFormat(format string, containers []shared.PsContainerOutput) error {
// return immediately if no containers are present
if len(containers) == 0 {
diff --git a/cmd/podman/pull.go b/cmd/podman/pull.go
index 115f437d8..a05c78928 100644
--- a/cmd/podman/pull.go
+++ b/cmd/podman/pull.go
@@ -14,7 +14,7 @@ import (
"github.com/containers/libpod/libpod/image"
"github.com/containers/libpod/pkg/adapter"
"github.com/containers/libpod/pkg/util"
- opentracing "github.com/opentracing/opentracing-go"
+ "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
diff --git a/cmd/podman/remoteclientconfig/configfile.go b/cmd/podman/remoteclientconfig/configfile.go
index aa3e82a31..06e82b186 100644
--- a/cmd/podman/remoteclientconfig/configfile.go
+++ b/cmd/podman/remoteclientconfig/configfile.go
@@ -22,7 +22,7 @@ func ReadRemoteConfig(reader io.Reader) (*RemoteConfig, error) {
// We need to validate each remote connection has fields filled out
for name, conn := range remoteConfig.Connections {
if len(conn.Destination) < 1 {
- return nil, errors.Errorf("connection %s has no destination defined", name)
+ return nil, errors.Errorf("connection %q has no destination defined", name)
}
}
return &remoteConfig, err
diff --git a/cmd/podman/restart.go b/cmd/podman/restart.go
index 437676eef..89bda7d6c 100644
--- a/cmd/podman/restart.go
+++ b/cmd/podman/restart.go
@@ -2,7 +2,7 @@ package main
import (
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -39,8 +39,8 @@ func init() {
flags.BoolVarP(&restartCommand.All, "all", "a", false, "Restart all non-running containers")
flags.BoolVarP(&restartCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.BoolVar(&restartCommand.Running, "running", false, "Restart only running containers when --all is used")
- flags.UintVarP(&restartCommand.Timeout, "timeout", "t", libpod.CtrRemoveTimeout, "Seconds to wait for stop before killing the container")
- flags.UintVar(&restartCommand.Timeout, "time", libpod.CtrRemoveTimeout, "Seconds to wait for stop before killing the container")
+ flags.UintVarP(&restartCommand.Timeout, "timeout", "t", define.CtrRemoveTimeout, "Seconds to wait for stop before killing the container")
+ flags.UintVar(&restartCommand.Timeout, "time", define.CtrRemoveTimeout, "Seconds to wait for stop before killing the container")
markFlagHiddenForRemoteClient("latest", flags)
}
@@ -48,7 +48,7 @@ func init() {
func restartCmd(c *cliconfig.RestartValues) error {
all := c.All
if len(c.InputArgs) < 1 && !c.Latest && !all {
- return errors.Wrapf(libpod.ErrInvalidArg, "you must provide at least one container name or ID")
+ return errors.Wrapf(define.ErrInvalidArg, "you must provide at least one container name or ID")
}
runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
@@ -59,7 +59,7 @@ func restartCmd(c *cliconfig.RestartValues) error {
ok, failures, err := runtime.Restart(getContext(), c)
if err != nil {
- if errors.Cause(err) == libpod.ErrNoSuchCtr {
+ if errors.Cause(err) == define.ErrNoSuchCtr {
if len(c.InputArgs) > 1 {
exitCode = 125
} else {
diff --git a/cmd/podman/restore.go b/cmd/podman/restore.go
index 6e445e5df..fcac9855d 100644
--- a/cmd/podman/restore.go
+++ b/cmd/podman/restore.go
@@ -2,7 +2,6 @@ package main
import (
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/adapter"
"github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
@@ -61,13 +60,6 @@ func restoreCmd(c *cliconfig.RestoreValues, cmd *cobra.Command) error {
}
defer runtime.Shutdown(false)
- options := libpod.ContainerCheckpointOptions{
- Keep: c.Keep,
- TCPEstablished: c.TcpEstablished,
- TargetFile: c.Import,
- Name: c.Name,
- }
-
if c.Import == "" && c.Name != "" {
return errors.Errorf("--name can only used with --import")
}
@@ -93,5 +85,5 @@ func restoreCmd(c *cliconfig.RestoreValues, cmd *cobra.Command) error {
return errors.Errorf("you must provide at least one name or id")
}
- return runtime.Restore(getContext(), c, options)
+ return runtime.Restore(getContext(), c)
}
diff --git a/cmd/podman/rm.go b/cmd/podman/rm.go
index 2710a8194..0f81a0d63 100644
--- a/cmd/podman/rm.go
+++ b/cmd/podman/rm.go
@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -65,7 +65,7 @@ func rmCmd(c *cliconfig.RmValues) error {
ok, failures, err := runtime.RemoveContainers(getContext(), c)
if err != nil {
- if errors.Cause(err) == libpod.ErrNoSuchCtr {
+ if errors.Cause(err) == define.ErrNoSuchCtr {
if len(c.InputArgs) > 1 {
exitCode = 125
} else {
diff --git a/cmd/podman/run.go b/cmd/podman/run.go
index 7d84d716b..6f089e5a4 100644
--- a/cmd/podman/run.go
+++ b/cmd/podman/run.go
@@ -3,7 +3,7 @@ package main
import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/pkg/adapter"
- opentracing "github.com/opentracing/opentracing-go"
+ "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
diff --git a/cmd/podman/runlabel.go b/cmd/podman/runlabel.go
index 59cbc7aa4..be5d29139 100644
--- a/cmd/podman/runlabel.go
+++ b/cmd/podman/runlabel.go
@@ -10,7 +10,7 @@ import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/cmd/podman/shared"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/image"
"github.com/containers/libpod/pkg/util"
"github.com/containers/libpod/utils"
@@ -169,7 +169,7 @@ func runlabelCmd(c *cliconfig.RunlabelValues) error {
name := cmd[i+1]
ctr, err := runtime.LookupContainer(name)
if err != nil {
- if errors.Cause(err) != libpod.ErrNoSuchCtr {
+ if errors.Cause(err) != define.ErrNoSuchCtr {
logrus.Debugf("Error occurred searching for container %s: %s", name, err.Error())
return err
}
diff --git a/cmd/podman/shared/container.go b/cmd/podman/shared/container.go
index f24a2358f..df4583be6 100644
--- a/cmd/podman/shared/container.go
+++ b/cmd/podman/shared/container.go
@@ -15,6 +15,7 @@ import (
"github.com/containers/image/types"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/image"
"github.com/containers/libpod/pkg/util"
"github.com/cri-o/ocicni/pkg/ocicni"
@@ -50,7 +51,7 @@ type PsOptions struct {
// container related information
type BatchContainerStruct struct {
ConConfig *libpod.ContainerConfig
- ConState libpod.ContainerStatus
+ ConState define.ContainerStatus
ExitCode int32
Exited bool
Pid int
@@ -70,7 +71,7 @@ type PsContainerOutput struct {
Names string
IsInfra bool
Status string
- State libpod.ContainerStatus
+ State define.ContainerStatus
Pid int
Size *ContainerSize
Pod string
@@ -112,7 +113,7 @@ type ContainerSize struct {
// be called in PBatch
func NewBatchContainer(ctr *libpod.Container, opts PsOptions) (PsContainerOutput, error) {
var (
- conState libpod.ContainerStatus
+ conState define.ContainerStatus
command string
created string
status string
@@ -183,16 +184,16 @@ func NewBatchContainer(ctr *libpod.Container, opts PsOptions) (PsContainerOutput
}
switch conState.String() {
- case libpod.ContainerStateExited.String():
+ case define.ContainerStateExited.String():
fallthrough
- case libpod.ContainerStateStopped.String():
+ case define.ContainerStateStopped.String():
exitedSince := units.HumanDuration(time.Since(exitedAt))
status = fmt.Sprintf("Exited (%d) %s ago", exitCode, exitedSince)
- case libpod.ContainerStateRunning.String():
+ case define.ContainerStateRunning.String():
status = "Up " + units.HumanDuration(time.Since(startedAt)) + " ago"
- case libpod.ContainerStatePaused.String():
+ case define.ContainerStatePaused.String():
status = "Paused"
- case libpod.ContainerStateCreated.String(), libpod.ContainerStateConfigured.String():
+ case define.ContainerStateCreated.String(), define.ContainerStateConfigured.String():
status = "Created"
default:
status = "Error"
@@ -278,8 +279,8 @@ func generateContainerFilterFuncs(filter, filterValue string, r *libpod.Runtime)
return strings.Contains(c.ID(), filterValue)
}, nil
case "label":
- var filterArray []string = strings.SplitN(filterValue, "=", 2)
- var filterKey string = filterArray[0]
+ var filterArray = strings.SplitN(filterValue, "=", 2)
+ var filterKey = filterArray[0]
if len(filterArray) > 1 {
filterValue = filterArray[1]
} else {
@@ -322,9 +323,9 @@ func generateContainerFilterFuncs(filter, filterValue string, r *libpod.Runtime)
filterValue = "exited"
}
state := status.String()
- if status == libpod.ContainerStateConfigured {
+ if status == define.ContainerStateConfigured {
state = "created"
- } else if status == libpod.ContainerStateStopped {
+ } else if status == define.ContainerStateStopped {
state = "exited"
}
return state == filterValue
@@ -489,7 +490,7 @@ func PBatch(containers []*libpod.Container, workers int, opts PsOptions) []PsCon
// We sort out running vs non-running here to save lots of copying
// later.
if !opts.All && !opts.Latest && opts.Last < 1 {
- if !res.IsInfra && res.State == libpod.ContainerStateRunning {
+ if !res.IsInfra && res.State == define.ContainerStateRunning {
psResults = append(psResults, res)
}
} else {
@@ -504,7 +505,7 @@ func PBatch(containers []*libpod.Container, workers int, opts PsOptions) []PsCon
func BatchContainerOp(ctr *libpod.Container, opts PsOptions) (BatchContainerStruct, error) {
var (
conConfig *libpod.ContainerConfig
- conState libpod.ContainerStatus
+ conState define.ContainerStatus
err error
exitCode int32
exited bool
@@ -824,7 +825,7 @@ func GenerateKube(name string, service bool, r *libpod.Runtime) (*v1.Pod, *v1.Se
podYAML, servicePorts, err = pod.GenerateForKube()
} else {
if len(container.Dependencies()) > 0 {
- return nil, nil, errors.Wrapf(libpod.ErrNotImplemented, "containers with dependencies")
+ return nil, nil, errors.Wrapf(define.ErrNotImplemented, "containers with dependencies")
}
podYAML, err = container.GenerateForKube()
}
diff --git a/cmd/podman/shared/container_inspect.go b/cmd/podman/shared/container_inspect.go
index c89daf6bb..a8094466e 100644
--- a/cmd/podman/shared/container_inspect.go
+++ b/cmd/podman/shared/container_inspect.go
@@ -4,7 +4,7 @@ import (
"github.com/containers/libpod/libpod"
cc "github.com/containers/libpod/pkg/spec"
"github.com/docker/go-connections/nat"
- specs "github.com/opencontainers/runtime-spec/specs-go"
+ "github.com/opencontainers/runtime-spec/specs-go"
)
// InspectContainer holds all inspect data for a container.
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index eee5f515d..31ac9a3a1 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -56,7 +56,7 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
}
if c.IsSet("cidfile") && os.Geteuid() == 0 {
- cidFile, err = libpod.OpenExclusiveFile(c.String("cidfile"))
+ cidFile, err = util.OpenExclusiveFile(c.String("cidfile"))
if err != nil && os.IsExist(err) {
return nil, nil, errors.Errorf("container id file exists. Ensure another container is not using it or delete %s", c.String("cidfile"))
}
@@ -690,7 +690,7 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
StopTimeout: c.Uint("stop-timeout"),
Sysctl: sysctl,
Systemd: systemd,
- Tmpfs: c.StringSlice("tmpfs"),
+ Tmpfs: c.StringArray("tmpfs"),
Tty: tty,
User: user,
UsernsMode: usernsMode,
diff --git a/cmd/podman/shared/create_cli.go b/cmd/podman/shared/create_cli.go
index 7f158b09a..4bfef8b62 100644
--- a/cmd/podman/shared/create_cli.go
+++ b/cmd/podman/shared/create_cli.go
@@ -5,9 +5,9 @@ import (
"strings"
"github.com/containers/libpod/cmd/podman/shared/parse"
+ "github.com/containers/libpod/pkg/cgroups"
cc "github.com/containers/libpod/pkg/spec"
"github.com/containers/libpod/pkg/sysinfo"
- "github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -78,7 +78,7 @@ func addWarning(warnings []string, msg string) []string {
func verifyContainerResources(config *cc.CreateConfig, update bool) ([]string, error) {
warnings := []string{}
- cgroup2, err := util.IsCgroup2UnifiedMode()
+ cgroup2, err := cgroups.IsCgroup2UnifiedMode()
if err != nil || cgroup2 {
return warnings, err
}
diff --git a/cmd/podman/shared/intermediate.go b/cmd/podman/shared/intermediate.go
index a38e4d47a..eecd1604c 100644
--- a/cmd/podman/shared/intermediate.go
+++ b/cmd/podman/shared/intermediate.go
@@ -448,7 +448,7 @@ func NewIntermediateLayer(c *cliconfig.PodmanCommand, remote bool) GenericCLIRes
m["subuidname"] = newCRString(c, "subuidname")
m["sysctl"] = newCRStringSlice(c, "sysctl")
m["systemd"] = newCRBool(c, "systemd")
- m["tmpfs"] = newCRStringSlice(c, "tmpfs")
+ m["tmpfs"] = newCRStringArray(c, "tmpfs")
m["tty"] = newCRBool(c, "tty")
m["uidmap"] = newCRStringSlice(c, "uidmap")
m["ulimit"] = newCRStringSlice(c, "ulimit")
diff --git a/cmd/podman/shared/pod.go b/cmd/podman/shared/pod.go
index 3f4cb0312..ab6d1f144 100644
--- a/cmd/podman/shared/pod.go
+++ b/cmd/podman/shared/pod.go
@@ -4,6 +4,7 @@ import (
"strconv"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/docker/go-connections/nat"
"github.com/pkg/errors"
@@ -29,7 +30,7 @@ func GetPodStatus(pod *libpod.Pod) (string, error) {
return CreatePodStatusResults(ctrStatuses)
}
-func CreatePodStatusResults(ctrStatuses map[string]libpod.ContainerStatus) (string, error) {
+func CreatePodStatusResults(ctrStatuses map[string]define.ContainerStatus) (string, error) {
ctrNum := len(ctrStatuses)
if ctrNum == 0 {
return PodStateCreated, nil
@@ -43,15 +44,15 @@ func CreatePodStatusResults(ctrStatuses map[string]libpod.ContainerStatus) (stri
}
for _, ctrStatus := range ctrStatuses {
switch ctrStatus {
- case libpod.ContainerStateExited:
+ case define.ContainerStateExited:
fallthrough
- case libpod.ContainerStateStopped:
+ case define.ContainerStateStopped:
statuses[PodStateStopped]++
- case libpod.ContainerStateRunning:
+ case define.ContainerStateRunning:
statuses[PodStateRunning]++
- case libpod.ContainerStatePaused:
+ case define.ContainerStatePaused:
statuses[PodStatePaused]++
- case libpod.ContainerStateCreated, libpod.ContainerStateConfigured:
+ case define.ContainerStateCreated, define.ContainerStateConfigured:
statuses[PodStateCreated]++
default:
statuses[PodStateErrored]++
diff --git a/cmd/podman/start.go b/cmd/podman/start.go
index bd34010f2..165273114 100644
--- a/cmd/podman/start.go
+++ b/cmd/podman/start.go
@@ -2,7 +2,7 @@ package main
import (
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
@@ -35,7 +35,7 @@ func init() {
startCommand.SetUsageTemplate(UsageTemplate())
flags := startCommand.Flags()
flags.BoolVarP(&startCommand.Attach, "attach", "a", false, "Attach container's STDOUT and STDERR")
- flags.StringVar(&startCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _")
+ flags.StringVar(&startCommand.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
flags.BoolVarP(&startCommand.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
flags.BoolVarP(&startCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.BoolVar(&startCommand.SigProxy, "sig-proxy", false, "Proxy received signals to the process (default true if attaching, false otherwise)")
@@ -62,7 +62,7 @@ func startCmd(c *cliconfig.StartValues) error {
sigProxy := c.SigProxy || attach
if sigProxy && !attach {
- return errors.Wrapf(libpod.ErrInvalidArg, "you cannot use sig-proxy without --attach")
+ return errors.Wrapf(define.ErrInvalidArg, "you cannot use sig-proxy without --attach")
}
runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
diff --git a/cmd/podman/stats.go b/cmd/podman/stats.go
index c2b2a688c..d79eebc3d 100644
--- a/cmd/podman/stats.go
+++ b/cmd/podman/stats.go
@@ -12,6 +12,7 @@ import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -127,7 +128,7 @@ func statsCmd(c *cliconfig.StatsValues) error {
initialStats, err := ctr.GetContainerStats(&libpod.ContainerStats{})
if err != nil {
// when doing "all", dont worry about containers that are not running
- if c.All && errors.Cause(err) == libpod.ErrCtrRemoved || errors.Cause(err) == libpod.ErrNoSuchCtr || errors.Cause(err) == libpod.ErrCtrStateInvalid {
+ if c.All && errors.Cause(err) == define.ErrCtrRemoved || errors.Cause(err) == define.ErrNoSuchCtr || errors.Cause(err) == define.ErrCtrStateInvalid {
continue
}
return err
@@ -148,7 +149,7 @@ func statsCmd(c *cliconfig.StatsValues) error {
id := ctr.ID()
if _, ok := containerStats[ctr.ID()]; !ok {
initialStats, err := ctr.GetContainerStats(&libpod.ContainerStats{})
- if errors.Cause(err) == libpod.ErrCtrRemoved || errors.Cause(err) == libpod.ErrNoSuchCtr || errors.Cause(err) == libpod.ErrCtrStateInvalid {
+ if errors.Cause(err) == define.ErrCtrRemoved || errors.Cause(err) == define.ErrNoSuchCtr || errors.Cause(err) == define.ErrCtrStateInvalid {
// skip dealing with a container that is gone
continue
}
@@ -158,7 +159,7 @@ func statsCmd(c *cliconfig.StatsValues) error {
containerStats[id] = initialStats
}
stats, err := ctr.GetContainerStats(containerStats[id])
- if err != nil && errors.Cause(err) != libpod.ErrNoSuchCtr {
+ if err != nil && errors.Cause(err) != define.ErrNoSuchCtr {
return err
}
// replace the previous measurement with the current one
diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go
index d88c90deb..5c93904ef 100644
--- a/cmd/podman/stop.go
+++ b/cmd/podman/stop.go
@@ -2,7 +2,7 @@ package main
import (
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
@@ -40,8 +40,8 @@ func init() {
flags := stopCommand.Flags()
flags.BoolVarP(&stopCommand.All, "all", "a", false, "Stop all running containers")
flags.BoolVarP(&stopCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
- flags.UintVar(&stopCommand.Timeout, "time", libpod.CtrRemoveTimeout, "Seconds to wait for stop before killing the container")
- flags.UintVarP(&stopCommand.Timeout, "timeout", "t", libpod.CtrRemoveTimeout, "Seconds to wait for stop before killing the container")
+ flags.UintVar(&stopCommand.Timeout, "time", define.CtrRemoveTimeout, "Seconds to wait for stop before killing the container")
+ flags.UintVarP(&stopCommand.Timeout, "timeout", "t", define.CtrRemoveTimeout, "Seconds to wait for stop before killing the container")
markFlagHiddenForRemoteClient("latest", flags)
}
diff --git a/cmd/podman/system_df.go b/cmd/podman/system_df.go
index d2163d0d7..ab67e4f07 100644
--- a/cmd/podman/system_df.go
+++ b/cmd/podman/system_df.go
@@ -1,3 +1,5 @@
+//+build !remoteclient
+
package main
import (
@@ -12,8 +14,9 @@ import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/image"
- units "github.com/docker/go-units"
+ "github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -358,7 +361,7 @@ func ctrIsActive(ctr *libpod.Container) (bool, error) {
if err != nil {
return false, err
}
- return state == libpod.ContainerStatePaused || state == libpod.ContainerStateRunning, nil
+ return state == define.ContainerStatePaused || state == define.ContainerStateRunning, nil
}
func activeContainers(containers []*libpod.Container) (map[string]*libpod.Container, error) {
diff --git a/cmd/podman/top.go b/cmd/podman/top.go
index 8583eccb5..ba6cbe72d 100644
--- a/cmd/podman/top.go
+++ b/cmd/podman/top.go
@@ -7,14 +7,14 @@ import (
"text/tabwriter"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/adapter"
+ "github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func getDescriptorString() string {
- descriptors, err := libpod.GetContainerPidInformationDescriptors()
+ descriptors, err := util.GetContainerPidInformationDescriptors()
if err == nil {
return fmt.Sprintf(`
Format Descriptors:
@@ -67,7 +67,7 @@ func topCmd(c *cliconfig.TopValues) error {
args := c.InputArgs
if c.ListDescriptors {
- descriptors, err := libpod.GetContainerPidInformationDescriptors()
+ descriptors, err := util.GetContainerPidInformationDescriptors()
if err != nil {
return err
}
diff --git a/cmd/podman/tree.go b/cmd/podman/tree.go
index 6490c609d..48e192990 100644
--- a/cmd/podman/tree.go
+++ b/cmd/podman/tree.go
@@ -72,7 +72,11 @@ func printTree(imageInfo *image.InfoImage, layerInfoMap map[string]*image.LayerI
fmt.Printf("Image ID: %s\n", imageInfo.ID[:12])
fmt.Printf("Tags:\t %s\n", imageInfo.Tags)
fmt.Printf("Size:\t %v\n", units.HumanSizeWithPrecision(float64(*size), 4))
- fmt.Printf(fmt.Sprintf("Image Layers\n"))
+ if img.TopLayer() != "" {
+ fmt.Printf("Image Layers\n")
+ } else {
+ fmt.Printf("No Image Layers\n")
+ }
if !whatRequires {
// fill imageInfo with layers associated with image.
@@ -123,7 +127,7 @@ func printImageChildren(layerMap map[string]*image.LayerInfo, layerID string, pr
}
fmt.Printf("%sID: %s Size: %7v%s\n", intend, ll.ID[:12], units.HumanSizeWithPrecision(float64(ll.Size), 4), tags)
for count, childID := range ll.ChildID {
- if err := printImageChildren(layerMap, childID, prefix, (count == len(ll.ChildID)-1)); err != nil {
+ if err := printImageChildren(layerMap, childID, prefix, count == len(ll.ChildID)-1); err != nil {
return err
}
}
diff --git a/cmd/podman/unpause.go b/cmd/podman/unpause.go
index 2cd6846fe..8126ebfbd 100644
--- a/cmd/podman/unpause.go
+++ b/cmd/podman/unpause.go
@@ -1,11 +1,10 @@
package main
import (
- "os"
-
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
+ "github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -38,7 +37,7 @@ func init() {
}
func unpauseCmd(c *cliconfig.UnpauseValues) error {
- if os.Geteuid() != 0 {
+ if rootless.IsRootless() && !remoteclient {
return errors.New("unpause is not supported for rootless containers")
}
@@ -54,7 +53,7 @@ func unpauseCmd(c *cliconfig.UnpauseValues) error {
}
ok, failures, err := runtime.UnpauseContainers(getContext(), c)
if err != nil {
- if errors.Cause(err) == libpod.ErrNoSuchCtr {
+ if errors.Cause(err) == define.ErrNoSuchCtr {
if len(c.InputArgs) > 1 {
exitCode = 125
} else {
diff --git a/cmd/podman/unshare.go b/cmd/podman/unshare.go
index 4a4e371db..31ce441f4 100644
--- a/cmd/podman/unshare.go
+++ b/cmd/podman/unshare.go
@@ -1,4 +1,4 @@
-// +build linux
+// +build !remoteclient
package main
@@ -8,8 +8,7 @@ import (
"os/exec"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/adapter"
"github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -41,10 +40,10 @@ func init() {
flags.SetInterspersed(false)
}
-func unshareEnv(config *libpod.RuntimeConfig) []string {
+func unshareEnv(graphroot, runroot string) []string {
return append(os.Environ(), "_CONTAINERS_USERNS_CONFIGURED=done",
- fmt.Sprintf("CONTAINERS_GRAPHROOT=%s", config.StorageConfig.GraphRoot),
- fmt.Sprintf("CONTAINERS_RUNROOT=%s", config.StorageConfig.RunRoot))
+ fmt.Sprintf("CONTAINERS_GRAPHROOT=%s", graphroot),
+ fmt.Sprintf("CONTAINERS_RUNROOT=%s", runroot))
}
// unshareCmd execs whatever using the ID mappings that we want to use for ourselves
@@ -63,7 +62,7 @@ func unshareCmd(c *cliconfig.PodmanCommand) error {
c.InputArgs = []string{shell}
}
- runtime, err := libpodruntime.GetRuntime(getContext(), c)
+ runtime, err := adapter.GetRuntime(getContext(), c)
if err != nil {
return err
}
@@ -73,7 +72,7 @@ func unshareCmd(c *cliconfig.PodmanCommand) error {
}
cmd := exec.Command(c.InputArgs[0], c.InputArgs[1:]...)
- cmd.Env = unshareEnv(runtimeConfig)
+ cmd.Env = unshareEnv(runtimeConfig.StorageConfig.GraphRoot, runtimeConfig.StorageConfig.RunRoot)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
diff --git a/cmd/podman/version.go b/cmd/podman/version.go
index 52a518db8..a078ba2fe 100644
--- a/cmd/podman/version.go
+++ b/cmd/podman/version.go
@@ -10,7 +10,7 @@ import (
"github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -40,7 +40,7 @@ func init() {
// versionCmd gets and prints version info for version command
func versionCmd(c *cliconfig.VersionValues) error {
- clientVersion, err := libpod.GetVersion()
+ clientVersion, err := define.GetVersion()
if err != nil {
errors.Wrapf(err, "unable to determine version")
}
@@ -85,7 +85,7 @@ func versionCmd(c *cliconfig.VersionValues) error {
return nil
}
-func formatVersion(writer io.Writer, version libpod.Version) {
+func formatVersion(writer io.Writer, version define.Version) {
fmt.Fprintf(writer, "Version:\t%s\n", version.Version)
fmt.Fprintf(writer, "RemoteAPI Version:\t%d\n", version.RemoteAPIVersion)
fmt.Fprintf(writer, "Go Version:\t%s\n", version.GoVersion)