forked from weaveworks/weave-gitops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
412 lines (322 loc) · 9.09 KB
/
options.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
package fluxexec
type ClusterDomainOption struct {
clusterDomain string
}
// ClusterDomain represents the --cluster-domain flag.
func ClusterDomain(clusterDomain string) *ClusterDomainOption {
return &ClusterDomainOption{clusterDomain}
}
type ComponentsOption struct {
components []Component
}
// Components represents the --components flag.
func Components(components ...Component) *ComponentsOption {
allowedComponents := map[Component]struct{}{
ComponentSourceController: {},
ComponentKustomizeController: {},
ComponentHelmController: {},
ComponentNotificationController: {},
}
// validate components
validatedComponents := []Component{}
for _, c := range components {
if _, ok := allowedComponents[c]; !ok {
continue
}
validatedComponents = append(validatedComponents, c)
}
return &ComponentsOption{validatedComponents}
}
type ComponentsExtraOption struct {
componentsExtra []ComponentExtra
}
// ComponentsExtra represents the --components-extra flag.
func ComponentsExtra(componentsExtra ...ComponentExtra) *ComponentsExtraOption {
allowedComponents := map[ComponentExtra]struct{}{
ComponentImageAutomationController: {},
ComponentImageReflectorController: {},
}
// validate components
validatedComponents := []ComponentExtra{}
for _, c := range componentsExtra {
if _, ok := allowedComponents[c]; !ok {
continue
}
validatedComponents = append(validatedComponents, c)
}
return &ComponentsExtraOption{validatedComponents}
}
type ExportOption struct {
export bool
}
// Export represents the --export flag.
func Export(export bool) *ExportOption {
return &ExportOption{export}
}
type ImagePullSecretOption struct {
imagePullSecret string
}
// ImagePullSecret represents the --image-pull-secret flag.
func ImagePullSecret(imagePullSecret string) *ImagePullSecretOption {
return &ImagePullSecretOption{imagePullSecret}
}
type LogLevelOption struct {
logLevel string
}
// LogLevel represents the --log-level flag.
func LogLevel(logLevel string) *LogLevelOption {
return &LogLevelOption{logLevel}
}
type NetworkPolicyOption struct {
networkPolicy bool
}
// NetworkPolicy represents the --network-policy flag.
func NetworkPolicy(networkPolicy bool) *NetworkPolicyOption {
return &NetworkPolicyOption{networkPolicy}
}
type RegistryOption struct {
registry string
}
// Registry represents the --registry flag.
func Registry(registry string) *RegistryOption {
return &RegistryOption{registry}
}
type TolerationKeysOption struct {
tolerationKeys []string
}
// TolerationKeys represents the --toleration-keys flag.
func TolerationKeys(tolerationKeys ...string) *TolerationKeysOption {
return &TolerationKeysOption{tolerationKeys}
}
type WatchAllNamespacesOption struct {
watchAllNamespaces bool
}
// WatchAllNamespaces represents the --watch-all-namespaces flag.
func WatchAllNamespaces(watchAllNamespaces bool) *WatchAllNamespacesOption {
return &WatchAllNamespacesOption{watchAllNamespaces}
}
type HostnameOption struct {
hostname string
}
// Hostname represents the --hostname flag.
func Hostname(hostname string) *HostnameOption {
return &HostnameOption{hostname}
}
type IntervalOption struct {
interval string
}
// Interval represents the --interval flag.
func Interval(interval string) *IntervalOption {
return &IntervalOption{interval}
}
type OwnerOption struct {
owner string
}
// Owner represents the --owner flag.
func Owner(owner string) *OwnerOption {
return &OwnerOption{owner}
}
type PathOption struct {
path string
}
// Path represents the --path flag.
func Path(path string) *PathOption {
return &PathOption{path}
}
type PersonalOption struct {
personal bool
}
// Personal represents the --personal flag.
func Personal(personal bool) *PersonalOption {
return &PersonalOption{personal}
}
type PrivateOption struct {
private bool
}
// Private represents the --private flag.
func Private(private bool) *PrivateOption {
return &PrivateOption{private}
}
type ReadWriteKeyOption struct {
readWriteKey bool
}
// ReadWriteKey represents the --read-write-key flag.
func ReadWriteKey(readWriteKey bool) *ReadWriteKeyOption {
return &ReadWriteKeyOption{readWriteKey}
}
type ReconcileOption struct {
reconcile bool
}
// Reconcile represents the --reconcile flag.
func Reconcile(reconcile bool) *ReconcileOption {
return &ReconcileOption{reconcile}
}
type RepositoryOption struct {
repository string
}
// Repository represents the --repository flag.
func Repository(repository string) *RepositoryOption {
return &RepositoryOption{repository}
}
type TeamOption struct {
team []string
}
// Team represents the --team flag.
func Team(team ...string) *TeamOption {
return &TeamOption{team}
}
type AuthorEmailOption struct {
authorEmail string
}
// AuthorEmail represents the --author-email flag.
func AuthorEmail(authorEmail string) *AuthorEmailOption {
return &AuthorEmailOption{authorEmail}
}
type AuthorNameOption struct {
authorName string
}
// AuthorName represents the --author-name flag.
func AuthorName(authorName string) *AuthorNameOption {
return &AuthorNameOption{authorName}
}
type BranchOption struct {
branch string
}
// Branch represents the --branch flag.
func Branch(branch string) *BranchOption {
return &BranchOption{branch}
}
type CaFileOption struct {
caFile string
}
// CaFile represents the --ca-file flag.
func CaFile(caFile string) *CaFileOption {
return &CaFileOption{caFile}
}
type CommitMessageAppendixOption struct {
commitMessageAppendix string
}
// CommitMessageAppendix represents the --commit-message-appendix flag.
func CommitMessageAppendix(commitMessageAppendix string) *CommitMessageAppendixOption {
return &CommitMessageAppendixOption{commitMessageAppendix}
}
type GroupOption struct {
group []string
}
// Group represents the --group flag.
// Bitbucket Server groups to be given write access (also accepts comma-separated values)
func Group(group ...string) *GroupOption {
return &GroupOption{group}
}
type GPGKeyIDOption struct {
gpgKeyID string
}
// GPGKeyID represents the --gpg-key-id flag.
func GPGKeyID(gpgKeyID string) *GPGKeyIDOption {
return &GPGKeyIDOption{gpgKeyID}
}
type GPGKeyRingOption struct {
gpgKeyRing string
}
// GPGKeyRing represents the --gpg-key-ring flag.
func GPGKeyRing(gpgKeyRing string) *GPGKeyRingOption {
return &GPGKeyRingOption{gpgKeyRing}
}
type GPGPassphraseOption struct {
gpgPassphrase string
}
// GPGPassphrase represents the --gpg-passphrase flag.
func GPGPassphrase(gpgPassphrase string) *GPGPassphraseOption {
return &GPGPassphraseOption{gpgPassphrase}
}
type PrivateKeyFileOption struct {
privateKeyFile string
}
// PrivateKeyFile represents the --private-key-file flag.
func PrivateKeyFile(privateKeyFile string) *PrivateKeyFileOption {
return &PrivateKeyFileOption{privateKeyFile}
}
type RecurseSubmodulesOption struct {
recurseSubmodules bool
}
// RecurseSubmodules represents the --recurse-submodules flag.
func RecurseSubmodules(recurseSubmodules bool) *RecurseSubmodulesOption {
return &RecurseSubmodulesOption{recurseSubmodules}
}
type SecretNameOption struct {
secretName string
}
// SecretName represents the --secret-name flag.
func SecretName(secretName string) *SecretNameOption {
return &SecretNameOption{secretName}
}
type SSHECDSACurveOption struct {
sshECDSACurve ECDSACurve
}
// SSHECDSACurve represents the --ssh-ecdsa-curve flag.
func SSHECDSACurve(ecdsaCurve ECDSACurve) *SSHECDSACurveOption {
return &SSHECDSACurveOption{ecdsaCurve}
}
type SSHHostnameOption struct {
sshHostname string
}
// SSHHostname represents the --ssh-hostname flag.
func SSHHostname(sshHostname string) *SSHHostnameOption {
return &SSHHostnameOption{sshHostname}
}
type SSHKeyAlgorithmOption struct {
sshKeyAlgorithm KeyAlgorithm
}
// SSHKeyAlgorithm represents the --ssh-key-algorithm flag.
func SSHKeyAlgorithm(sshKeyAlgorithm KeyAlgorithm) *SSHKeyAlgorithmOption {
return &SSHKeyAlgorithmOption{sshKeyAlgorithm}
}
type SSHRSABitsOption struct {
sshRSABits int
}
// SSHRSABits represents the --ssh-rsa-bits flag.
func SSHRSABits(sshRSABits int) *SSHRSABitsOption {
return &SSHRSABitsOption{sshRSABits}
}
type TokenAuthOption struct {
tokenAuth bool
}
// TokenAuth represents the --token-auth flag.
func TokenAuth(tokenAuth bool) *TokenAuthOption {
return &TokenAuthOption{tokenAuth}
}
type UsernameOption struct {
username string
}
// Username represents the --username flag.
func Username(username string) *UsernameOption {
return &UsernameOption{username}
}
type PasswordOption struct {
password string
}
// Password represents the --password flag.
func Password(password string) *PasswordOption {
return &PasswordOption{password}
}
type AllowInsecureHTTPOption struct {
allowInsecureHTTP bool
}
// AllowInsecureHTTP represents the --allow-insecure-http flag.
func AllowInsecureHTTP(allowInsecureHTTP bool) *AllowInsecureHTTPOption {
return &AllowInsecureHTTPOption{allowInsecureHTTP: allowInsecureHTTP}
}
type SilentOption struct {
silent bool
}
// Silent represents the --silent flag.
func Silent(silent bool) *SilentOption {
return &SilentOption{silent: silent}
}
type URLOption struct {
url string
}
// URL represents the --url flag.
func URL(url string) *URLOption {
return &URLOption{url: url}
}