command lines: always show flags with hyphens

All Kubernetes commands should show flags with hyphens in their help text even
when the flag originally was defined with underscore. Converting a command to
this style is not breaking its command line API because the old-style parameter
with underscore is accepted as alias.

The easiest solution to achieve this is to set normalization shortly before
running the command in the new central cli.Run or the few places where that
function isn't used yet.

There may be some texts which depends on normalization at flag definition time,
like the --logging-format usage warning. Those get generated assuming that
hyphens will be used.
This commit is contained in:
Patrick Ohly
2021-09-28 20:59:15 +02:00
parent 21d1bcd6b8
commit 00e4a599f6
24 changed files with 13 additions and 73 deletions

View File

@@ -23,10 +23,7 @@ package main
import (
"os"
"github.com/spf13/pflag"
"k8s.io/component-base/cli"
cliflag "k8s.io/component-base/cli/flag"
_ "k8s.io/component-base/logs/json/register" // for JSON log format registration
_ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugin
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration
@@ -34,8 +31,6 @@ import (
)
func main() {
pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
command := app.NewControllerManagerCommand()
code := cli.Run(command)
os.Exit(code)