summaryrefslogtreecommitdiff
path: root/cmd/podman/pod.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/pod.go')
-rw-r--r--cmd/podman/pod.go56
1 files changed, 52 insertions, 4 deletions
diff --git a/cmd/podman/pod.go b/cmd/podman/pod.go
index c1350bd4d..9a9c7a702 100644
--- a/cmd/podman/pod.go
+++ b/cmd/podman/pod.go
@@ -1,20 +1,24 @@
package main
import (
+ "os"
+
"github.com/containers/libpod/cmd/podman/cliconfig"
+ "github.com/containers/libpod/pkg/adapter"
+ "github.com/containers/libpod/pkg/rootless"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
)
var (
- podDescription = `Manage container pods.
-
-Pods are a group of one or more containers sharing the same network, pid and ipc namespaces.`
+ podDescription = `Pods are a group of one or more containers sharing the same network, pid and ipc namespaces.`
)
var podCommand = cliconfig.PodmanCommand{
Command: &cobra.Command{
Use: "pod",
Short: "Manage pods",
Long: podDescription,
+ RunE: commandRunE(),
},
}
@@ -29,12 +33,56 @@ var podSubCommands = []*cobra.Command{
_podRestartCommand,
_podRmCommand,
_podStartCommand,
+ _podStatsCommand,
_podStopCommand,
+ _podTopCommand,
_podUnpauseCommand,
}
+func joinPodNS(runtime *adapter.LocalRuntime, all, latest bool, inputArgs []string) ([]string, bool, bool, error) {
+ if rootless.IsRootless() {
+ if os.Geteuid() == 0 {
+ return []string{rootless.Argument()}, false, false, nil
+ } else {
+ var err error
+ var pods []*adapter.Pod
+ if all {
+ pods, err = runtime.GetAllPods()
+ if err != nil {
+ return nil, false, false, errors.Wrapf(err, "unable to get pods")
+ }
+ } else if latest {
+ pod, err := runtime.GetLatestPod()
+ if err != nil {
+ return nil, false, false, errors.Wrapf(err, "unable to get latest pod")
+ }
+ pods = append(pods, pod)
+ } else {
+ for _, i := range inputArgs {
+ pod, err := runtime.LookupPod(i)
+ if err != nil {
+ return nil, false, false, errors.Wrapf(err, "unable to lookup pod %s", i)
+ }
+ pods = append(pods, pod)
+ }
+ }
+ for _, p := range pods {
+ _, ret, err := runtime.JoinOrCreateRootlessPod(p)
+ if err != nil {
+ return nil, false, false, err
+ }
+ if ret != 0 {
+ os.Exit(ret)
+ }
+ }
+ os.Exit(0)
+ }
+ }
+ return inputArgs, all, latest, nil
+}
+
func init() {
podCommand.AddCommand(podSubCommands...)
- podCommand.AddCommand(getPodSubCommands()...)
+ podCommand.SetHelpTemplate(HelpTemplate())
podCommand.SetUsageTemplate(UsageTemplate())
}