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.
helm/kubectl/command.go

33 lines
491 B

package kubectl
import (
"bytes"
"fmt"
"io/ioutil"
"os/exec"
"strings"
)
type cmd struct {
*exec.Cmd
}
func command(args ...string) *cmd {
return &cmd{exec.Command(Path, args...)}
}
func assignStdin(cmd *cmd, in []byte) {
cmd.Stdin = bytes.NewBuffer(in)
}
func (c *cmd) String() string {
var stdin string
if c.Stdin != nil {
b, _ := ioutil.ReadAll(c.Stdin)
stdin = fmt.Sprintf("< %s", string(b))
}
return fmt.Sprintf("[CMD] %s %s", strings.Join(c.Args, " "), stdin)
}