mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: refactor entitlements to be a safe object to use (#14406)
* chore: refactor entitlements to be passable as an argument Previously, all usage of entitlements requires mutex usage on the api struct directly. This prevents passing the entitlements to a sub package. It also creates the possibility for misuse.
This commit is contained in:
@@ -35,6 +35,12 @@ const (
|
||||
EntitlementNotEntitled Entitlement = "not_entitled"
|
||||
)
|
||||
|
||||
// Entitled returns if the entitlement can be used. So this is true if it
|
||||
// is entitled or still in it's grace period.
|
||||
func (e Entitlement) Entitled() bool {
|
||||
return e == EntitlementEntitled || e == EntitlementGracePeriod
|
||||
}
|
||||
|
||||
// Weight converts the enum types to a numerical value for easier
|
||||
// comparisons. Easier than sets of if statements.
|
||||
func (e Entitlement) Weight() int {
|
||||
|
||||
Reference in New Issue
Block a user