Skip to content

Commit

Permalink
set example featuregate to comment
Browse files Browse the repository at this point in the history
Signed-off-by: googs1025 <[email protected]>
  • Loading branch information
googs1025 committed May 12, 2024
1 parent 9042608 commit 3596dd1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package main

import (
"flag"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"os"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
Expand All @@ -27,6 +26,7 @@ import (

"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
Expand Down
18 changes: 9 additions & 9 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import (
)

const (
// Example
// owner: <feature owner>
// kep: <KEP link>
// alpha: v0.5
// beta: v0.6
//
// Enables example.
Example featuregate.Feature = "Example"
// Example
// owner: <feature owner>
// kep: <KEP link>
// alpha: v0.5
// beta: v0.6
//
// Enables example.
// Example featuregate.Feature = "Example"
)

func init() {
Expand All @@ -48,7 +48,7 @@ func init() {
// Entries are separated from each other with blank lines to avoid sweeping gofmt changes
// when adding or removing one entry.
var defaultFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
Example: {Default: true, PreRelease: featuregate.Beta},
// Example: {Default: true, PreRelease: featuregate.Beta},
}

func SetFeatureGateDuringTest(tb testing.TB, f featuregate.Feature, value bool) func() {
Expand Down
14 changes: 6 additions & 8 deletions pkg/features/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ package features

import (
"testing"

utilfeature "k8s.io/apiserver/pkg/util/feature"
featuregatetesting "k8s.io/component-base/featuregate/testing"
)

func TestFeatureGate(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, Example, true)()

if !utilfeature.DefaultFeatureGate.Enabled(Example) {
t.Error("feature gate should be enabled")
}
// TODO: add test case
//defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, Example, true)()
//
//if !utilfeature.DefaultFeatureGate.Enabled(Example) {
// t.Error("feature gate should be enabled")
//}
}

0 comments on commit 3596dd1

Please sign in to comment.