@@ -15,10 +15,8 @@ import (
15
15
16
16
"cdr.dev/slog"
17
17
"github.com/coder/coder/coderd"
18
- agplaudit "github.com/coder/coder/coderd/audit"
19
18
"github.com/coder/coder/coderd/httpapi"
20
19
"github.com/coder/coder/coderd/httpmw"
21
- "github.com/coder/coder/coderd/workspacequota"
22
20
"github.com/coder/coder/codersdk"
23
21
"github.com/coder/coder/enterprise/audit"
24
22
"github.com/coder/coder/enterprise/audit/backends"
@@ -98,9 +96,9 @@ type Options struct {
98
96
99
97
AuditLogging bool
100
98
// Whether to block non-browser connections.
101
- BrowserOnly bool
102
- SCIMAPIKey []byte
103
- WorkspaceQuota int
99
+ BrowserOnly bool
100
+ SCIMAPIKey []byte
101
+ UserWorkspaceQuota int
104
102
105
103
EntitlementsUpdateInterval time.Duration
106
104
Keys map [string ]ed25519.PublicKey
@@ -193,17 +191,16 @@ func (api *API) updateEntitlements(ctx context.Context) error {
193
191
}
194
192
195
193
if entitlements .auditLogs != api .entitlements .auditLogs {
196
- auditor := agplaudit .NewNop ()
197
194
// A flag could be added to the options that would allow disabling
198
195
// enhanced audit logging here!
199
196
if entitlements .auditLogs != codersdk .EntitlementNotEntitled && api .AuditLogging {
200
- auditor = audit .NewAuditor (
197
+ auditor : = audit .NewAuditor (
201
198
audit .DefaultFilter ,
202
199
backends .NewPostgres (api .Database , true ),
203
200
backends .NewSlog (api .Logger ),
204
201
)
202
+ api .AGPL .Auditor .Store (& auditor )
205
203
}
206
- api .AGPL .Auditor .Store (& auditor )
207
204
}
208
205
209
206
if entitlements .browserOnly != api .entitlements .browserOnly {
@@ -215,11 +212,10 @@ func (api *API) updateEntitlements(ctx context.Context) error {
215
212
}
216
213
217
214
if entitlements .workspaceQuota != api .entitlements .workspaceQuota {
218
- var enforcer workspacequota. Enforcer
219
- if entitlements . workspaceQuota != codersdk . EntitlementNotEntitled && api .WorkspaceQuota > 0 {
220
- enforcer = NewEnforcer ( api .WorkspaceQuota )
215
+ if entitlements . workspaceQuota != codersdk . EntitlementNotEntitled && api . Options . UserWorkspaceQuota > 0 {
216
+ enforcer := NewEnforcer ( api .Options . UserWorkspaceQuota )
217
+ api .AGPL . WorkspaceQuotaEnforcer . Store ( & enforcer )
221
218
}
222
- api .AGPL .WorkspaceQuotaEnforcer .Store (& enforcer )
223
219
}
224
220
225
221
api .entitlements = entitlements
@@ -279,9 +275,9 @@ func (api *API) serveEntitlements(rw http.ResponseWriter, r *http.Request) {
279
275
280
276
resp .Features [codersdk .FeatureWorkspaceQuota ] = codersdk.Feature {
281
277
Entitlement : entitlements .workspaceQuota ,
282
- Enabled : api .WorkspaceQuota > 0 ,
278
+ Enabled : api .UserWorkspaceQuota > 0 ,
283
279
}
284
- if entitlements .workspaceQuota == codersdk .EntitlementGracePeriod && api .WorkspaceQuota > 0 {
280
+ if entitlements .workspaceQuota == codersdk .EntitlementGracePeriod && api .UserWorkspaceQuota > 0 {
285
281
resp .Warnings = append (resp .Warnings ,
286
282
"Workspace quotas are enabled but your license for this feature is expired." )
287
283
}
0 commit comments