Skip to content

Commit ee58237

Browse files
committed
remove HasLicense field from Options and implement HasLicense method in Entitlements
1 parent 3e2288b commit ee58237

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

coderd/coderd.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ type Options struct {
180180
// Entitlements can come from the enterprise caller if enterprise code is
181181
// included.
182182
Entitlements *entitlements.Set
183-
// HasLicense indicates if a license is installed.
184-
HasLicense bool
185183
// PostAuthAdditionalHeadersFunc is used to add additional headers to the response
186184
// after a successful authentication.
187185
// This is somewhat janky, but seemingly the only reasonable way to add a header

coderd/entitlements/entitlements.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,9 @@ func (l *Set) Errors() []string {
161161
defer l.entitlementsMu.RUnlock()
162162
return slices.Clone(l.entitlements.Errors)
163163
}
164+
165+
func (l *Set) HasLicense() bool {
166+
l.entitlementsMu.RLock()
167+
defer l.entitlementsMu.RUnlock()
168+
return l.entitlements.HasLicense
169+
}

enterprise/coderd/coderd.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,6 @@ func (api *API) updateEntitlements(ctx context.Context) error {
739739
return codersdk.Entitlements{}, err
740740
}
741741

742-
api.HasLicense = reloadedEntitlements.HasLicense
743-
744742
if reloadedEntitlements.RequireTelemetry && !api.DeploymentValues.Telemetry.Enable.Value() {
745743
api.Logger.Error(ctx, "license requires telemetry enabled")
746744
return codersdk.Entitlements{}, entitlements.ErrLicenseRequiresTelemetry
@@ -965,7 +963,7 @@ func (api *API) CheckBuildUsage(ctx context.Context, store database.Store, templ
965963
// When unlicensed, we need to check that we haven't breached the managed agent
966964
// limit.
967965
// Unlicensed deployments are allowed to use unlimited managed agents.
968-
if api.HasLicense {
966+
if api.Entitlements.HasLicense() {
969967
managedAgentLimit, ok := api.Entitlements.Feature(codersdk.FeatureManagedAgentLimit)
970968
if !ok || !managedAgentLimit.Enabled || managedAgentLimit.Limit == nil || managedAgentLimit.UsagePeriod == nil {
971969
return wsbuilder.UsageCheckResponse{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy