summaryrefslogtreecommitdiff
path: root/cmd/podman/pods
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-05-29 10:35:22 +0200
committerValentin Rothberg <rothberg@redhat.com>2020-06-11 11:01:13 +0200
commitcf89bb671184e453c4ba5f27e26d02216d8fc491 (patch)
treeed707e35dcae297a60e97150bc407d9a5ea5ff80 /cmd/podman/pods
parent7d71d24440afbf30689c53c2c69205072e4b029f (diff)
downloadpodman-cf89bb671184e453c4ba5f27e26d02216d8fc491.tar.gz
podman-cf89bb671184e453c4ba5f27e26d02216d8fc491.tar.bz2
podman-cf89bb671184e453c4ba5f27e26d02216d8fc491.zip
container-{create,run}: add `--pod-id-file`
Allow containers to join an existing pod via the `--pod-id-file` which is already supported by a number of `podman-pod` subcommands. Also add tests to make sure it's working and to prevent future regressions. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'cmd/podman/pods')
-rw-r--r--cmd/podman/pods/common.go23
-rw-r--r--cmd/podman/pods/rm.go3
-rw-r--r--cmd/podman/pods/start.go3
-rw-r--r--cmd/podman/pods/stop.go3
4 files changed, 6 insertions, 26 deletions
diff --git a/cmd/podman/pods/common.go b/cmd/podman/pods/common.go
deleted file mode 100644
index 1c4195095..000000000
--- a/cmd/podman/pods/common.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package pods
-
-import (
- "io/ioutil"
- "strings"
-
- "github.com/pkg/errors"
-)
-
-// readPodIDFiles reads the specified files and returns their content (i.e.,
-// first line).
-func readPodIDFiles(files []string) ([]string, error) {
- ids := []string{}
- for _, podFile := range files {
- content, err := ioutil.ReadFile(podFile)
- if err != nil {
- return nil, errors.Wrap(err, "error reading pod ID file")
- }
- id := strings.Split(string(content), "\n")[0]
- ids = append(ids, id)
- }
- return ids, nil
-}
diff --git a/cmd/podman/pods/rm.go b/cmd/podman/pods/rm.go
index ecceda32a..8de0bce9e 100644
--- a/cmd/podman/pods/rm.go
+++ b/cmd/podman/pods/rm.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
+ "github.com/containers/libpod/cmd/podman/common"
"github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
@@ -61,7 +62,7 @@ func rm(cmd *cobra.Command, args []string) error {
errs utils.OutputErrors
)
- ids, err := readPodIDFiles(rmOptions.PodIDFiles)
+ ids, err := common.ReadPodIDFiles(rmOptions.PodIDFiles)
if err != nil {
return err
}
diff --git a/cmd/podman/pods/start.go b/cmd/podman/pods/start.go
index 86517190d..97020b360 100644
--- a/cmd/podman/pods/start.go
+++ b/cmd/podman/pods/start.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
+ "github.com/containers/libpod/cmd/podman/common"
"github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
@@ -61,7 +62,7 @@ func start(cmd *cobra.Command, args []string) error {
errs utils.OutputErrors
)
- ids, err := readPodIDFiles(startOptions.PodIDFiles)
+ ids, err := common.ReadPodIDFiles(startOptions.PodIDFiles)
if err != nil {
return err
}
diff --git a/cmd/podman/pods/stop.go b/cmd/podman/pods/stop.go
index fd66488f9..628e8a536 100644
--- a/cmd/podman/pods/stop.go
+++ b/cmd/podman/pods/stop.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
+ "github.com/containers/libpod/cmd/podman/common"
"github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
@@ -68,7 +69,7 @@ func stop(cmd *cobra.Command, args []string) error {
stopOptions.Timeout = int(stopOptions.TimeoutCLI)
}
- ids, err := readPodIDFiles(stopOptions.PodIDFiles)
+ ids, err := common.ReadPodIDFiles(stopOptions.PodIDFiles)
if err != nil {
return err
}