cri-o/server/exec.go

32 lines
540 B
Go
Raw Normal View History

package server
import (
"bytes"
"os/exec"
"strings"
)
func execCmd(name string, args ...string) (string, error) {
cmd := exec.Command(name, args...)
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return "", err
}
return out.String(), nil
}
func execRuncVersion(name string, args ...string) (string, error) {
out, err := execCmd(name, args...)
if err != nil {
return "", err
}
firstLine := out[:strings.Index(out, "\n")]
v := firstLine[strings.LastIndex(firstLine, " ")+1:]
return v, nil
}