summaryrefslogtreecommitdiff
path: root/cmd/podman/common/util.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-06-11 10:56:11 -0400
committerGitHub <noreply@github.com>2020-06-11 10:56:11 -0400
commit39ad0387ca27097875b02b55c6f71c2f2b8bdd6c (patch)
tree0c870e02eb98c1f1db60d5dd44e7ebf2a7450335 /cmd/podman/common/util.go
parentf1b6840382ffdfe9811c64b3aea75218d9b14e5e (diff)
parentc7c81a8c081f6f7458345027f315a796d6ca5eda (diff)
downloadpodman-39ad0387ca27097875b02b55c6f71c2f2b8bdd6c.tar.gz
podman-39ad0387ca27097875b02b55c6f71c2f2b8bdd6c.tar.bz2
podman-39ad0387ca27097875b02b55c6f71c2f2b8bdd6c.zip
Merge pull request #6415 from vrothberg/systemd-new-pod
podman-generate-systemd --new for pods
Diffstat (limited to 'cmd/podman/common/util.go')
-rw-r--r--cmd/podman/common/util.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/cmd/podman/common/util.go b/cmd/podman/common/util.go
index 0d9f3ba26..ce323a4ba 100644
--- a/cmd/podman/common/util.go
+++ b/cmd/podman/common/util.go
@@ -1,6 +1,7 @@
package common
import (
+ "io/ioutil"
"net"
"strconv"
"strings"
@@ -10,6 +11,30 @@ import (
"github.com/sirupsen/logrus"
)
+// ReadPodIDFile reads the specified file and returns its content (i.e., first
+// line).
+func ReadPodIDFile(path string) (string, error) {
+ content, err := ioutil.ReadFile(path)
+ if err != nil {
+ return "", errors.Wrap(err, "error reading pod ID file")
+ }
+ return strings.Split(string(content), "\n")[0], nil
+}
+
+// ReadPodIDFiles reads the specified files and returns their content (i.e.,
+// first line).
+func ReadPodIDFiles(files []string) ([]string, error) {
+ ids := []string{}
+ for _, file := range files {
+ id, err := ReadPodIDFile(file)
+ if err != nil {
+ return nil, err
+ }
+ ids = append(ids, id)
+ }
+ return ids, nil
+}
+
// createExpose parses user-provided exposed port definitions and converts them
// into SpecGen format.
// TODO: The SpecGen format should really handle ranges more sanely - we could