Skip to content

Commit 73d4261

Browse files
author
Simon Emms
committed
[licensor]: introduce concept of a fallback license with limited features
1 parent b94fa7f commit 73d4261

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

components/licensor/ee/pkg/licensor/licensor.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,18 @@ func (lvl LicenseLevel) allowance() allowance {
117117
return a
118118
}
119119

120+
// Fallback license is used when the instance exceeds the number of licenses - it allows limited access
121+
var fallbackLicense = LicensePayload{
122+
ID: "fallback-license",
123+
Level: LevelTeam,
124+
Seats: 0,
125+
// Domain, ValidUntil are free for all
126+
}
127+
128+
// Default license is used when no valid license is given - it allows full access up to 10 users
120129
var defaultLicense = LicensePayload{
121130
ID: "default-license",
122-
Level: LevelTeam,
131+
Level: LevelEnterprise,
123132
Seats: 10,
124133
// Domain, ValidUntil are free for all
125134
}
@@ -163,7 +172,15 @@ func (e *Evaluator) Enabled(feature Feature, seats int) bool {
163172
return false
164173
}
165174

166-
_, ok := e.lic.Level.allowance().Features[feature]
175+
var ok bool
176+
if e.lic.Seats == 0 || seats <= e.lic.Seats {
177+
// License has enough seats available - evaluate this license
178+
_, ok = e.lic.Level.allowance().Features[feature]
179+
} else {
180+
// License has run out of seats - use the fallback license
181+
_, ok = fallbackLicense.Level.allowance().Features[feature]
182+
}
183+
167184
return ok
168185
}
169186

0 commit comments

Comments
 (0)