@@ -118,11 +118,11 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
118
118
119
119
// Coder tracing should be disabled if telemetry is disabled unless
120
120
// --telemetry-trace was explicitly provided.
121
- shouldCoderTrace := cfg .TelemetryEnable .Value && ! isTest ()
121
+ shouldCoderTrace := cfg .Telemetry . Enable .Value && ! isTest ()
122
122
// Only override if telemetryTraceEnable was specifically set.
123
123
// By default we want it to be controlled by telemetryEnable.
124
124
if cmd .Flags ().Changed ("telemetry-trace" ) {
125
- shouldCoderTrace = cfg .TelemetryTrace .Value
125
+ shouldCoderTrace = cfg .Telemetry . Trace .Value
126
126
}
127
127
128
128
if cfg .TraceEnable .Value || shouldCoderTrace {
@@ -175,13 +175,13 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
175
175
defer listener .Close ()
176
176
177
177
var tlsConfig * tls.Config
178
- if cfg .TLSEnable .Value {
178
+ if cfg .TLS . Enable .Value {
179
179
tlsConfig , err = configureTLS (
180
- cfg .TLSMinVersion .Value ,
181
- cfg .TLSClientAuth .Value ,
182
- cfg .TLSCertFiles .Value ,
183
- cfg .TLSKeyFiles .Value ,
184
- cfg .TLSClientCAFile .Value ,
180
+ cfg .TLS . MinVersion .Value ,
181
+ cfg .TLS . ClientAuth .Value ,
182
+ cfg .TLS . CertFiles .Value ,
183
+ cfg .TLS . KeyFiles .Value ,
184
+ cfg .TLS . ClientCAFile .Value ,
185
185
)
186
186
if err != nil {
187
187
return xerrors .Errorf ("configure tls: %w" , err )
@@ -203,7 +203,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
203
203
Scheme : "http" ,
204
204
Host : tcpAddr .String (),
205
205
}
206
- if cfg .TLSEnable .Value {
206
+ if cfg .TLS . Enable .Value {
207
207
localURL .Scheme = "https"
208
208
}
209
209
@@ -298,22 +298,22 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
298
298
299
299
defaultRegion := & tailcfg.DERPRegion {
300
300
EmbeddedRelay : true ,
301
- RegionID : cfg .DERPServerRegionID .Value ,
302
- RegionCode : cfg .DERPServerRegionCode .Value ,
303
- RegionName : cfg .DERPServerRegionName .Value ,
301
+ RegionID : cfg .DERP . Server . RegionID .Value ,
302
+ RegionCode : cfg .DERP . Server . RegionCode .Value ,
303
+ RegionName : cfg .DERP . Server . RegionName .Value ,
304
304
Nodes : []* tailcfg.DERPNode {{
305
- Name : fmt .Sprintf ("%db" , cfg .DERPServerRegionID .Value ),
306
- RegionID : cfg .DERPServerRegionID .Value ,
305
+ Name : fmt .Sprintf ("%db" , cfg .DERP . Server . RegionID .Value ),
306
+ RegionID : cfg .DERP . Server . RegionID .Value ,
307
307
HostName : accessURLParsed .Hostname (),
308
308
DERPPort : accessURLPort ,
309
309
STUNPort : - 1 ,
310
310
ForceHTTP : accessURLParsed .Scheme == "http" ,
311
311
}},
312
312
}
313
- if ! cfg .DERPServerEnable .Value {
313
+ if ! cfg .DERP . Server . Enable .Value {
314
314
defaultRegion = nil
315
315
}
316
- derpMap , err := tailnet .NewDERPMap (ctx , defaultRegion , cfg .DERPServerSTUNAddresses . Value , cfg .DERPConfigURL . Value , cfg .DERPConfigPath .Value )
316
+ derpMap , err := tailnet .NewDERPMap (ctx , defaultRegion , cfg .DERP . Server . STUNAddresses . Value , cfg .DERP . Config . URL . Value , cfg .DERP . Config . Path .Value )
317
317
if err != nil {
318
318
return xerrors .Errorf ("create derp map: %w" , err )
319
319
}
@@ -357,35 +357,35 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
357
357
MetricsCacheRefreshInterval : cfg .MetricsCacheRefreshInterval .Value ,
358
358
AgentStatsRefreshInterval : cfg .AgentStatRefreshInterval .Value ,
359
359
Experimental : ExperimentalEnabled (cmd ),
360
- DeploymentConfig : & cfg ,
360
+ DeploymentConfig : cfg ,
361
361
}
362
362
if tlsConfig != nil {
363
363
options .TLSCertificates = tlsConfig .Certificates
364
364
}
365
365
366
- if cfg .OAuth2GithubClientSecret .Value != "" {
366
+ if cfg .OAuth2 . Github . ClientSecret .Value != "" {
367
367
options .GithubOAuth2Config , err = configureGithubOAuth2 (accessURLParsed ,
368
- cfg .OAuth2GithubClientID .Value ,
369
- cfg .OAuth2GithubClientSecret .Value ,
370
- cfg .OAuth2GithubAllowSignups .Value ,
371
- cfg .OAuth2GithubAllowedOrgs .Value ,
372
- cfg .OAuth2GithubAllowedTeams .Value ,
373
- cfg .OAuth2GithubEnterpriseBaseURL .Value ,
368
+ cfg .OAuth2 . Github . ClientID .Value ,
369
+ cfg .OAuth2 . Github . ClientSecret .Value ,
370
+ cfg .OAuth2 . Github . AllowSignups .Value ,
371
+ cfg .OAuth2 . Github . AllowedOrgs .Value ,
372
+ cfg .OAuth2 . Github . AllowedTeams .Value ,
373
+ cfg .OAuth2 . Github . EnterpriseBaseURL .Value ,
374
374
)
375
375
if err != nil {
376
376
return xerrors .Errorf ("configure github oauth2: %w" , err )
377
377
}
378
378
}
379
379
380
- if cfg .OIDCClientSecret .Value != "" {
381
- if cfg .OIDCClientID .Value == "" {
380
+ if cfg .OIDC . ClientSecret .Value != "" {
381
+ if cfg .OIDC . ClientID .Value == "" {
382
382
return xerrors .Errorf ("OIDC client ID be set!" )
383
383
}
384
- if cfg .OIDCIssuerURL .Value == "" {
384
+ if cfg .OIDC . IssuerURL .Value == "" {
385
385
return xerrors .Errorf ("OIDC issuer URL must be set!" )
386
386
}
387
387
388
- oidcProvider , err := oidc .NewProvider (ctx , cfg .OIDCIssuerURL .Value )
388
+ oidcProvider , err := oidc .NewProvider (ctx , cfg .OIDC . IssuerURL .Value )
389
389
if err != nil {
390
390
return xerrors .Errorf ("configure oidc provider: %w" , err )
391
391
}
@@ -395,17 +395,17 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
395
395
}
396
396
options .OIDCConfig = & coderd.OIDCConfig {
397
397
OAuth2Config : & oauth2.Config {
398
- ClientID : cfg .OIDCClientID .Value ,
399
- ClientSecret : cfg .OIDCClientSecret .Value ,
398
+ ClientID : cfg .OIDC . ClientID .Value ,
399
+ ClientSecret : cfg .OIDC . ClientSecret .Value ,
400
400
RedirectURL : redirectURL .String (),
401
401
Endpoint : oidcProvider .Endpoint (),
402
- Scopes : cfg .OIDCScopes .Value ,
402
+ Scopes : cfg .OIDC . Scopes .Value ,
403
403
},
404
404
Verifier : oidcProvider .Verifier (& oidc.Config {
405
- ClientID : cfg .OIDCClientID .Value ,
405
+ ClientID : cfg .OIDC . ClientID .Value ,
406
406
}),
407
- EmailDomain : cfg .OIDCEmailDomain .Value ,
408
- AllowSignups : cfg .OIDCAllowSignups .Value ,
407
+ EmailDomain : cfg .OIDC . EmailDomain .Value ,
408
+ AllowSignups : cfg .OIDC . AllowSignups .Value ,
409
409
}
410
410
}
411
411
@@ -469,26 +469,26 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
469
469
}
470
470
471
471
// Parse the raw telemetry URL!
472
- telemetryURL , err := parseURL (ctx , cfg .TelemetryURL .Value )
472
+ telemetryURL , err := parseURL (ctx , cfg .Telemetry . URL .Value )
473
473
if err != nil {
474
474
return xerrors .Errorf ("parse telemetry url: %w" , err )
475
475
}
476
476
// Disable telemetry if the in-memory database is used unless explicitly defined!
477
- if cfg .InMemoryDatabase .Value && ! cmd .Flags ().Changed (cfg .TelemetryEnable .Flag ) {
478
- cfg .TelemetryEnable .Value = false
477
+ if cfg .InMemoryDatabase .Value && ! cmd .Flags ().Changed (cfg .Telemetry . Enable .Flag ) {
478
+ cfg .Telemetry . Enable .Value = false
479
479
}
480
- if cfg .TelemetryEnable .Value {
480
+ if cfg .Telemetry . Enable .Value {
481
481
options .Telemetry , err = telemetry .New (telemetry.Options {
482
482
BuiltinPostgres : builtinPostgres ,
483
483
DeploymentID : deploymentID ,
484
484
Database : options .Database ,
485
485
Logger : logger .Named ("telemetry" ),
486
486
URL : telemetryURL ,
487
- GitHubOAuth : cfg .OAuth2GithubClientID .Value != "" ,
488
- OIDCAuth : cfg .OIDCClientID .Value != "" ,
489
- OIDCIssuerURL : cfg .OIDCIssuerURL .Value ,
490
- Prometheus : cfg .PrometheusEnable .Value ,
491
- STUN : len (cfg .DERPServerSTUNAddresses .Value ) != 0 ,
487
+ GitHubOAuth : cfg .OAuth2 . Github . ClientID .Value != "" ,
488
+ OIDCAuth : cfg .OIDC . ClientID .Value != "" ,
489
+ OIDCIssuerURL : cfg .OIDC . IssuerURL .Value ,
490
+ Prometheus : cfg .Prometheus . Enable .Value ,
491
+ STUN : len (cfg .DERP . Server . STUNAddresses .Value ) != 0 ,
492
492
Tunnel : tunnel != nil ,
493
493
})
494
494
if err != nil {
@@ -499,11 +499,11 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
499
499
500
500
// This prevents the pprof import from being accidentally deleted.
501
501
_ = pprof .Handler
502
- if cfg .PprofEnable .Value {
502
+ if cfg .Pprof . Enable .Value {
503
503
//nolint:revive
504
- defer serveHandler (ctx , logger , nil , cfg .PprofAddress .Value , "pprof" )()
504
+ defer serveHandler (ctx , logger , nil , cfg .Pprof . Address .Value , "pprof" )()
505
505
}
506
- if cfg .PrometheusEnable .Value {
506
+ if cfg .Prometheus . Enable .Value {
507
507
options .PrometheusRegistry = prometheus .NewRegistry ()
508
508
closeUsersFunc , err := prometheusmetrics .ActiveUsers (ctx , options .PrometheusRegistry , options .Database , 0 )
509
509
if err != nil {
@@ -520,7 +520,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
520
520
//nolint:revive
521
521
defer serveHandler (ctx , logger , promhttp .InstrumentMetricHandler (
522
522
options .PrometheusRegistry , promhttp .HandlerFor (options .PrometheusRegistry , promhttp.HandlerOpts {}),
523
- ), cfg .PrometheusAddress .Value , "prometheus" )()
523
+ ), cfg .Prometheus . Address .Value , "prometheus" )()
524
524
}
525
525
526
526
// We use a separate coderAPICloser so the Enterprise API
@@ -532,7 +532,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
532
532
}
533
533
534
534
client := codersdk .New (localURL )
535
- if cfg .TLSEnable .Value {
535
+ if cfg .TLS . Enable .Value {
536
536
// Secure transport isn't needed for locally communicating!
537
537
client .HTTPClient .Transport = & http.Transport {
538
538
TLSClientConfig : & tls.Config {
0 commit comments