@@ -22,20 +22,24 @@ import (
22
22
func newConfig () codersdk.DeploymentConfig {
23
23
return codersdk.DeploymentConfig {
24
24
AccessURL : codersdk.DeploymentConfigField [string ]{
25
+ Name : "Access URL" ,
25
26
Usage : "External URL to access your deployment. This must be accessible by all provisioned workspaces." ,
26
27
Flag : "access-url" ,
27
28
},
28
29
WildcardAccessURL : codersdk.DeploymentConfigField [string ]{
30
+ Name : "Wildcard Access URL" ,
29
31
Usage : "Specifies the wildcard hostname to use for workspace applications in the form \" *.example.com\" ." ,
30
32
Flag : "wildcard-access-url" ,
31
33
},
32
34
Address : codersdk.DeploymentConfigField [string ]{
35
+ Name : "Address" ,
33
36
Usage : "Bind address of the server." ,
34
37
Flag : "address" ,
35
38
Shorthand : "a" ,
36
39
Value : "127.0.0.1:3000" ,
37
40
},
38
41
AutobuildPollInterval : codersdk.DeploymentConfigField [time.Duration ]{
42
+ Name : "Autobuild Poll Interval" ,
39
43
Usage : "Interval to poll for scheduled workspace builds." ,
40
44
Flag : "autobuild-poll-interval" ,
41
45
Hidden : true ,
@@ -44,143 +48,177 @@ func newConfig() codersdk.DeploymentConfig {
44
48
DERP : codersdk.DERP {
45
49
Server : codersdk.DERPServerConfig {
46
50
Enable : codersdk.DeploymentConfigField [bool ]{
51
+ Name : "DERP Server Enable" ,
47
52
Usage : "Whether to enable or disable the embedded DERP relay server." ,
48
53
Flag : "derp-server-enable" ,
49
54
Value : true ,
50
55
},
51
56
RegionID : codersdk.DeploymentConfigField [int ]{
57
+ Name : "DERP Server Region ID" ,
52
58
Usage : "Region ID to use for the embedded DERP server." ,
53
59
Flag : "derp-server-region-id" ,
54
60
Value : 999 ,
55
61
},
56
62
RegionCode : codersdk.DeploymentConfigField [string ]{
63
+ Name : "DERP Server Region Code" ,
57
64
Usage : "Region code to use for the embedded DERP server." ,
58
65
Flag : "derp-server-region-code" ,
59
66
Value : "coder" ,
60
67
},
61
68
RegionName : codersdk.DeploymentConfigField [string ]{
69
+ Name : "DERP Server Region Name" ,
62
70
Usage : "Region name that for the embedded DERP server." ,
63
71
Flag : "derp-server-region-name" ,
64
72
Value : "Coder Embedded Relay" ,
65
73
},
66
74
STUNAddresses : codersdk.DeploymentConfigField [[]string ]{
75
+ Name : "DERP Server STUN Addresses" ,
67
76
Usage : "Addresses for STUN servers to establish P2P connections. Set empty to disable P2P connections." ,
68
77
Flag : "derp-server-stun-addresses" ,
69
78
Value : []string {"stun.l.google.com:19302" },
70
79
},
71
- RelayAddress : codersdk.DeploymentConfigField [string ]{
72
- Usage : "An HTTP address that is accessible by other replicas to relay DERP traffic. Required for high availability." ,
73
- Flag : "derp-server-relay-address" ,
80
+ RelayURL : codersdk.DeploymentConfigField [string ]{
81
+ Name : "DERP Server Relay URL" ,
82
+ Usage : "An HTTP URL that is accessible by other replicas to relay DERP traffic. Required for high availability." ,
83
+ Flag : "derp-server-relay-url" ,
74
84
Enterprise : true ,
75
85
},
76
86
},
77
87
Config : codersdk.DERPConfig {
78
88
URL : codersdk.DeploymentConfigField [string ]{
89
+ Name : "DERP Config URL" ,
79
90
Usage : "URL to fetch a DERP mapping on startup. See: https://tailscale.com/kb/1118/custom-derp-servers/" ,
80
91
Flag : "derp-config-url" ,
81
92
},
82
93
Path : codersdk.DeploymentConfigField [string ]{
94
+ Name : "DERP Config Path" ,
83
95
Usage : "Path to read a DERP mapping from. See: https://tailscale.com/kb/1118/custom-derp-servers/" ,
84
96
Flag : "derp-config-path" ,
85
97
},
86
98
},
87
99
},
88
100
Prometheus : codersdk.PrometheusConfig {
89
101
Enable : codersdk.DeploymentConfigField [bool ]{
102
+ Name : "Prometheus Enable" ,
90
103
Usage : "Serve prometheus metrics on the address defined by prometheus address." ,
91
104
Flag : "prometheus-enable" ,
92
105
},
93
106
Address : codersdk.DeploymentConfigField [string ]{
107
+ Name : "Prometheus Address" ,
94
108
Usage : "The bind address to serve prometheus metrics." ,
95
109
Flag : "prometheus-address" ,
96
110
Value : "127.0.0.1:2112" ,
97
111
},
98
112
},
99
113
Pprof : codersdk.PprofConfig {
100
114
Enable : codersdk.DeploymentConfigField [bool ]{
115
+ Name : "Pprof Enable" ,
101
116
Usage : "Serve pprof metrics on the address defined by pprof address." ,
102
117
Flag : "pprof-enable" ,
103
118
},
104
119
Address : codersdk.DeploymentConfigField [string ]{
120
+ Name : "Pprof Address" ,
105
121
Usage : "The bind address to serve pprof." ,
106
122
Flag : "pprof-address" ,
107
123
Value : "127.0.0.1:6060" ,
108
124
},
109
125
},
126
+ ProxyTrustedHeaders : codersdk.DeploymentConfigField [[]string ]{
127
+ Name : "Proxy Trusted Headers" ,
128
+ Flag : "proxy-trusted-headers" ,
129
+ Usage : "Headers to trust for forwarding IP addresses. e.g. Cf-Connecting-IP True-Client-Ip, X-Forwarded-for" ,
130
+ },
131
+ ProxyTrustedOrigins : codersdk.DeploymentConfigField [[]string ]{
132
+ Name : "Proxy Trusted Origins" ,
133
+ Flag : "proxy-trusted-origins" ,
134
+ Usage : "Origin addresses to respect \" proxy-trusted-headers\" . e.g. example.com" ,
135
+ },
110
136
CacheDirectory : codersdk.DeploymentConfigField [string ]{
111
-
137
+ Name : "Cache Directory" ,
112
138
Usage : "The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with systemd." ,
113
139
Flag : "cache-dir" ,
114
140
Value : defaultCacheDir (),
115
141
},
116
142
InMemoryDatabase : codersdk.DeploymentConfigField [bool ]{
117
-
143
+ Name : "In Memory Database" ,
118
144
Usage : "Controls whether data will be stored in an in-memory database." ,
119
145
Flag : "in-memory" ,
120
146
Hidden : true ,
121
147
},
122
148
ProvisionerDaemons : codersdk.DeploymentConfigField [int ]{
123
-
149
+ Name : "Provisioner Daemons" ,
124
150
Usage : "Number of provisioner daemons to create on start. If builds are stuck in queued state for a long time, consider increasing this." ,
125
151
Flag : "provisioner-daemons" ,
126
152
Value : 3 ,
127
153
},
128
154
PostgresURL : codersdk.DeploymentConfigField [string ]{
129
-
155
+ Name : "Postgres Connection URL" ,
130
156
Usage : "URL of a PostgreSQL database. If empty, PostgreSQL binaries will be downloaded from Maven (https://repo1.maven.org/maven2) and store all data in the config root. Access the built-in database with \" coder server postgres-builtin-url\" ." ,
131
157
Flag : "postgres-url" ,
132
158
},
133
159
OAuth2 : codersdk.OAuth2Config {
134
160
Github : codersdk.OAuth2GithubConfig {
135
161
ClientID : codersdk.DeploymentConfigField [string ]{
162
+ Name : "OAuth2 GitHub Client ID" ,
136
163
Usage : "Client ID for Login with GitHub." ,
137
164
Flag : "oauth2-github-client-id" ,
138
165
},
139
166
ClientSecret : codersdk.DeploymentConfigField [string ]{
167
+ Name : "OAuth2 GitHub Client Secret" ,
140
168
Usage : "Client secret for Login with GitHub." ,
141
169
Flag : "oauth2-github-client-secret" ,
142
170
},
143
171
AllowedOrganizations : codersdk.DeploymentConfigField [[]string ]{
172
+ Name : "OAuth2 GitHub Allowed Orgs" ,
144
173
Usage : "Organizations the user must be a member of to Login with GitHub." ,
145
174
Flag : "oauth2-github-allowed-orgs" ,
146
175
},
147
176
AllowedTeams : codersdk.DeploymentConfigField [[]string ]{
177
+ Name : "OAuth2 GitHub Allowed Teams" ,
148
178
Usage : "Teams inside organizations the user must be a member of to Login with GitHub. Structured as: <organization-name>/<team-slug>." ,
149
179
Flag : "oauth2-github-allowed-teams" ,
150
180
},
151
181
AllowSignups : codersdk.DeploymentConfigField [bool ]{
182
+ Name : "OAuth2 GitHub Allow Signups" ,
152
183
Usage : "Whether new users can sign up with GitHub." ,
153
184
Flag : "oauth2-github-allow-signups" ,
154
185
},
155
186
EnterpriseBaseURL : codersdk.DeploymentConfigField [string ]{
187
+ Name : "OAuth2 GitHub Enterprise Base URL" ,
156
188
Usage : "Base URL of a GitHub Enterprise deployment to use for Login with GitHub." ,
157
189
Flag : "oauth2-github-enterprise-base-url" ,
158
190
},
159
191
},
160
192
},
161
193
OIDC : codersdk.OIDCConfig {
162
194
AllowSignups : codersdk.DeploymentConfigField [bool ]{
195
+ Name : "OIDC Allow Signups" ,
163
196
Usage : "Whether new users can sign up with OIDC." ,
164
197
Flag : "oidc-allow-signups" ,
165
198
Value : true ,
166
199
},
167
200
ClientID : codersdk.DeploymentConfigField [string ]{
201
+ Name : "OIDC Client ID" ,
168
202
Usage : "Client ID to use for Login with OIDC." ,
169
203
Flag : "oidc-client-id" ,
170
204
},
171
205
ClientSecret : codersdk.DeploymentConfigField [string ]{
206
+ Name : "OIDC Client Secret" ,
172
207
Usage : "Client secret to use for Login with OIDC." ,
173
208
Flag : "oidc-client-secret" ,
174
209
},
175
210
EmailDomain : codersdk.DeploymentConfigField [string ]{
211
+ Name : "OIDC Email Domain" ,
176
212
Usage : "Email domain that clients logging in with OIDC must match." ,
177
213
Flag : "oidc-email-domain" ,
178
214
},
179
215
IssuerURL : codersdk.DeploymentConfigField [string ]{
216
+ Name : "OIDC Issuer URL" ,
180
217
Usage : "Issuer URL to use for Login with OIDC." ,
181
218
Flag : "oidc-issuer-url" ,
182
219
},
183
220
Scopes : codersdk.DeploymentConfigField [[]string ]{
221
+ Name : "OIDC Scopes" ,
184
222
Usage : "Scopes to grant when authenticating with OIDC." ,
185
223
Flag : "oidc-scopes" ,
186
224
Value : []string {oidc .ScopeOpenID , "profile" , "email" },
@@ -189,16 +227,19 @@ func newConfig() codersdk.DeploymentConfig {
189
227
190
228
Telemetry : codersdk.TelemetryConfig {
191
229
Enable : codersdk.DeploymentConfigField [bool ]{
230
+ Name : "Telemetry Enable" ,
192
231
Usage : "Whether telemetry is enabled or not. Coder collects anonymized usage data to help improve our product." ,
193
232
Flag : "telemetry" ,
194
233
Value : flag .Lookup ("test.v" ) == nil ,
195
234
},
196
235
Trace : codersdk.DeploymentConfigField [bool ]{
236
+ Name : "Telemetry Trace" ,
197
237
Usage : "Whether Opentelemetry traces are sent to Coder. Coder collects anonymized application tracing to help improve our product. Disabling telemetry also disables this option." ,
198
238
Flag : "telemetry-trace" ,
199
239
Value : flag .Lookup ("test.v" ) == nil ,
200
240
},
201
241
URL : codersdk.DeploymentConfigField [string ]{
242
+ Name : "Telemetry URL" ,
202
243
Usage : "URL to send telemetry." ,
203
244
Flag : "telemetry-url" ,
204
245
Hidden : true ,
@@ -207,88 +248,95 @@ func newConfig() codersdk.DeploymentConfig {
207
248
},
208
249
TLS : codersdk.TLSConfig {
209
250
Enable : codersdk.DeploymentConfigField [bool ]{
251
+ Name : "TLS Enable" ,
210
252
Usage : "Whether TLS will be enabled." ,
211
253
Flag : "tls-enable" ,
212
254
},
213
255
CertFiles : codersdk.DeploymentConfigField [[]string ]{
256
+ Name : "TLS Certificate Files" ,
214
257
Usage : "Path to each certificate for TLS. It requires a PEM-encoded file. To configure the listener to use a CA certificate, concatenate the primary certificate and the CA certificate together. The primary certificate should appear first in the combined file." ,
215
258
Flag : "tls-cert-file" ,
216
259
},
217
260
ClientCAFile : codersdk.DeploymentConfigField [string ]{
261
+ Name : "TLS Client CA Files" ,
218
262
Usage : "PEM-encoded Certificate Authority file used for checking the authenticity of client" ,
219
263
Flag : "tls-client-ca-file" ,
220
264
},
221
265
ClientAuth : codersdk.DeploymentConfigField [string ]{
266
+ Name : "TLS Client Auth" ,
222
267
Usage : "Policy the server will follow for TLS Client Authentication. Accepted values are \" none\" , \" request\" , \" require-any\" , \" verify-if-given\" , or \" require-and-verify\" ." ,
223
268
Flag : "tls-client-auth" ,
224
269
Value : "request" ,
225
270
},
226
271
KeyFiles : codersdk.DeploymentConfigField [[]string ]{
272
+ Name : "TLS Key Files" ,
227
273
Usage : "Paths to the private keys for each of the certificates. It requires a PEM-encoded file." ,
228
274
Flag : "tls-key-file" ,
229
275
},
230
276
MinVersion : codersdk.DeploymentConfigField [string ]{
277
+ Name : "TLS Minimum Version" ,
231
278
Usage : "Minimum supported version of TLS. Accepted values are \" tls10\" , \" tls11\" , \" tls12\" or \" tls13\" " ,
232
279
Flag : "tls-min-version" ,
233
280
Value : "tls12" ,
234
281
},
235
282
},
236
283
TraceEnable : codersdk.DeploymentConfigField [bool ]{
237
-
284
+ Name : "Trace Enable" ,
238
285
Usage : "Whether application tracing data is collected." ,
239
286
Flag : "trace" ,
240
287
},
241
288
SecureAuthCookie : codersdk.DeploymentConfigField [bool ]{
242
-
289
+ Name : "Secure Auth Cookie" ,
243
290
Usage : "Controls if the 'Secure' property is set on browser session cookies." ,
244
291
Flag : "secure-auth-cookie" ,
245
292
},
246
293
SSHKeygenAlgorithm : codersdk.DeploymentConfigField [string ]{
247
-
294
+ Name : "SSH Keygen Algorithm" ,
248
295
Usage : "The algorithm to use for generating ssh keys. Accepted values are \" ed25519\" , \" ecdsa\" , or \" rsa4096\" ." ,
249
296
Flag : "ssh-keygen-algorithm" ,
250
297
Value : "ed25519" ,
251
298
},
252
299
AutoImportTemplates : codersdk.DeploymentConfigField [[]string ]{
253
-
300
+ Name : "Auto Import Templates" ,
254
301
Usage : "Templates to auto-import. Available auto-importable templates are: kubernetes" ,
255
302
Flag : "auto-import-template" ,
256
303
Hidden : true ,
257
304
},
258
305
MetricsCacheRefreshInterval : codersdk.DeploymentConfigField [time.Duration ]{
259
-
306
+ Name : "Metrics Cache Refresh Interval" ,
260
307
Usage : "How frequently metrics are refreshed" ,
261
308
Flag : "metrics-cache-refresh-interval" ,
262
309
Hidden : true ,
263
310
Value : time .Hour ,
264
311
},
265
312
AgentStatRefreshInterval : codersdk.DeploymentConfigField [time.Duration ]{
266
-
313
+ Name : "Agent Stat Refresh Interval" ,
267
314
Usage : "How frequently agent stats are recorded" ,
268
315
Flag : "agent-stats-refresh-interval" ,
269
316
Hidden : true ,
270
317
Value : 10 * time .Minute ,
271
318
},
272
319
AuditLogging : codersdk.DeploymentConfigField [bool ]{
273
-
320
+ Name : "Audit Logging" ,
274
321
Usage : "Specifies whether audit logging is enabled." ,
275
322
Flag : "audit-logging" ,
276
323
Value : true ,
277
324
Enterprise : true ,
278
325
},
279
326
BrowserOnly : codersdk.DeploymentConfigField [bool ]{
280
-
327
+ Name : "Browser Only" ,
281
328
Usage : "Whether Coder only allows connections to workspaces via the browser." ,
282
329
Flag : "browser-only" ,
283
330
Enterprise : true ,
284
331
},
285
332
SCIMAPIKey : codersdk.DeploymentConfigField [string ]{
333
+ Name : "SCIM API Key" ,
286
334
Usage : "Enables SCIM and sets the authentication header for the built-in SCIM server. New users are automatically created with OIDC authentication." ,
287
335
Flag : "scim-auth-header" ,
288
336
Enterprise : true ,
289
337
},
290
338
UserWorkspaceQuota : codersdk.DeploymentConfigField [int ]{
291
-
339
+ Name : "User Workspace Quota" ,
292
340
Usage : "Enables and sets a limit on how many workspaces each user can create." ,
293
341
Flag : "user-workspace-quota" ,
294
342
Enterprise : true ,
@@ -334,7 +382,19 @@ func setConfig(prefix string, vip *viper.Viper, target interface{}) {
334
382
case time.Duration :
335
383
val .FieldByName ("Value" ).SetInt (int64 (vip .GetDuration (prefix )))
336
384
case []string :
337
- val .FieldByName ("Value" ).Set (reflect .ValueOf (vip .GetStringSlice (prefix )))
385
+ // As of October 21st, 2022 we supported delimiting a string
386
+ // with a comma, but Viper only supports with a space. This
387
+ // is a small hack around it!
388
+ rawSlice := reflect .ValueOf (vip .GetStringSlice (prefix )).Interface ()
389
+ slice , ok := rawSlice .([]string )
390
+ if ! ok {
391
+ panic (fmt .Sprintf ("string slice is of type %T" , rawSlice ))
392
+ }
393
+ value := make ([]string , 0 , len (slice ))
394
+ for _ , entry := range slice {
395
+ value = append (value , strings .Split (entry , "," )... )
396
+ }
397
+ val .FieldByName ("Value" ).Set (reflect .ValueOf (value ))
338
398
default :
339
399
panic (fmt .Sprintf ("unsupported type %T" , value ))
340
400
}
@@ -372,6 +432,7 @@ func NewViper() *viper.Viper {
372
432
vip := viper .New ()
373
433
vip .SetEnvPrefix ("coder" )
374
434
vip .AutomaticEnv ()
435
+ vip .SetEnvKeyReplacer (strings .NewReplacer ("-" , "_" , "." , "_" ))
375
436
376
437
setViperDefaults ("" , vip , dc )
377
438
0 commit comments