Skip to content

Commit

Permalink
[licensor]: introduce concept of a fallback license with limited feat…
Browse files Browse the repository at this point in the history
…ures
  • Loading branch information
Simon Emms committed Mar 4, 2022
1 parent b94fa7f commit 73d4261
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions components/licensor/ee/pkg/licensor/licensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,18 @@ func (lvl LicenseLevel) allowance() allowance {
return a
}

// Fallback license is used when the instance exceeds the number of licenses - it allows limited access
var fallbackLicense = LicensePayload{
ID: "fallback-license",
Level: LevelTeam,
Seats: 0,
// Domain, ValidUntil are free for all
}

// Default license is used when no valid license is given - it allows full access up to 10 users
var defaultLicense = LicensePayload{
ID: "default-license",
Level: LevelTeam,
Level: LevelEnterprise,
Seats: 10,
// Domain, ValidUntil are free for all
}
Expand Down Expand Up @@ -163,7 +172,15 @@ func (e *Evaluator) Enabled(feature Feature, seats int) bool {
return false
}

_, ok := e.lic.Level.allowance().Features[feature]
var ok bool
if e.lic.Seats == 0 || seats <= e.lic.Seats {
// License has enough seats available - evaluate this license
_, ok = e.lic.Level.allowance().Features[feature]
} else {
// License has run out of seats - use the fallback license
_, ok = fallbackLicense.Level.allowance().Features[feature]
}

return ok
}

Expand Down

0 comments on commit 73d4261

Please sign in to comment.