Skip to content

Commit 41c2726

Browse files
committed
make enterprise = All - [multi-org]
1 parent 96f0b2d commit 41c2726

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

codersdk/deployment.go

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010
"path/filepath"
1111
"reflect"
12+
"slices"
1213
"strconv"
1314
"strings"
1415
"time"
@@ -144,26 +145,23 @@ const (
144145
func (set FeatureSet) Features() []FeatureName {
145146
switch FeatureSet(strings.ToLower(string(set))) {
146147
case FeatureSetEnterprise:
147-
// List all features that should be included in the Enterprise feature set.
148-
return []FeatureName{
149-
FeatureUserLimit,
150-
FeatureAuditLog,
151-
FeatureBrowserOnly,
152-
FeatureSCIM,
153-
FeatureTemplateRBAC,
154-
FeatureHighAvailability,
155-
FeatureMultipleExternalAuth,
156-
FeatureExternalProvisionerDaemons,
157-
FeatureAppearance,
158-
FeatureAdvancedTemplateScheduling,
159-
FeatureWorkspaceProxy,
160-
FeatureUserRoleManagement,
161-
FeatureExternalTokenEncryption,
162-
FeatureWorkspaceBatchActions,
163-
FeatureAccessControl,
164-
FeatureControlSharedPorts,
165-
FeatureCustomRoles,
166-
}
148+
// Enterprise is the set 'AllFeatures' minus some select features.
149+
150+
// Copy the list of all features
151+
enterpriseFeatures := make([]FeatureName, len(FeatureNames))
152+
copy(enterpriseFeatures, FeatureNames)
153+
// Remove the selection
154+
enterpriseFeatures = slices.DeleteFunc(enterpriseFeatures, func(f FeatureName) bool {
155+
switch f {
156+
// Add all features that should be excluded in the Enterprise feature set.
157+
case FeatureMultipleOrganizations:
158+
return true
159+
default:
160+
return false
161+
}
162+
})
163+
164+
return enterpriseFeatures
167165
case FeatureSetPremium:
168166
// FeatureSetPremium is a superset of Enterprise
169167
return append(FeatureSetEnterprise.Features(), FeatureMultipleOrganizations)

codersdk/deployment_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,5 +544,20 @@ func TestPremiumSuperSet(t *testing.T) {
544544

545545
enterprise := codersdk.FeatureSetEnterprise
546546
premium := codersdk.FeatureSetPremium
547+
548+
// Premium > Enterprise
549+
require.Greater(t, len(premium.Features()), len(enterprise.Features()), "premium should have more features than enterprise")
550+
551+
// Premium ⊃ Enterprise
547552
require.Subset(t, premium.Features(), enterprise.Features(), "premium should be a superset of enterprise. If this fails, update the premium feature set to include all enterprise features.")
553+
554+
// Premium = All Features
555+
// This is currently true. If this assertion changes, update this test
556+
// to reflect the change in feature sets.
557+
require.ElementsMatch(t, premium.Features(), codersdk.FeatureNames, "premium should contain all features")
558+
559+
// This check exists because if you misuse the slices.Delete, you can end up
560+
// with zero'd values.
561+
require.NotContains(t, enterprise.Features(), "", "enterprise should not contain empty string")
562+
require.NotContains(t, premium.Features(), "", "premium should not contain empty string")
548563
}

0 commit comments

Comments
 (0)