-
Notifications
You must be signed in to change notification settings - Fork 90
/
cli.go
57 lines (50 loc) · 1.07 KB
/
cli.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package helm
import (
"fmt"
"os/exec"
"path/filepath"
"github.com/onsi/gomega/gexec"
"github.com/replicatedhq/kots/e2e/util"
)
type CLI struct {
workspace string
}
func NewCLI(workspace string) *CLI {
return &CLI{
workspace: workspace,
}
}
func (c *CLI) RepoAdd(name, url string) (*gexec.Session, error) {
return util.RunCommand(exec.Command(
"helm",
c.AppendCommonFlags(
"repo",
"add",
name,
url,
)...,
))
}
func (c *CLI) Install(kubeconfig string, args ...string) (*gexec.Session, error) {
args = append(
[]string{
fmt.Sprintf("--kubeconfig=%s", kubeconfig),
"install",
},
args...,
)
return util.RunCommand(exec.Command(
"helm",
c.AppendCommonFlags(args...)...,
))
}
func (c *CLI) AppendCommonFlags(args ...string) []string {
return append(
[]string{
fmt.Sprintf("--registry-config=%s", filepath.Join(c.workspace, "registry.json")),
fmt.Sprintf("--repository-cache=%s", filepath.Join(c.workspace, "repository")),
fmt.Sprintf("--repository-config=%s", filepath.Join(c.workspace, "repositories.yaml")),
},
args...,
)
}