Skip to content

Commit c61abe5

Browse files
authored
add feature gates infrastructure (#263)
Signed-off-by: Bryce Palmer <[email protected]>
1 parent e7c62df commit c61abe5

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

cmd/manager/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/operator-framework/deppy/pkg/deppy/solver"
2424
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
25+
"github.com/spf13/pflag"
2526
"go.uber.org/zap/zapcore"
2627
"k8s.io/apimachinery/pkg/runtime"
2728
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -36,6 +37,7 @@ import (
3637
"github.com/operator-framework/operator-controller/internal/controllers"
3738
"github.com/operator-framework/operator-controller/internal/resolution/entitysources"
3839
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/olm"
40+
"github.com/operator-framework/operator-controller/pkg/features"
3941
)
4042

4143
var (
@@ -66,7 +68,10 @@ func main() {
6668
Development: true,
6769
}
6870
opts.BindFlags(flag.CommandLine)
69-
flag.Parse()
71+
72+
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
73+
features.OperatorControllerFeatureGate.AddFlag(pflag.CommandLine)
74+
pflag.Parse()
7075

7176
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts), zap.StacktraceLevel(zapcore.DPanicLevel)))
7277

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ require (
1111
github.com/operator-framework/deppy v0.0.0-20230602120738-cbf2c66b141b
1212
github.com/operator-framework/operator-registry v1.26.3
1313
github.com/operator-framework/rukpak v0.12.0
14+
github.com/spf13/pflag v1.0.5
1415
go.uber.org/zap v1.24.0
1516
k8s.io/apimachinery v0.26.1
1617
k8s.io/client-go v0.26.1
18+
k8s.io/component-base v0.26.1
1719
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
1820
sigs.k8s.io/controller-runtime v0.14.4
1921
)
@@ -53,7 +55,6 @@ require (
5355
github.com/prometheus/client_model v0.3.0 // indirect
5456
github.com/prometheus/common v0.37.0 // indirect
5557
github.com/prometheus/procfs v0.8.0 // indirect
56-
github.com/spf13/pflag v1.0.5 // indirect
5758
go.uber.org/atomic v1.7.0 // indirect
5859
go.uber.org/multierr v1.6.0 // indirect
5960
golang.org/x/net v0.10.0 // indirect
@@ -71,7 +72,6 @@ require (
7172
gopkg.in/yaml.v3 v3.0.1 // indirect
7273
k8s.io/api v0.26.1 // indirect
7374
k8s.io/apiextensions-apiserver v0.26.1 // indirect
74-
k8s.io/component-base v0.26.1 // indirect
7575
k8s.io/klog/v2 v2.80.1 // indirect
7676
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
7777
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect

pkg/features/features.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package features
2+
3+
import (
4+
"k8s.io/component-base/featuregate"
5+
)
6+
7+
const (
8+
// Add new feature gates constants (strings)
9+
// Ex: SomeFeature featuregate.Feature = "SomeFeature"
10+
)
11+
12+
var operatorControllerFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
13+
// Add new feature gate definitions
14+
// Ex: SomeFeature: {...}
15+
}
16+
17+
var OperatorControllerFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate()
18+
19+
func init() {
20+
OperatorControllerFeatureGate.Add(operatorControllerFeatureGates)
21+
}

0 commit comments

Comments
 (0)