fix: label premium features in middleware error (#14360)

Previously, all features were called enterprise in the license check middleware.
This commit is contained in:
Asher
2024-08-19 15:58:41 -08:00
committed by GitHub
parent 4446d61fcd
commit f8f3d8967e
4 changed files with 59 additions and 10 deletions
+5 -1
View File
@@ -364,8 +364,12 @@ func (api *API) RequireFeatureMW(feat codersdk.FeatureName) func(http.Handler) h
enabled := api.entitlements.Features[feat].Enabled
api.entitlementsMu.RUnlock()
if !enabled {
licenseType := "a Premium"
if feat.Enterprise() {
licenseType = "an Enterprise"
}
httpapi.Write(r.Context(), rw, http.StatusForbidden, codersdk.Response{
Message: fmt.Sprintf("%s is an Enterprise feature. Contact sales!", feat.Humanize()),
Message: fmt.Sprintf("%s is %s feature. Contact sales!", feat.Humanize(), licenseType),
})
return
}