| 25 | } |
| 26 | |
| 27 | func New() *Set { |
| 28 | s := &Set{ |
| 29 | // Some defaults for an unlicensed instance. |
| 30 | // These will be updated when coderd is initialized. |
| 31 | entitlements: codersdk.Entitlements{ |
| 32 | Features: map[codersdk.FeatureName]codersdk.Feature{}, |
| 33 | Warnings: []string{}, |
| 34 | Errors: []string{}, |
| 35 | HasLicense: false, |
| 36 | Trial: false, |
| 37 | RequireTelemetry: false, |
| 38 | RefreshedAt: time.Time{}, |
| 39 | }, |
| 40 | right2Update: make(chan struct{}, 1), |
| 41 | } |
| 42 | // Ensure all features are present in the entitlements. Our frontend |
| 43 | // expects this. |
| 44 | for _, featureName := range codersdk.FeatureNames { |
| 45 | s.entitlements.AddFeature(featureName, codersdk.Feature{ |
| 46 | Entitlement: codersdk.EntitlementNotEntitled, |
| 47 | Enabled: false, |
| 48 | }) |
| 49 | } |
| 50 | s.right2Update <- struct{}{} // one token, serialized updates |
| 51 | return s |
| 52 | } |
| 53 | |
| 54 | // ErrLicenseRequiresTelemetry is an error returned by a fetch passed to Update to indicate that the |
| 55 | // fetched license cannot be used because it requires telemetry. |