forked from kubernetes/kops
/
channels.go
36 lines (30 loc) · 907 Bytes
/
channels.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package protokube
import (
"fmt"
"github.com/golang/glog"
"os"
"os/exec"
"strings"
)
func execChannels(args ...string) (string, error) {
kubectlPath := "channels" // Assume in PATH
cmd := exec.Command(kubectlPath, args...)
env := os.Environ()
cmd.Env = env
human := strings.Join(cmd.Args, " ")
glog.V(2).Infof("Running command: %s", human)
output, err := cmd.CombinedOutput()
if err != nil {
glog.Infof("error running %s:", human)
glog.Info(string(output))
return string(output), fmt.Errorf("error running channels: %v", err)
}
return string(output), err
}
func ApplyChannel(channel string) error {
// We don't embed the channels code because we expect this will eventually be part of kubectl
glog.Infof("checking channel: %q", channel)
out, err := execChannels("apply", "channel", channel, "--v=4", "--yes")
glog.V(4).Infof("apply channel output was: %v", out)
return err
}