Skip to content
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
remove HasLicense field from Options and implement HasLicense method …
…in Entitlements
  • Loading branch information
kacpersaw committed Aug 19, 2025
commit ee58237e909c3914f60b38d82c798d3f0adf2188
2 changes: 0 additions & 2 deletions coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ type Options struct {
// Entitlements can come from the enterprise caller if enterprise code is
// included.
Entitlements *entitlements.Set
// HasLicense indicates if a license is installed.
HasLicense bool
// PostAuthAdditionalHeadersFunc is used to add additional headers to the response
// after a successful authentication.
// This is somewhat janky, but seemingly the only reasonable way to add a header
Expand Down
6 changes: 6 additions & 0 deletions coderd/entitlements/entitlements.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,9 @@ func (l *Set) Errors() []string {
defer l.entitlementsMu.RUnlock()
return slices.Clone(l.entitlements.Errors)
}

func (l *Set) HasLicense() bool {
l.entitlementsMu.RLock()
defer l.entitlementsMu.RUnlock()
return l.entitlements.HasLicense
}
4 changes: 1 addition & 3 deletions enterprise/coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,6 @@ func (api *API) updateEntitlements(ctx context.Context) error {
return codersdk.Entitlements{}, err
}

api.HasLicense = reloadedEntitlements.HasLicense

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