chore: keep entitlements in the options only, simplify fields (#14434)

* chore: refactor entitlements to keep it in just the options

Duplicating the reference did not feel valuable, just confusing
This commit is contained in:
Steven Masley
2024-08-26 13:05:03 -05:00
committed by GitHub
parent fb6b954222
commit 93eef7b542
11 changed files with 27 additions and 25 deletions

View File

@ -18,7 +18,7 @@ const TimeFormatHHMM = "15:04"
func (api *API) autostopRequirementEnabledMW(next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
feature, ok := api.entitlements.Feature(codersdk.FeatureAdvancedTemplateScheduling)
feature, ok := api.Entitlements.Feature(codersdk.FeatureAdvancedTemplateScheduling)
if !ok || !feature.Entitlement.Entitled() {
httpapi.Write(r.Context(), rw, http.StatusForbidden, codersdk.Response{
Message: "Advanced template scheduling (and user quiet hours schedule) is an Enterprise feature. Contact sales!",