aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/pods/common.go
blob: 1c4195095e4914c8224a92912d95e3cfbfec4a38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
}