Skip to content

fix: label premium features in middleware error #14360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Flip license check
  • Loading branch information
code-asher committed Aug 19, 2024
commit 01d267336d6721f7fd387f258096acc14ddc9ee3
10 changes: 5 additions & 5 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ func (n FeatureName) AlwaysEnable() bool {
}[n]
}

// Premium returns true if the feature is a premium feature.
func (n FeatureName) Premium() bool {
// Enterprise returns true if the feature is an enterprise feature.
func (n FeatureName) Enterprise() bool {
switch n {
// Add all features that should be excluded in the Enterprise feature set.
case FeatureMultipleOrganizations, FeatureCustomRoles:
return true
default:
return false
default:
return true
}
}

Expand Down Expand Up @@ -163,7 +163,7 @@ func (set FeatureSet) Features() []FeatureName {
copy(enterpriseFeatures, FeatureNames)
// Remove the selection
enterpriseFeatures = slices.DeleteFunc(enterpriseFeatures, func(f FeatureName) bool {
return f.Premium()
return !f.Enterprise()
})

return enterpriseFeatures
Expand Down
6 changes: 3 additions & 3 deletions enterprise/coderd/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ func (api *API) RequireFeatureMW(feat codersdk.FeatureName) func(http.Handler) h
enabled := api.entitlements.Features[feat].Enabled
api.entitlementsMu.RUnlock()
if !enabled {
licenseType := "an Enterprise"
if feat.Premium() {
licenseType = "a Premium"
licenseType := "a Premium"
if feat.Enterprise() {
licenseType = "an Enterprise"
}
httpapi.Write(r.Context(), rw, http.StatusForbidden, codersdk.Response{
Message: fmt.Sprintf("%s is %s feature. Contact sales!", feat.Humanize(), licenseType),
Expand Down
Loading