forked from cloudfoundry/bosh-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 2
/
terraform_executor.go
158 lines (142 loc) · 3.2 KB
/
terraform_executor.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package fakes
type Import struct {
Addr string
ID string
}
type TerraformExecutor struct {
IsInitializedCall struct {
CallCount int
Returns struct {
IsInitialized bool
}
}
SetupCall struct {
CallCount int
Receives struct {
Template string
Inputs map[string]interface{}
}
Returns struct {
Error error
}
}
InitCall struct {
CallCount int
Receives struct{}
Returns struct {
Error error
}
}
ApplyCall struct {
CallCount int
Receives struct {
Credentials map[string]string
}
Returns struct {
Error error
}
}
DestroyCall struct {
CallCount int
Receives struct {
Credentials map[string]string
}
Returns struct {
Error error
}
}
ValidateCall struct {
CallCount int
Receives struct {
Credentials map[string]string
}
Returns struct {
Error error
}
}
VersionCall struct {
CallCount int
Returns struct {
Version string
Error error
}
}
OutputCall struct {
Stub func(string) (string, error)
CallCount int
Receives struct {
OutputName string
}
Returns struct {
Output string
Error error
}
}
OutputsCall struct {
Stub func() (map[string]interface{}, error)
CallCount int
Returns struct {
Outputs map[string]interface{}
Error error
}
}
IsPavedCall struct {
CallCount int
Returns struct {
IsPaved bool
Error error
}
}
}
func (t *TerraformExecutor) IsInitialized() bool {
t.IsInitializedCall.CallCount++
return t.IsInitializedCall.Returns.IsInitialized
}
func (t *TerraformExecutor) Setup(template string, inputs map[string]interface{}) error {
t.SetupCall.CallCount++
t.SetupCall.Receives.Template = template
t.SetupCall.Receives.Inputs = inputs
return t.SetupCall.Returns.Error
}
func (t *TerraformExecutor) Init() error {
t.InitCall.CallCount++
return t.InitCall.Returns.Error
}
func (t *TerraformExecutor) Apply(credentials map[string]string) error {
t.ApplyCall.CallCount++
t.ApplyCall.Receives.Credentials = credentials
return t.ApplyCall.Returns.Error
}
func (t *TerraformExecutor) Destroy(credentials map[string]string) error {
t.DestroyCall.CallCount++
t.DestroyCall.Receives.Credentials = credentials
return t.DestroyCall.Returns.Error
}
func (t *TerraformExecutor) Validate(credentials map[string]string) error {
t.ValidateCall.CallCount++
t.ValidateCall.Receives.Credentials = credentials
return t.ValidateCall.Returns.Error
}
func (t *TerraformExecutor) Version() (string, error) {
t.VersionCall.CallCount++
return t.VersionCall.Returns.Version, t.VersionCall.Returns.Error
}
func (t *TerraformExecutor) Output(outputName string) (string, error) {
t.OutputCall.CallCount++
t.OutputCall.Receives.OutputName = outputName
if t.OutputCall.Stub != nil {
return t.OutputCall.Stub(outputName)
}
return t.OutputCall.Returns.Output, t.OutputCall.Returns.Error
}
func (t *TerraformExecutor) Outputs() (map[string]interface{}, error) {
t.OutputsCall.CallCount++
if t.OutputsCall.Stub != nil {
return t.OutputsCall.Stub()
}
return t.OutputsCall.Returns.Outputs, t.OutputsCall.Returns.Error
}
func (t *TerraformExecutor) IsPaved() (bool, error) {
t.IsPavedCall.CallCount++
return t.IsPavedCall.Returns.IsPaved, t.IsPavedCall.Returns.Error
}