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