mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: Support config files with viper (#4696)
This commit is contained in:
+13
-12
@@ -24,10 +24,10 @@ import (
|
||||
)
|
||||
|
||||
func server() *cobra.Command {
|
||||
dflags := deployment.Flags()
|
||||
cmd := agpl.Server(dflags, func(ctx context.Context, options *agplcoderd.Options) (*agplcoderd.API, io.Closer, error) {
|
||||
if dflags.DerpServerRelayAddress.Value != "" {
|
||||
_, err := url.Parse(dflags.DerpServerRelayAddress.Value)
|
||||
vip := deployment.NewViper()
|
||||
cmd := agpl.Server(vip, func(ctx context.Context, options *agplcoderd.Options) (*agplcoderd.API, io.Closer, error) {
|
||||
if options.DeploymentConfig.DERPServerRelayURL.Value != "" {
|
||||
_, err := url.Parse(options.DeploymentConfig.DERPServerRelayURL.Value)
|
||||
if err != nil {
|
||||
return nil, nil, xerrors.Errorf("derp-server-relay-address must be a valid HTTP URL: %w", err)
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func server() *cobra.Command {
|
||||
}
|
||||
options.DERPServer.SetMeshKey(meshKey)
|
||||
|
||||
if dflags.AuditLogging.Value {
|
||||
if options.DeploymentConfig.AuditLogging.Value {
|
||||
options.Auditor = audit.NewAuditor(audit.DefaultFilter,
|
||||
backends.NewPostgres(options.Database, true),
|
||||
backends.NewSlog(options.Logger),
|
||||
@@ -58,13 +58,13 @@ func server() *cobra.Command {
|
||||
}
|
||||
|
||||
o := &coderd.Options{
|
||||
AuditLogging: dflags.AuditLogging.Value,
|
||||
BrowserOnly: dflags.BrowserOnly.Value,
|
||||
SCIMAPIKey: []byte(dflags.SCIMAuthHeader.Value),
|
||||
UserWorkspaceQuota: dflags.UserWorkspaceQuota.Value,
|
||||
AuditLogging: options.DeploymentConfig.AuditLogging.Value,
|
||||
BrowserOnly: options.DeploymentConfig.BrowserOnly.Value,
|
||||
SCIMAPIKey: []byte(options.DeploymentConfig.SCIMAPIKey.Value),
|
||||
UserWorkspaceQuota: options.DeploymentConfig.UserWorkspaceQuota.Value,
|
||||
RBAC: true,
|
||||
DERPServerRelayAddress: dflags.DerpServerRelayAddress.Value,
|
||||
DERPServerRegionID: dflags.DerpServerRegionID.Value,
|
||||
DERPServerRelayAddress: options.DeploymentConfig.DERPServerRelayURL.Value,
|
||||
DERPServerRegionID: options.DeploymentConfig.DERPServerRegionID.Value,
|
||||
|
||||
Options: options,
|
||||
}
|
||||
@@ -76,6 +76,7 @@ func server() *cobra.Command {
|
||||
return api.AGPL, api, nil
|
||||
})
|
||||
|
||||
deployment.AttachFlags(cmd.Flags(), dflags, true)
|
||||
deployment.AttachFlags(cmd.Flags(), vip, true)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user