Skip to content

Commit 7436159

Browse files
committed
make enterprise = All - [multi-org]
1 parent f3b04bd commit 7436159

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
@@ -8,6 +8,7 @@ import (
88
"net/http"
99
"os"
1010
"path/filepath"
11+
"slices"
1112
"strconv"
1213
"strings"
1314
"time"
@@ -143,26 +144,23 @@ const (
143144
func (set FeatureSet) Features() []FeatureName {
144145
switch FeatureSet(strings.ToLower(string(set))) {
145146
case FeatureSetEnterprise:
146-
// List all features that should be included in the Enterprise feature set.
147-
return []FeatureName{
148-
FeatureUserLimit,
149-
FeatureAuditLog,
150-
FeatureBrowserOnly,
151-
FeatureSCIM,
152-
FeatureTemplateRBAC,
153-
FeatureHighAvailability,
154-
FeatureMultipleExternalAuth,
155-
FeatureExternalProvisionerDaemons,
156-
FeatureAppearance,
157-
FeatureAdvancedTemplateScheduling,
158-
FeatureWorkspaceProxy,
159-
FeatureUserRoleManagement,
160-
FeatureExternalTokenEncryption,
161-
FeatureWorkspaceBatchActions,
162-
FeatureAccessControl,
163-
FeatureControlSharedPorts,
164-
FeatureCustomRoles,
165-
}
147+
// Enterprise is the set 'AllFeatures' minus some select features.
148+
149+
// Copy the list of all features
150+
enterpriseFeatures := make([]FeatureName, len(FeatureNames))
151+
copy(enterpriseFeatures, FeatureNames)
152+
// Remove the selection
153+
enterpriseFeatures = slices.DeleteFunc(enterpriseFeatures, func(f FeatureName) bool {
154+
switch f {
155+
// Add all features that should be excluded in the Enterprise feature set.
156+
case FeatureMultipleOrganizations:
157+
return true
158+
default:
159+
return false
160+
}
161+
})
162+
163+
return enterpriseFeatures
166164
case FeatureSetPremium:
167165
// FeatureSetPremium is a superset of Enterprise
168166
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)