@@ -35,6 +35,7 @@ import (
35
35
"github.com/coder/coder/coderd/rbac"
36
36
"github.com/coder/coder/coderd/telemetry"
37
37
"github.com/coder/coder/coderd/tracing"
38
+ "github.com/coder/coder/coderd/workspacequota"
38
39
"github.com/coder/coder/coderd/wsconncache"
39
40
"github.com/coder/coder/codersdk"
40
41
"github.com/coder/coder/site"
@@ -55,6 +56,7 @@ type Options struct {
55
56
CacheDir string
56
57
57
58
Auditor audit.Auditor
59
+ WorkspaceQuotaEnforcer workspacequota.Enforcer
58
60
AgentConnectionUpdateFrequency time.Duration
59
61
AgentInactiveDisconnectTimeout time.Duration
60
62
// APIRateLimit is the minutely throughput rate limit per user or ip.
@@ -120,6 +122,9 @@ func New(options *Options) *API {
120
122
if options .Auditor == nil {
121
123
options .Auditor = audit .NewNop ()
122
124
}
125
+ if options .WorkspaceQuotaEnforcer == nil {
126
+ options .WorkspaceQuotaEnforcer = workspacequota .NewNop ()
127
+ }
123
128
124
129
siteCacheDir := options .CacheDir
125
130
if siteCacheDir != "" {
@@ -145,10 +150,12 @@ func New(options *Options) *API {
145
150
Authorizer : options .Authorizer ,
146
151
Logger : options .Logger ,
147
152
},
148
- metricsCache : metricsCache ,
149
- Auditor : atomic.Pointer [audit.Auditor ]{},
153
+ metricsCache : metricsCache ,
154
+ Auditor : atomic.Pointer [audit.Auditor ]{},
155
+ WorkspaceQuotaEnforcer : atomic.Pointer [workspacequota.Enforcer ]{},
150
156
}
151
157
api .Auditor .Store (& options .Auditor )
158
+ api .WorkspaceQuotaEnforcer .Store (& options .WorkspaceQuotaEnforcer )
152
159
api .workspaceAgentCache = wsconncache .New (api .dialWorkspaceAgentTailnet , 0 )
153
160
api .derpServer = derp .NewServer (key .NewNode (), tailnet .Logger (options .Logger ))
154
161
oauthConfigs := & httpmw.OAuth2Configs {
@@ -516,6 +523,7 @@ type API struct {
516
523
* Options
517
524
Auditor atomic.Pointer [audit.Auditor ]
518
525
WorkspaceClientCoordinateOverride atomic.Pointer [func (rw http.ResponseWriter ) bool ]
526
+ WorkspaceQuotaEnforcer atomic.Pointer [workspacequota.Enforcer ]
519
527
HTTPAuth * HTTPAuthorizer
520
528
521
529
// APIHandler serves "/api/v2"
0 commit comments