-
Notifications
You must be signed in to change notification settings - Fork 273
/
executables.go
87 lines (70 loc) 路 2.06 KB
/
executables.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package framework
import (
"context"
"github.com/aws/eks-anywhere/pkg/executables"
"github.com/aws/eks-anywhere/pkg/filewriter"
"github.com/aws/eks-anywhere/pkg/helm"
"github.com/aws/eks-anywhere/pkg/providers/cloudstack/decoder"
)
func buildKubectl(t T) *executables.Kubectl {
ctx := context.Background()
kubectl := executableBuilder(ctx, t).BuildKubectlExecutable()
return kubectl
}
func buildLocalKubectl() *executables.Kubectl {
return executables.NewLocalExecutablesBuilder().BuildKubectlExecutable()
}
func executableBuilder(ctx context.Context, t T) *executables.ExecutablesBuilder {
executableBuilder, close, err := executables.InitInDockerExecutablesBuilder(ctx, executables.DefaultEksaImage())
if err != nil {
t.Fatalf("Unable to initialize executable builder: %v", err)
}
t.Cleanup(func() {
if err := close(ctx); err != nil {
t.Fatal(err)
}
})
return executableBuilder
}
func buildGovc(t T) *executables.Govc {
ctx := context.Background()
tmpWriter, err := filewriter.NewWriter("unique-ip")
if err != nil {
t.Fatalf("Error creating tmp writer")
}
govc := executableBuilder(ctx, t).BuildGovcExecutable(tmpWriter)
t.Cleanup(func() {
govc.Close(ctx)
})
return govc
}
func buildDocker(t T) *executables.Docker {
return executables.BuildDockerExecutable()
}
func buildHelm(t T) helm.Client {
ctx := context.Background()
helm := executableBuilder(ctx, t).BuildHelmExecutable(helm.WithInsecure())
return helm
}
func buildSSH(t T) *executables.SSH {
return executables.NewLocalExecutablesBuilder().BuildSSHExecutable()
}
func buildCmk(t T) *executables.Cmk {
ctx := context.Background()
tmpWriter, err := filewriter.NewWriter("cmk")
if err != nil {
t.Fatalf("Error creating tmp writer")
}
execConfig, err := decoder.ParseCloudStackCredsFromEnv()
if err != nil {
t.Fatalf("parsing cloudstack credentials from environment: %v", err)
}
cmk, err := executableBuilder(ctx, t).BuildCmkExecutable(tmpWriter, execConfig)
if err != nil {
t.Fatalf("Error creating cmk client: %v", err)
}
t.Cleanup(func() {
cmk.Close(ctx)
})
return cmk
}