@@ -20,244 +20,296 @@ import (
20
20
func newConfig () codersdk.DeploymentConfig {
21
21
return codersdk.DeploymentConfig {
22
22
AccessURL : codersdk.DeploymentConfigField [string ]{
23
+ Key : "access_url" ,
23
24
Usage : "External URL to access your deployment. This must be accessible by all provisioned workspaces." ,
24
25
Flag : "access-url" ,
25
26
},
26
27
WildcardAccessURL : codersdk.DeploymentConfigField [string ]{
28
+ Key : "wildcard_access_url" ,
27
29
Usage : "Specifies the wildcard hostname to use for workspace applications in the form \" *.example.com\" ." ,
28
30
Flag : "wildcard-access-url" ,
29
31
},
30
32
Address : codersdk.DeploymentConfigField [string ]{
33
+ Key : "address" ,
31
34
Usage : "Bind address of the server." ,
32
35
Flag : "address" ,
33
36
Shorthand : "a" ,
34
37
Value : "127.0.0.1:3000" ,
35
38
},
36
39
AutobuildPollInterval : codersdk.DeploymentConfigField [time.Duration ]{
40
+ Key : "autobuild_poll_interval" ,
37
41
Usage : "Interval to poll for scheduled workspace builds." ,
38
42
Flag : "autobuild-poll-interval" ,
39
43
Hidden : true ,
40
44
Value : time .Minute ,
41
45
},
42
46
DERPServerEnable : codersdk.DeploymentConfigField [bool ]{
47
+ Key : "derp.server.enable" ,
43
48
Usage : "Whether to enable or disable the embedded DERP relay server." ,
44
49
Flag : "derp-server-enable" ,
45
50
Value : true ,
46
51
},
47
52
DERPServerRegionID : codersdk.DeploymentConfigField [int ]{
53
+ Key : "derp.server.region_id" ,
48
54
Usage : "Region ID to use for the embedded DERP server." ,
49
55
Flag : "derp-server-region-id" ,
50
56
Value : 999 ,
51
57
},
52
58
DERPServerRegionCode : codersdk.DeploymentConfigField [string ]{
59
+ Key : "derp.server.region_code" ,
53
60
Usage : "Region code to use for the embedded DERP server." ,
54
61
Flag : "derp-server-region-code" ,
55
62
Value : "coder" ,
56
63
},
57
64
DERPServerRegionName : codersdk.DeploymentConfigField [string ]{
65
+ Key : "derp.server.region_name" ,
58
66
Usage : "Region name that for the embedded DERP server." ,
59
67
Flag : "derp-server-region-name" ,
60
68
Value : "Coder Embedded Relay" ,
61
69
},
62
70
DERPServerSTUNAddresses : codersdk.DeploymentConfigField [[]string ]{
71
+ Key : "derp.server.stun_addresses" ,
63
72
Usage : "Addresses for STUN servers to establish P2P connections. Set empty to disable P2P connections." ,
64
73
Flag : "derp-server-stun-addresses" ,
65
74
Value : []string {"stun.l.google.com:19302" },
66
75
},
67
76
DERPServerRelayAddress : codersdk.DeploymentConfigField [string ]{
77
+ Key : "derp.server.relay_address" ,
68
78
Usage : "An HTTP address that is accessible by other replicas to relay DERP traffic. Required for high availability." ,
69
79
Flag : "derp-server-relay-address" ,
70
80
Enterprise : true ,
71
81
},
72
82
DERPConfigURL : codersdk.DeploymentConfigField [string ]{
83
+ Key : "derp.config.url" ,
73
84
Usage : "URL to fetch a DERP mapping on startup. See: https://tailscale.com/kb/1118/custom-derp-servers/" ,
74
85
Flag : "derp-config-url" ,
75
86
},
76
87
DERPConfigPath : codersdk.DeploymentConfigField [string ]{
88
+ Key : "derp.config.path" ,
77
89
Usage : "Path to read a DERP mapping from. See: https://tailscale.com/kb/1118/custom-derp-servers/" ,
78
90
Flag : "derp-config-path" ,
79
91
},
80
92
PrometheusEnable : codersdk.DeploymentConfigField [bool ]{
93
+ Key : "prometheus.enable" ,
81
94
Usage : "Serve prometheus metrics on the address defined by prometheus address." ,
82
95
Flag : "prometheus-enable" ,
83
96
},
84
97
PrometheusAddress : codersdk.DeploymentConfigField [string ]{
98
+ Key : "prometheus.address" ,
85
99
Usage : "The bind address to serve prometheus metrics." ,
86
100
Flag : "prometheus-address" ,
87
101
Value : "127.0.0.1:2112" ,
88
102
},
89
103
PprofEnable : codersdk.DeploymentConfigField [bool ]{
104
+ Key : "pprof.enable" ,
90
105
Usage : "Serve pprof metrics on the address defined by pprof address." ,
91
106
Flag : "pprof-enable" ,
92
107
},
93
108
PprofAddress : codersdk.DeploymentConfigField [string ]{
109
+ Key : "pprof.address" ,
94
110
Usage : "The bind address to serve pprof." ,
95
111
Flag : "pprof-address" ,
96
112
Value : "127.0.0.1:6060" ,
97
113
},
98
114
CacheDir : codersdk.DeploymentConfigField [string ]{
115
+ Key : "cache_dir" ,
99
116
Usage : "The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with systemd." ,
100
117
Flag : "cache-dir" ,
101
118
Value : defaultCacheDir (),
102
119
},
103
120
InMemoryDatabase : codersdk.DeploymentConfigField [bool ]{
121
+ Key : "in_memory_database" ,
104
122
Usage : "Controls whether data will be stored in an in-memory database." ,
105
123
Flag : "in-memory" ,
106
124
Hidden : true ,
107
125
},
108
126
ProvisionerDaemonCount : codersdk.DeploymentConfigField [int ]{
127
+ Key : "provisioner.daemon_count" ,
109
128
Usage : "Number of provisioner daemons to create on start. If builds are stuck in queued state for a long time, consider increasing this." ,
110
129
Flag : "provisioner-daemons" ,
111
130
Value : 3 ,
112
131
},
113
132
PostgresURL : codersdk.DeploymentConfigField [string ]{
133
+ Key : "postgres_url" ,
114
134
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\" ." ,
115
135
Flag : "postgres-url" ,
116
136
},
117
137
OAuth2GithubClientID : codersdk.DeploymentConfigField [string ]{
138
+ Key : "oauth2github.client_id" ,
118
139
Usage : "Client ID for Login with GitHub." ,
119
140
Flag : "oauth2-github-client-id" ,
120
141
},
121
142
OAuth2GithubClientSecret : codersdk.DeploymentConfigField [string ]{
143
+ Key : "oauth2github.client_secret" ,
122
144
Usage : "Client secret for Login with GitHub." ,
123
145
Flag : "oauth2-github-client-secret" ,
124
146
},
125
147
OAuth2GithubAllowedOrganizations : codersdk.DeploymentConfigField [[]string ]{
148
+ Key : "oauth2github.allowed_organizations" ,
126
149
Usage : "Organizations the user must be a member of to Login with GitHub." ,
127
150
Flag : "oauth2-github-allowed-orgs" ,
128
151
},
129
152
OAuth2GithubAllowedTeams : codersdk.DeploymentConfigField [[]string ]{
153
+ Key : "oauth2github.allowed_teams" ,
130
154
Usage : "Teams inside organizations the user must be a member of to Login with GitHub. Structured as: <organization-name>/<team-slug>." ,
131
155
Flag : "oauth2-github-allowed-teams" ,
132
156
},
133
157
OAuth2GithubAllowSignups : codersdk.DeploymentConfigField [bool ]{
158
+ Key : "oauth2github.allow_signups" ,
134
159
Usage : "Whether new users can sign up with GitHub." ,
135
160
Flag : "oauth2-github-allow-signups" ,
136
161
},
137
162
OAuth2GithubEnterpriseBaseURL : codersdk.DeploymentConfigField [string ]{
163
+ Key : "oauth2github.enterprise_base_url" ,
138
164
Usage : "Base URL of a GitHub Enterprise deployment to use for Login with GitHub." ,
139
165
Flag : "oauth2-github-enterprise-base-url" ,
140
166
},
141
167
OIDCAllowSignups : codersdk.DeploymentConfigField [bool ]{
168
+ Key : "oidc.allow_signups" ,
142
169
Usage : "Whether new users can sign up with OIDC." ,
143
170
Flag : "oidc-allow-signups" ,
144
171
Value : true ,
145
172
},
146
173
OIDCClientID : codersdk.DeploymentConfigField [string ]{
174
+ Key : "oidc.client_id" ,
147
175
Usage : "Client ID to use for Login with OIDC." ,
148
176
Flag : "oidc-client-id" ,
149
177
},
150
178
OIDCClientSecret : codersdk.DeploymentConfigField [string ]{
179
+ Key : "oidc.client_secret" ,
151
180
Usage : "Client secret to use for Login with OIDC." ,
152
181
Flag : "oidc-client-secret" ,
153
182
},
154
183
OIDCEmailDomain : codersdk.DeploymentConfigField [string ]{
184
+ Key : "oidc.email_domain" ,
155
185
Usage : "Email domain that clients logging in with OIDC must match." ,
156
186
Flag : "oidc-email-domain" ,
157
187
},
158
188
OIDCIssuerURL : codersdk.DeploymentConfigField [string ]{
189
+ Key : "oidc.issuer_url" ,
159
190
Usage : "Issuer URL to use for Login with OIDC." ,
160
191
Flag : "oidc-issuer-url" ,
161
192
},
162
193
OIDCScopes : codersdk.DeploymentConfigField [[]string ]{
194
+ Key : "oidc.scopes" ,
163
195
Usage : "Scopes to grant when authenticating with OIDC." ,
164
196
Flag : "oidc-scopes" ,
165
197
Value : []string {oidc .ScopeOpenID , "profile" , "email" },
166
198
},
167
199
TelemetryEnable : codersdk.DeploymentConfigField [bool ]{
200
+ Key : "telemetry.enable" ,
168
201
Usage : "Whether telemetry is enabled or not. Coder collects anonymized usage data to help improve our product." ,
169
202
Flag : "telemetry" ,
170
203
Value : flag .Lookup ("test.v" ) == nil ,
171
204
},
172
205
TelemetryTraceEnable : codersdk.DeploymentConfigField [bool ]{
206
+ Key : "telemetry.trace.enable" ,
173
207
Usage : "Whether Opentelemetry traces are sent to Coder. Coder collects anonymized application tracing to help improve our product. Disabling telemetry also disables this option." ,
174
208
Flag : "telemetry-trace" ,
175
209
Value : flag .Lookup ("test.v" ) == nil ,
176
210
},
177
211
TelemetryURL : codersdk.DeploymentConfigField [string ]{
212
+ Key : "telemetry.url" ,
178
213
Usage : "URL to send telemetry." ,
179
214
Flag : "telemetry-url" ,
180
215
Hidden : true ,
181
216
Value : "https://telemetry.coder.com" ,
182
217
},
183
218
TLSEnable : codersdk.DeploymentConfigField [bool ]{
219
+ Key : "tls.enable" ,
184
220
Usage : "Whether TLS will be enabled." ,
185
221
Flag : "tls-enable" ,
186
222
},
187
223
TLSCertFiles : codersdk.DeploymentConfigField [[]string ]{
224
+ Key : "tls.cert_files" ,
188
225
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." ,
189
226
Flag : "tls-cert-file" ,
190
227
},
191
228
TLSClientCAFile : codersdk.DeploymentConfigField [string ]{
229
+ Key : "tls.client_ca_file" ,
192
230
Usage : "PEM-encoded Certificate Authority file used for checking the authenticity of client" ,
193
231
Flag : "tls-client-ca-file" ,
194
232
},
195
233
TLSClientAuth : codersdk.DeploymentConfigField [string ]{
234
+ Key : "tls.client_auth" ,
196
235
Usage : "Policy the server will follow for TLS Client Authentication. Accepted values are \" none\" , \" request\" , \" require-any\" , \" verify-if-given\" , or \" require-and-verify\" ." ,
197
236
Flag : "tls-client-auth" ,
198
237
Value : "request" ,
199
238
},
200
239
TLSKeyFiles : codersdk.DeploymentConfigField [[]string ]{
240
+ Key : "tls.key_files" ,
201
241
Usage : "Paths to the private keys for each of the certificates. It requires a PEM-encoded file." ,
202
242
Flag : "tls-key-file" ,
203
243
},
204
244
TLSMinVersion : codersdk.DeploymentConfigField [string ]{
245
+ Key : "tls.min_version" ,
205
246
Usage : "Minimum supported version of TLS. Accepted values are \" tls10\" , \" tls11\" , \" tls12\" or \" tls13\" " ,
206
247
Flag : "tls-min-version" ,
207
248
Value : "tls12" ,
208
249
},
209
250
TraceEnable : codersdk.DeploymentConfigField [bool ]{
251
+ Key : "trace" ,
210
252
Usage : "Whether application tracing data is collected." ,
211
253
Flag : "trace" ,
212
254
},
213
255
SecureAuthCookie : codersdk.DeploymentConfigField [bool ]{
256
+ Key : "secure_auth_cookie" ,
214
257
Usage : "Controls if the 'Secure' property is set on browser session cookies." ,
215
258
Flag : "secure-auth-cookie" ,
216
259
},
217
260
SSHKeygenAlgorithm : codersdk.DeploymentConfigField [string ]{
261
+ Key : "ssh_keygen_algorithm" ,
218
262
Usage : "The algorithm to use for generating ssh keys. Accepted values are \" ed25519\" , \" ecdsa\" , or \" rsa4096\" ." ,
219
263
Flag : "ssh-keygen-algorithm" ,
220
264
Value : "ed25519" ,
221
265
},
222
266
AutoImportTemplates : codersdk.DeploymentConfigField [[]string ]{
267
+ Key : "auto_import_templates" ,
223
268
Usage : "Templates to auto-import. Available auto-importable templates are: kubernetes" ,
224
269
Flag : "auto-import-template" ,
225
270
Hidden : true ,
226
271
},
227
272
MetricsCacheRefreshInterval : codersdk.DeploymentConfigField [time.Duration ]{
273
+ Key : "metrics_cache_refresh_interval" ,
228
274
Usage : "How frequently metrics are refreshed" ,
229
275
Flag : "metrics-cache-refresh-interval" ,
230
276
Hidden : true ,
231
277
Value : time .Hour ,
232
278
},
233
279
AgentStatRefreshInterval : codersdk.DeploymentConfigField [time.Duration ]{
280
+ Key : "agent_stat_refresh_interval" ,
234
281
Usage : "How frequently agent stats are recorded" ,
235
282
Flag : "agent-stats-refresh-interval" ,
236
283
Hidden : true ,
237
284
Value : 10 * time .Minute ,
238
285
},
239
286
Verbose : codersdk.DeploymentConfigField [bool ]{
287
+ Key : "verbose" ,
240
288
Usage : "Enables verbose logging." ,
241
289
Flag : "verbose" ,
242
290
Shorthand : "v" ,
243
291
},
244
292
AuditLogging : codersdk.DeploymentConfigField [bool ]{
293
+ Key : "audit_logging" ,
245
294
Usage : "Specifies whether audit logging is enabled." ,
246
295
Flag : "audit-logging" ,
247
296
Value : true ,
248
297
Enterprise : true ,
249
298
},
250
299
BrowserOnly : codersdk.DeploymentConfigField [bool ]{
300
+ Key : "browser_only" ,
251
301
Usage : "Whether Coder only allows connections to workspaces via the browser." ,
252
302
Flag : "browser-only" ,
253
303
Enterprise : true ,
254
304
},
255
305
SCIMAuthHeader : codersdk.DeploymentConfigField [string ]{
306
+ Key : "scim_auth_header" ,
256
307
Usage : "Enables SCIM and sets the authentication header for the built-in SCIM server. New users are automatically created with OIDC authentication." ,
257
308
Flag : "scim-auth-header" ,
258
309
Enterprise : true ,
259
310
},
260
311
UserWorkspaceQuota : codersdk.DeploymentConfigField [int ]{
312
+ Key : "user_workspace_quota" ,
261
313
Usage : "Enables and sets a limit on how many workspaces each user can create." ,
262
314
Flag : "user-workspace-quota" ,
263
315
Enterprise : true ,
@@ -267,11 +319,10 @@ func newConfig() codersdk.DeploymentConfig {
267
319
268
320
func Config (vip * viper.Viper ) codersdk.DeploymentConfig {
269
321
dc := newConfig ()
270
- dcv := reflect .ValueOf (dc ).Elem ()
322
+ dcv := reflect .ValueOf (& dc ).Elem ()
271
323
t := dcv .Type ()
272
324
for i := 0 ; i < t .NumField (); i ++ {
273
- fv := dcv .Field (i )
274
- fve := fv .Elem ()
325
+ fve := dcv .Field (i )
275
326
key := fve .FieldByName ("Key" ).String ()
276
327
value := fve .FieldByName ("Value" ).Interface ()
277
328
@@ -298,13 +349,12 @@ func NewViper() *viper.Viper {
298
349
v .SetEnvPrefix ("coder" )
299
350
v .AutomaticEnv ()
300
351
301
- dcv := reflect .ValueOf (dc ). Elem ()
352
+ dcv := reflect .ValueOf (dc )
302
353
t := dcv .Type ()
303
354
for i := 0 ; i < t .NumField (); i ++ {
304
355
fv := dcv .Field (i )
305
- fve := fv .Elem ()
306
- key := fve .FieldByName ("Key" ).String ()
307
- value := fve .FieldByName ("Value" ).Interface ()
356
+ key := fv .FieldByName ("Key" ).String ()
357
+ value := fv .FieldByName ("Value" ).Interface ()
308
358
v .SetDefault (key , value )
309
359
}
310
360
@@ -314,25 +364,24 @@ func NewViper() *viper.Viper {
314
364
//nolint:revive
315
365
func AttachFlags (flagset * pflag.FlagSet , vip * viper.Viper , enterprise bool ) {
316
366
dc := newConfig ()
317
- dcv := reflect .ValueOf (dc ). Elem ()
367
+ dcv := reflect .ValueOf (dc )
318
368
t := dcv .Type ()
319
369
for i := 0 ; i < t .NumField (); i ++ {
320
370
fv := dcv .Field (i )
321
- fve := fv .Elem ()
322
- isEnt := fve .FieldByName ("Enterprise" ).Bool ()
371
+ isEnt := fv .FieldByName ("Enterprise" ).Bool ()
323
372
if enterprise != isEnt {
324
373
continue
325
374
}
326
- key := fve .FieldByName ("Key" ).String ()
327
- flg := fve .FieldByName ("Flag" ).String ()
375
+ key := fv .FieldByName ("Key" ).String ()
376
+ flg := fv .FieldByName ("Flag" ).String ()
328
377
if flg == "" {
329
378
continue
330
379
}
331
- usage := fve .FieldByName ("Usage" ).String ()
380
+ usage := fv .FieldByName ("Usage" ).String ()
332
381
usage = fmt .Sprintf ("%s\n %s" , usage , cliui .Styles .Placeholder .Render ("Consumes $" + formatEnv (key )))
333
- shorthand := fve .FieldByName ("Shorthand" ).String ()
334
- hidden := fve .FieldByName ("Hidden" ).Bool ()
335
- value := fve .FieldByName ("Value" ).Interface ()
382
+ shorthand := fv .FieldByName ("Shorthand" ).String ()
383
+ hidden := fv .FieldByName ("Hidden" ).Bool ()
384
+ value := fv .FieldByName ("Value" ).Interface ()
336
385
337
386
switch value .(type ) {
338
387
case string :
0 commit comments