@@ -96,17 +96,6 @@ func Entitlements(
9696return codersdk.Entitlements {},xerrors .Errorf ("query active user count: %w" ,err )
9797}
9898
99- // nolint:gocritic // Getting external workspaces is a system function.
100- externalWorkspaces ,err := db .GetWorkspaces (dbauthz .AsSystemRestricted (ctx ), database.GetWorkspacesParams {
101- HasExternalAgent : sql.NullBool {
102- Bool :true ,
103- Valid :true ,
104- },
105- })
106- if err != nil {
107- return codersdk.Entitlements {},xerrors .Errorf ("query external workspaces: %w" ,err )
108- }
109-
11099// nolint:gocritic // Getting external templates is a system function.
111100externalTemplates ,err := db .GetTemplatesWithFilter (dbauthz .AsSystemRestricted (ctx ), database.GetTemplatesWithFilterParams {
112101HasExternalAgent : sql.NullBool {
@@ -119,11 +108,10 @@ func Entitlements(
119108}
120109
121110entitlements ,err := LicensesEntitlements (ctx ,now ,licenses ,enablements ,keys ,FeatureArguments {
122- ActiveUserCount :activeUserCount ,
123- ReplicaCount :replicaCount ,
124- ExternalAuthCount :externalAuthCount ,
125- ExternalWorkspaceCount :int64 (len (externalWorkspaces )),
126- ExternalTemplateCount :int64 (len (externalTemplates )),
111+ ActiveUserCount :activeUserCount ,
112+ ReplicaCount :replicaCount ,
113+ ExternalAuthCount :externalAuthCount ,
114+ ExternalTemplateCount :int64 (len (externalTemplates )),
127115ManagedAgentCountFn :func (ctx context.Context ,startTime time.Time ,endTime time.Time ) (int64 ,error ) {
128116// This is not super accurate, as the start and end times will be
129117// truncated to the date in UTC timezone. This is an optimization
@@ -149,11 +137,10 @@ func Entitlements(
149137}
150138
151139type FeatureArguments struct {
152- ActiveUserCount int64
153- ReplicaCount int
154- ExternalAuthCount int
155- ExternalWorkspaceCount int64
156- ExternalTemplateCount int64
140+ ActiveUserCount int64
141+ ReplicaCount int
142+ ExternalAuthCount int
143+ ExternalTemplateCount int64
157144// Unfortunately, managed agent count is not a simple count of the current
158145// state of the world, but a count between two points in time determined by
159146// the licenses.
@@ -477,18 +464,6 @@ func LicensesEntitlements(
477464}
478465}
479466
480- if featureArguments .ExternalWorkspaceCount > 0 {
481- feature := entitlements .Features [codersdk .FeatureWorkspaceExternalAgent ]
482- switch feature .Entitlement {
483- case codersdk .EntitlementNotEntitled :
484- entitlements .Errors = append (entitlements .Errors ,
485- "You have external workspaces but your license is not entitled to this feature." )
486- case codersdk .EntitlementGracePeriod :
487- entitlements .Warnings = append (entitlements .Warnings ,
488- "You have external workspaces but your license is expired." )
489- }
490- }
491-
492467if featureArguments .ExternalTemplateCount > 0 {
493468feature := entitlements .Features [codersdk .FeatureWorkspaceExternalAgent ]
494469switch feature .Entitlement {