summaryrefslogtreecommitdiff
path: root/cmd/podman/pods/common.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-05-28 13:27:23 +0200
committerValentin Rothberg <rothberg@redhat.com>2020-06-11 11:01:13 +0200
commit7d71d24440afbf30689c53c2c69205072e4b029f (patch)
tree20ae3d75ac79b2e9cf5a237ce4582ecd6a508b9c /cmd/podman/pods/common.go
parent7f5aabb08389f9baee49bd76ab21f876e0bb70b9 (diff)
downloadpodman-7d71d24440afbf30689c53c2c69205072e4b029f.tar.gz
podman-7d71d24440afbf30689c53c2c69205072e4b029f.tar.bz2
podman-7d71d24440afbf30689c53c2c69205072e4b029f.zip
podman-pod{rm,start,stop}: support --pod-id-file
Support the `--pod-id-file` flag in the rm, start and stop pod commands. This completes the already support flag in pod-create and is another prerequisite for generating generic systemd unit files for pods. Also add completions, docs and tests. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'cmd/podman/pods/common.go')
-rw-r--r--cmd/podman/pods/common.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/cmd/podman/pods/common.go b/cmd/podman/pods/common.go
new file mode 100644
index 000000000..1c4195095
--- /dev/null
+++ b/cmd/podman/pods/common.go
@@ -0,0 +1,23 @@
+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
+}