FeatureFlags: Add helper to check against a set of flags (#97240)

This commit is contained in:
Ryan McKinley
2024-12-02 21:41:41 +02:00
committed by GitHub
parent 3448384e0d
commit 20a27da636
8 changed files with 36 additions and 13 deletions
+4 -4
View File
@@ -3,6 +3,7 @@ package scope
import (
"fmt"
"github.com/prometheus/client_golang/prometheus"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/authorization/authorizer"
@@ -12,8 +13,6 @@ import (
"k8s.io/kube-openapi/pkg/spec3"
"k8s.io/kube-openapi/pkg/validation/spec"
"github.com/prometheus/client_golang/prometheus"
scope "github.com/grafana/grafana/pkg/apis/scope/v0alpha1"
"github.com/grafana/grafana/pkg/services/apiserver/builder"
"github.com/grafana/grafana/pkg/services/featuremgmt"
@@ -29,8 +28,9 @@ func NewScopeAPIBuilder() *ScopeAPIBuilder {
}
func RegisterAPIService(features featuremgmt.FeatureToggles, apiregistration builder.APIRegistrar, reg prometheus.Registerer) *ScopeAPIBuilder {
if !(features.IsEnabledGlobally(featuremgmt.FlagScopeApi) ||
features.IsEnabledGlobally(featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs)) {
if !featuremgmt.AnyEnabled(features,
featuremgmt.FlagScopeApi,
featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs) {
return nil // skip registration unless opting into experimental apis
}
builder := NewScopeAPIBuilder()