mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
Warn for every _ flag user or cmd defined
also renames all global _ flags to -
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
clientcmdapi "github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
)
|
||||
|
||||
func TestNewFactoryDefaultFlagBindings(t *testing.T) {
|
||||
@@ -153,3 +154,15 @@ func TestLabelsForObject(t *testing.T) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlagUnderscoreRenaming(t *testing.T) {
|
||||
factory := NewFactory(nil)
|
||||
|
||||
factory.flags.SetNormalizeFunc(util.WordSepNormalizeFunc)
|
||||
factory.flags.Bool("valid_flag", false, "bool value")
|
||||
|
||||
// In case of failure of this test check this PR: spf13/pflag#23
|
||||
if factory.flags.Lookup("valid_flag").Name != "valid-flag" {
|
||||
t.Fatalf("Expected flag name to be valid-flag, got %s", factory.flags.Lookup("valid_flag").Name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user