Skip to content

Commit 17603f5

Browse files
authored
chore: add runtimeconfig manager to options for plumbing (#14562)
1 parent 549e4fb commit 17603f5

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

cli/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import (
5656
"cdr.dev/slog"
5757
"cdr.dev/slog/sloggers/sloghuman"
5858
"github.com/coder/coder/v2/coderd/entitlements"
59+
"github.com/coder/coder/v2/coderd/runtimeconfig"
5960
"github.com/coder/pretty"
6061
"github.com/coder/quartz"
6162
"github.com/coder/retry"
@@ -820,6 +821,14 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
820821
return err
821822
}
822823

824+
// TODO: Throw a caching layer infront of the RuntimeConfig to prevent
825+
// excessive database queries.
826+
// Note: This happens before dbauthz, which is really unfortunate.
827+
// dbauthz is configured in `Coderd.New()`, but we need the manager
828+
// at this level for notifications. We might have to move some init
829+
// code around.
830+
options.RuntimeConfig = runtimeconfig.NewStoreManager(options.Database)
831+
823832
// This should be output before the logs start streaming.
824833
cliui.Infof(inv.Stdout, "\n==> Logs will stream in below (press ctrl+c to gracefully exit):")
825834

coderd/coderd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"cdr.dev/slog"
4040
"github.com/coder/coder/v2/coderd/entitlements"
4141
"github.com/coder/coder/v2/coderd/idpsync"
42+
"github.com/coder/coder/v2/coderd/runtimeconfig"
4243
"github.com/coder/quartz"
4344
"github.com/coder/serpent"
4445

@@ -135,6 +136,7 @@ type Options struct {
135136
Logger slog.Logger
136137
Database database.Store
137138
Pubsub pubsub.Pubsub
139+
RuntimeConfig runtimeconfig.Manager
138140

139141
// CacheDir is used for caching files served by the API.
140142
CacheDir string

coderd/coderdtest/coderdtest.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import (
6767
"github.com/coder/coder/v2/coderd/notifications"
6868
"github.com/coder/coder/v2/coderd/rbac"
6969
"github.com/coder/coder/v2/coderd/rbac/policy"
70+
"github.com/coder/coder/v2/coderd/runtimeconfig"
7071
"github.com/coder/coder/v2/coderd/schedule"
7172
"github.com/coder/coder/v2/coderd/telemetry"
7273
"github.com/coder/coder/v2/coderd/unhanger"
@@ -254,6 +255,10 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
254255
var acs dbauthz.AccessControlStore = dbauthz.AGPLTemplateAccessControlStore{}
255256
accessControlStore.Store(&acs)
256257

258+
// runtimeManager does not use dbauthz.
259+
// TODO: It probably should, but the init code for prod happens before dbauthz
260+
// is ready.
261+
runtimeManager := runtimeconfig.NewStoreManager(options.Database)
257262
options.Database = dbauthz.New(options.Database, options.Authorizer, *options.Logger, accessControlStore)
258263

259264
// Some routes expect a deployment ID, so just make sure one exists.
@@ -482,6 +487,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
482487
AppHostnameRegex: appHostnameRegex,
483488
Logger: *options.Logger,
484489
CacheDir: t.TempDir(),
490+
RuntimeConfig: runtimeManager,
485491
Database: options.Database,
486492
Pubsub: options.Pubsub,
487493
ExternalAuthConfigs: options.ExternalAuthConfigs,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy