mirror of https://github.com/k3s-io/k3s
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
453 B
22 lines
453 B
2 years ago
|
package util
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"os/exec"
|
||
|
)
|
||
|
|
||
|
// ExecCommand executes a command using the VPN binary
|
||
|
// In case of error != nil, the string returned var will have more information
|
||
|
func ExecCommand(command string, args []string) (string, error) {
|
||
|
var out, errOut bytes.Buffer
|
||
|
|
||
|
cmd := exec.Command(command, args...)
|
||
|
cmd.Stdout = &out
|
||
|
cmd.Stderr = &errOut
|
||
|
err := cmd.Run()
|
||
|
if err != nil {
|
||
|
return errOut.String(), err
|
||
|
}
|
||
|
return out.String(), nil
|
||
|
}
|