mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: workspace quotas (#4184)
This commit is contained in:
@@ -57,7 +57,7 @@ func TestFeaturesList(t *testing.T) {
|
||||
var entitlements codersdk.Entitlements
|
||||
err := json.Unmarshal(buf.Bytes(), &entitlements)
|
||||
require.NoError(t, err, "unmarshal JSON output")
|
||||
assert.Len(t, entitlements.Features, 3)
|
||||
assert.Len(t, entitlements.Features, 4)
|
||||
assert.Empty(t, entitlements.Warnings)
|
||||
assert.Equal(t, codersdk.EntitlementNotEntitled,
|
||||
entitlements.Features[codersdk.FeatureUserLimit].Entitlement)
|
||||
@@ -65,6 +65,8 @@ func TestFeaturesList(t *testing.T) {
|
||||
entitlements.Features[codersdk.FeatureAuditLog].Entitlement)
|
||||
assert.Equal(t, codersdk.EntitlementNotEntitled,
|
||||
entitlements.Features[codersdk.FeatureBrowserOnly].Entitlement)
|
||||
assert.Equal(t, codersdk.EntitlementNotEntitled,
|
||||
entitlements.Features[codersdk.FeatureWorkspaceQuota].Entitlement)
|
||||
assert.False(t, entitlements.HasLicense)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,16 +15,18 @@ import (
|
||||
|
||||
func server() *cobra.Command {
|
||||
var (
|
||||
auditLogging bool
|
||||
browserOnly bool
|
||||
scimAuthHeader string
|
||||
auditLogging bool
|
||||
browserOnly bool
|
||||
scimAuthHeader string
|
||||
userWorkspaceQuota int
|
||||
)
|
||||
cmd := agpl.Server(func(ctx context.Context, options *agplcoderd.Options) (*agplcoderd.API, error) {
|
||||
api, err := coderd.New(ctx, &coderd.Options{
|
||||
AuditLogging: auditLogging,
|
||||
BrowserOnly: browserOnly,
|
||||
SCIMAPIKey: []byte(scimAuthHeader),
|
||||
Options: options,
|
||||
AuditLogging: auditLogging,
|
||||
BrowserOnly: browserOnly,
|
||||
SCIMAPIKey: []byte(scimAuthHeader),
|
||||
UserWorkspaceQuota: userWorkspaceQuota,
|
||||
Options: options,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -39,6 +41,8 @@ func server() *cobra.Command {
|
||||
"Whether Coder only allows connections to workspaces via the browser. "+enterpriseOnly)
|
||||
cliflag.StringVarP(cmd.Flags(), &scimAuthHeader, "scim-auth-header", "", "CODER_SCIM_API_KEY", "",
|
||||
"Enables SCIM and sets the authentication header for the built-in SCIM server. New users are automatically created with OIDC authentication. "+enterpriseOnly)
|
||||
cliflag.IntVarP(cmd.Flags(), &userWorkspaceQuota, "user-workspace-quota", "", "CODER_USER_WORKSPACE_QUOTA", 0,
|
||||
"A positive number applies a limit on how many workspaces each user can create. "+enterpriseOnly)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user