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:
Steven Masley
2024-08-23 16:21:58 -05:00
committed by GitHub
parent cb6a47227f
commit af125c3795
17 changed files with 247 additions and 124 deletions
+6
View File
@@ -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 {