forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context.go
181 lines (149 loc) · 4.08 KB
/
context.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
package app
import (
"testing"
. "github.com/argoproj/argo-cd/common"
"github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
"github.com/argoproj/argo-cd/test/e2e/fixture"
"github.com/argoproj/argo-cd/test/e2e/fixture/certs"
"github.com/argoproj/argo-cd/test/e2e/fixture/repos"
"github.com/argoproj/argo-cd/util/settings"
)
// this implements the "given" part of given/when/then
type Context struct {
t *testing.T
path string
repoURLType fixture.RepoURLType
// seconds
timeout int
name string
destServer string
env string
parameters []string
jsonnetTLAStr []string
jsonnetTLACode []string
namePrefix string
resource string
prune bool
configManagementPlugin string
async bool
localPath string
project string
}
func Given(t *testing.T) *Context {
fixture.EnsureCleanState(t)
return &Context{t: t, destServer: KubernetesInternalAPIServerAddr, repoURLType: fixture.RepoURLTypeFile, name: fixture.Name(), timeout: 10, project: "default", prune: true}
}
func (c *Context) CustomCACertAdded() *Context {
certs.AddCustomCACert()
return c
}
func (c *Context) CustomSSHKnownHostsAdded() *Context {
certs.AddCustomSSHKnownHostsKeys()
return c
}
func (c *Context) HTTPSRepoURLAdded() *Context {
repos.AddHTTPSRepo(false)
return c
}
func (c *Context) HTTPSInsecureRepoURLAdded() *Context {
repos.AddHTTPSRepo(true)
return c
}
func (c *Context) HTTPSInsecureRepoURLWithClientCertAdded() *Context {
repos.AddHTTPSRepoClientCert(false)
return c
}
func (c *Context) HTTPSRepoURLWithClientCertAdded() *Context {
repos.AddHTTPSRepoClientCert(true)
return c
}
func (c *Context) SSHRepoURLAdded() *Context {
repos.AddSSHRepo(false)
return c
}
func (c *Context) SSHInsecureRepoURLAdded() *Context {
repos.AddSSHRepo(true)
return c
}
func (c *Context) RepoURLType(urlType fixture.RepoURLType) *Context {
c.repoURLType = urlType
return c
}
func (c *Context) Path(path string) *Context {
c.path = path
return c
}
func (c *Context) Timeout(timeout int) *Context {
c.timeout = timeout
return c
}
func (c *Context) DestServer(destServer string) *Context {
c.destServer = destServer
return c
}
func (c *Context) Env(env string) *Context {
c.env = env
return c
}
func (c *Context) Parameter(parameter string) *Context {
c.parameters = append(c.parameters, parameter)
return c
}
func (c *Context) JsonnetTLAStrParameter(parameter string) *Context {
c.jsonnetTLAStr = append(c.jsonnetTLAStr, parameter)
return c
}
func (c *Context) JsonnetTLACodeParameter(parameter string) *Context {
c.jsonnetTLACode = append(c.jsonnetTLACode, parameter)
return c
}
// group:kind:name
func (c *Context) SelectedResource(resource string) *Context {
c.resource = resource
return c
}
func (c *Context) NamePrefix(namePrefix string) *Context {
c.namePrefix = namePrefix
return c
}
func (c *Context) ResourceOverrides(overrides map[string]v1alpha1.ResourceOverride) *Context {
fixture.SetResourceOverrides(overrides)
return c
}
func (c *Context) ResourceFilter(filter settings.ResourcesFilter) *Context {
fixture.SetResourceFilter(filter)
return c
}
// this both configures the plugin, but forces use of it
func (c *Context) ConfigManagementPlugin(plugin v1alpha1.ConfigManagementPlugin) *Context {
fixture.SetConfigManagementPlugins(plugin)
c.configManagementPlugin = plugin.Name
return c
}
func (c *Context) HelmRepoCredential(name, url string) *Context {
fixture.SetHelmRepoCredential(settings.HelmRepoCredentials{Name: name, URL: url})
return c
}
func (c *Context) And(block func()) *Context {
block()
return c
}
func (c *Context) When() *Actions {
return &Actions{context: c}
}
func (c *Context) Prune(prune bool) *Context {
c.prune = prune
return c
}
func (c *Context) Async(async bool) *Context {
c.async = async
return c
}
func (c *Context) LocalPath(localPath string) *Context {
c.localPath = localPath
return c
}
func (c *Context) Project(project string) *Context {
c.project = project
return c
}