-
Notifications
You must be signed in to change notification settings - Fork 13
/
vars.go
444 lines (436 loc) · 10.1 KB
/
vars.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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
package config
import (
"github.com/urfave/cli"
)
type (
configVar struct {
Type configVarType
Default interface{}
CLIFlag cli.Flag
}
configVarType string
)
// Will be populated in init() below
var CLIFlags []cli.Flag
var (
stringType configVarType = "string"
intType configVarType = "int"
boolType configVarType = "bool"
)
var configVars = map[string]configVar{
"genindex": {
Type: boolType,
Default: false,
CLIFlag: cli.BoolFlag{
Name: "gen-index",
Usage: "generate index.yaml, print to stdout and exit",
EnvVar: "GEN_INDEX",
},
},
"debug": {
Type: boolType,
Default: false,
CLIFlag: cli.BoolFlag{
Name: "debug",
Usage: "show debug messages",
EnvVar: "DEBUG",
},
},
"logjson": {
Type: boolType,
Default: false,
CLIFlag: cli.BoolFlag{
Name: "log-json",
Usage: "output structured logs as json",
EnvVar: "LOG_JSON",
},
},
"disablemetrics": {
Type: boolType,
Default: false,
CLIFlag: cli.BoolFlag{
Name: "disable-metrics",
Usage: "disable Prometheus metrics",
EnvVar: "DISABLE_METRICS",
},
},
"disableapi": {
Type: boolType,
Default: false,
CLIFlag: cli.BoolFlag{
Name: "disable-api",
Usage: "disable all routes prefixed with /api",
EnvVar: "DISABLE_API",
},
},
"disablestatefiles": {
Type: boolType,
Default: false,
CLIFlag: cli.BoolFlag{
Name: "disable-statefiles",
Usage: "disable use of index-cache.yaml",
EnvVar: "DISABLE_STATEFILES",
},
},
"allowoverwrite": {
Type: boolType,
Default: false,
CLIFlag: cli.BoolFlag{
Name: "allow-overwrite",
Usage: "allow chart versions to be re-uploaded",
EnvVar: "ALLOW_OVERWRITE",
},
},
"port": {
Type: intType,
Default: 8080,
CLIFlag: cli.IntFlag{
Name: "port",
Usage: "port to listen on",
EnvVar: "PORT",
},
},
"charturl": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "chart-url",
Usage: "absolute url for .tgzs in index.yaml",
EnvVar: "CHART_URL",
},
},
"basicauth.user": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "basic-auth-user",
Usage: "username for basic http authentication",
EnvVar: "BASIC_AUTH_USER",
},
},
"basicauth.pass": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "basic-auth-pass",
Usage: "password for basic http authentication",
EnvVar: "BASIC_AUTH_PASS",
},
},
"authanonymousget": {
Type: boolType,
Default: false,
CLIFlag: cli.BoolFlag{
Name: "auth-anonymous-get",
Usage: "allow anonymous GET operations when auth is used",
EnvVar: "AUTH_ANONYMOUS_GET",
},
},
"tls.cert": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "tls-cert",
Usage: "path to tls certificate chain file",
EnvVar: "TLS_CERT",
},
},
"tls.key": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "tls-key",
Usage: "path to tls key file",
EnvVar: "TLS_KEY",
},
},
"cache.store": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "cache",
Usage: "cache store, can be one of: redis",
EnvVar: "CACHE",
},
},
"cache.redis.addr": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "cache-redis-addr",
Usage: "address of Redis service (host:port)",
EnvVar: "CACHE_REDIS_ADDR",
},
},
"cache.redis.password": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "cache-redis-password",
Usage: "Redis requirepass server configuration",
EnvVar: "CACHE_REDIS_PASSWORD",
},
},
"cache.redis.db": {
Type: intType,
Default: 0,
CLIFlag: cli.IntFlag{
Name: "cache-redis-db",
Usage: "Redis database to be selected after connect",
EnvVar: "CACHE_REDIS_DB",
Value: 0,
},
},
"storage.backend": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage",
Usage: "storage backend, can be one of: local, amazon, google",
EnvVar: "STORAGE",
},
},
"storage.local.rootdir": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-local-rootdir",
Usage: "directory to store charts for local storage backend",
EnvVar: "STORAGE_LOCAL_ROOTDIR",
},
},
"storage.amazon.bucket": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-amazon-bucket",
Usage: "s3 bucket to store charts for amazon storage backend",
EnvVar: "STORAGE_AMAZON_BUCKET",
},
},
"storage.amazon.prefix": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-amazon-prefix",
Usage: "prefix to store charts for --storage-amazon-bucket",
EnvVar: "STORAGE_AMAZON_PREFIX",
},
},
"storage.amazon.region": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-amazon-region",
Usage: "region of --storage-amazon-bucket",
EnvVar: "STORAGE_AMAZON_REGION",
},
},
"storage.amazon.endpoint": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-amazon-endpoint",
Usage: "alternative s3 endpoint",
EnvVar: "STORAGE_AMAZON_ENDPOINT",
},
},
"storage.amazon.sse": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-amazon-sse",
Usage: "server side encryption algorithm",
EnvVar: "STORAGE_AMAZON_SSE",
},
},
"storage.google.bucket": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-google-bucket",
Usage: "gcs bucket to store charts for google storage backend",
EnvVar: "STORAGE_GOOGLE_BUCKET",
},
},
"storage.google.prefix": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-google-prefix",
Usage: "prefix to store charts for --storage-google-bucket",
EnvVar: "STORAGE_GOOGLE_PREFIX",
},
},
"storage.microsoft.container": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-microsoft-container",
Usage: "container to store charts for microsoft storage backend",
EnvVar: "STORAGE_MICROSOFT_CONTAINER",
},
},
"storage.microsoft.prefix": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-microsoft-prefix",
Usage: "prefix to store charts for --storage-microsoft-prefix",
EnvVar: "STORAGE_MICROSOFT_PREFIX",
},
},
"storage.alibaba.bucket": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-alibaba-bucket",
Usage: "OSS bucket to store charts for Alibaba Cloud storage backend",
EnvVar: "STORAGE_ALIBABA_BUCKET",
},
},
"storage.alibaba.prefix": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-alibaba-prefix",
Usage: "prefix to store charts for --storage-alibaba-cloud-bucket",
EnvVar: "STORAGE_ALIBABA_PREFIX",
},
},
"storage.alibaba.endpoint": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-alibaba-endpoint",
Usage: "OSS endpoint",
EnvVar: "STORAGE_ALIBABA_ENDPOINT",
},
},
"storage.alibaba.sse": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-alibaba-sse",
Usage: "server side encryption algorithm for Alibaba Cloud storage backend, AES256 or KMS",
EnvVar: "STORAGE_ALIBABA_SSE",
},
},
"storage.openstack.container": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-openstack-container",
Usage: "container to store charts for openstack storage backend",
EnvVar: "STORAGE_OPENSTACK_CONTAINER",
},
},
"storage.openstack.prefix": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-openstack-prefix",
Usage: "prefix to store charts for --storage-openstack-container",
EnvVar: "STORAGE_OPENSTACK_PREFIX",
},
},
"storage.openstack.region": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-openstack-region",
Usage: "region of --storage-openstack-container",
EnvVar: "STORAGE_OPENSTACK_REGION",
},
},
"storage.openstack.cacert": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "storage-openstack-cacert",
Usage: "path to a CA cert bundle for your openstack endpoint",
EnvVar: "STORAGE_OPENSTACK_CACERT",
},
},
"chartpostformfieldname": {
Type: stringType,
Default: "chart",
CLIFlag: cli.StringFlag{
Name: "chart-post-form-field-name",
Usage: "form field which will be queried for the chart file content",
EnvVar: "CHART_POST_FORM_FIELD_NAME",
},
},
"provpostformfieldname": {
Type: stringType,
Default: "prov",
CLIFlag: cli.StringFlag{
Name: "prov-post-form-field-name",
Usage: "form field which will be queried for the provenance file content",
EnvVar: "PROV_POST_FORM_FIELD_NAME",
},
},
"maxstorageobjects": {
Type: intType,
Default: 0,
CLIFlag: cli.IntFlag{
Name: "max-storage-objects",
Usage: "maximum number of objects allowed in storage (per tenant)",
EnvVar: "MAX_STORAGE_OBJECTS",
},
},
"maxuploadsize": {
Type: intType,
Default: 1024 * 1024 * 20, // 20MB, per Helm's limit
CLIFlag: cli.IntFlag{
Name: "max-upload-size",
Usage: "max size of post body (in bytes)",
EnvVar: "MAX_UPLOAD_SIZE",
Value: 1024 * 1024 * 20,
},
},
"indexlimit": {
Type: intType,
Default: 0,
CLIFlag: cli.IntFlag{
Name: "index-limit",
Usage: "parallel scan limit for the repo indexer",
EnvVar: "INDEX_LIMIT",
},
},
"contextpath": {
Type: stringType,
Default: "",
CLIFlag: cli.StringFlag{
Name: "context-path",
Usage: "base context path",
EnvVar: "CONTEXT_PATH",
},
},
"depth": {
Type: intType,
Default: 0,
CLIFlag: cli.IntFlag{
Name: "depth",
Usage: "levels of nested repos for multitenancy",
EnvVar: "DEPTH",
},
},
}
func populateCLIFlags() {
CLIFlags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Usage: "chartmuseum configuration file",
EnvVar: "CONFIG",
},
}
for _, configVar := range configVars {
if flag := configVar.CLIFlag; flag != nil {
CLIFlags = append(CLIFlags, flag)
}
}
}
func init() {
populateCLIFlags()
}