Skip to content

Commit

Permalink
Adds feature gates infrastructure
Browse files Browse the repository at this point in the history
Signed-off-by: Joaquim Moreno Prusi <joaquim@redhat.com>
  • Loading branch information
jmprusi authored and ncdc committed Oct 2, 2023
1 parent 3ac325f commit 29a1957
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
7 changes: 6 additions & 1 deletion cmd/core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/gorilla/handlers"
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"
"github.com/spf13/pflag"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -52,6 +53,7 @@ import (
"github.com/operator-framework/rukpak/internal/uploadmgr"
"github.com/operator-framework/rukpak/internal/util"
"github.com/operator-framework/rukpak/internal/version"
"github.com/operator-framework/rukpak/pkg/features"
)

var (
Expand Down Expand Up @@ -99,7 +101,10 @@ func main() {
Development: true,
}
opts.BindFlags(flag.CommandLine)
flag.Parse()

pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
features.RukpakFeatureGate.AddFlag(pflag.CommandLine)
pflag.Parse()

if rukpakVersion {
fmt.Println(version.String())
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/operator-framework/helm-operator-plugins v0.0.11
github.com/operator-framework/operator-registry v1.28.0
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.13.0
golang.org/x/sync v0.3.0
Expand All @@ -25,6 +26,7 @@ require (
k8s.io/apimachinery v0.26.1
k8s.io/cli-runtime v0.26.1
k8s.io/client-go v0.26.1
k8s.io/component-base v0.26.1
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
sigs.k8s.io/controller-runtime v0.14.4
sigs.k8s.io/yaml v1.3.0
Expand Down Expand Up @@ -149,7 +151,6 @@ require (
github.com/sirupsen/logrus v1.9.2 // indirect
github.com/skeema/knownhosts v1.2.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
Expand Down Expand Up @@ -189,7 +190,6 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/kubectl v0.26.1 // indirect
Expand Down
22 changes: 22 additions & 0 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package features

import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/component-base/featuregate"
)

const (
// Add new feature gates constants (strings)
// Ex: SomeFeature featuregate.Feature = "SomeFeature"
)

var rukpakFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
// Add new feature gate definitions
// Ex: SomeFeature: {...}
}

var RukpakFeatureGate featuregate.MutableFeatureGate = featuregate.NewFeatureGate()

func init() {
utilruntime.Must(RukpakFeatureGate.Add(rukpakFeatureGates))
}

0 comments on commit 29a1957

Please sign in to comment.