-
Notifications
You must be signed in to change notification settings - Fork 90
/
commands.go
58 lines (49 loc) · 1.35 KB
/
commands.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
58
package registry
import (
"fmt"
"time"
"github.com/onsi/gomega/gexec"
"github.com/replicatedhq/kots/e2e/helm"
//lint:ignore ST1001 since Ginkgo and Gomega are DSLs this makes the tests more natural to read
. "github.com/onsi/gomega"
)
const (
DefaultNamespace = "registry"
DefaultReleaseName = "registry"
)
type registry struct {
helmCLI *helm.CLI
kubeconfig string
}
func New(helmCLI *helm.CLI, kubeconfig string) *registry {
return ®istry{
helmCLI: helmCLI,
kubeconfig: kubeconfig,
}
}
type Options struct {
Namespace string
ReleaseName string
}
func (r *registry) Install(opts Options) {
if opts.Namespace == "" {
opts.Namespace = DefaultNamespace
}
if opts.ReleaseName == "" {
opts.ReleaseName = DefaultReleaseName
}
session, err := r.helmCLI.RepoAdd("twuni", "https://helm.twun.io")
Expect(err).WithOffset(1).Should(Succeed(), "helm repo add")
Eventually(session).WithOffset(1).WithTimeout(time.Minute).Should(gexec.Exit(0), "helm repo add")
session, err = r.helmCLI.Install(
r.kubeconfig,
"--create-namespace",
fmt.Sprintf("--namespace=%s", opts.Namespace),
"--wait",
"--set=fullnameOverride=registry",
opts.ReleaseName,
"twuni/docker-registry",
)
Expect(err).WithOffset(1).Should(Succeed(), "helm install")
Eventually(session).WithOffset(1).WithTimeout(2*time.Minute).Should(gexec.Exit(0), "helm install")
}