diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-05-28 13:27:23 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-06-11 11:01:13 +0200 |
commit | 7d71d24440afbf30689c53c2c69205072e4b029f (patch) | |
tree | 20ae3d75ac79b2e9cf5a237ce4582ecd6a508b9c /cmd/podman/pods/common.go | |
parent | 7f5aabb08389f9baee49bd76ab21f876e0bb70b9 (diff) | |
download | podman-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.go | 23 |
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 +} |