IsFeatureEnabled returns whether a feature is enabled.
(ctx context.Context, workspaceID string, f v1pb.PlanFeature)
| 285 | |
| 286 | // IsFeatureEnabled returns whether a feature is enabled. |
| 287 | func (s *LicenseService) IsFeatureEnabled(ctx context.Context, workspaceID string, f v1pb.PlanFeature) error { |
| 288 | plan := s.GetEffectivePlan(ctx, workspaceID) |
| 289 | features, ok := planFeatureMatrix[plan] |
| 290 | if !ok || !features[f] { |
| 291 | minimalPlan := v1pb.PlanType_ENTERPRISE |
| 292 | if planFeatureMatrix[v1pb.PlanType_TEAM][f] { |
| 293 | minimalPlan = v1pb.PlanType_TEAM |
| 294 | } |
| 295 | return errors.Errorf("feature %s is a %s feature, please upgrade to access it", f.String(), minimalPlan.String()) |
| 296 | } |
| 297 | return nil |
| 298 | } |
| 299 | |
| 300 | // IsFeatureEnabledForInstance returns whether a feature is enabled for the instance. |
| 301 | func (s *LicenseService) IsFeatureEnabledForInstance(ctx context.Context, workspaceID string, f v1pb.PlanFeature, instance *store.InstanceMessage) error { |
no test coverage detected