diff --git a/cmd/core/main.go b/cmd/core/main.go index 5b6cf91d..72cf2a8f 100644 --- a/cmd/core/main.go +++ b/cmd/core/main.go @@ -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" @@ -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 ( @@ -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()) diff --git a/go.mod b/go.mod index 9b03bead..031c941c 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/pkg/features/features.go b/pkg/features/features.go new file mode 100644 index 00000000..768834b3 --- /dev/null +++ b/pkg/features/features.go @@ -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)) +}