refactor: deduplicate / type license feature code (#5734)

This commit is contained in:
Ammar Bandukwala
2023-01-17 17:04:29 -06:00
committed by GitHub
parent ea1b03f7c9
commit 501cfa9e8d
39 changed files with 648 additions and 396 deletions

View File

@ -238,7 +238,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
api.entitlementsMu.Lock()
defer api.entitlementsMu.Unlock()
entitlements, err := license.Entitlements(ctx, api.Database, api.Logger, len(api.replicaManager.All()), len(api.GitAuthConfigs), api.Keys, map[string]bool{
entitlements, err := license.Entitlements(ctx, api.Database, api.Logger, len(api.replicaManager.All()), len(api.GitAuthConfigs), api.Keys, map[codersdk.FeatureName]bool{
codersdk.FeatureAuditLog: api.AuditLogging,
codersdk.FeatureBrowserOnly: api.BrowserOnly,
codersdk.FeatureSCIM: len(api.SCIMAPIKey) != 0,
@ -252,7 +252,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
}
entitlements.Experimental = api.DeploymentConfig.Experimental.Value
featureChanged := func(featureName string) (changed bool, enabled bool) {
featureChanged := func(featureName codersdk.FeatureName) (changed bool, enabled bool) {
if api.entitlements.Features == nil {
return true, entitlements.Features[featureName].Enabled
}