mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-27 08:37:36 +00:00
@@ -86,7 +86,7 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
|
||||
mapper := kubectl.ShortcutExpander{latest.RESTMapper}
|
||||
|
||||
flags := pflag.NewFlagSet("", pflag.ContinueOnError)
|
||||
flags.SetWordSeparators([]string{"-", "_"})
|
||||
flags.SetNormalizeFunc(util.WordSepNormalizeFunc)
|
||||
|
||||
clientConfig := optionalClientConfig
|
||||
if optionalClientConfig == nil {
|
||||
|
||||
@@ -16,11 +16,23 @@ limitations under the License.
|
||||
|
||||
package util
|
||||
|
||||
import "strings"
|
||||
|
||||
import "github.com/spf13/pflag"
|
||||
|
||||
func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
from := []string{"-", "_"}
|
||||
to := "."
|
||||
for _, sep := range from {
|
||||
name = strings.Replace(name, sep, to, -1)
|
||||
}
|
||||
// Type convert to indicate normalization has been done.
|
||||
return pflag.NormalizedName(name)
|
||||
}
|
||||
|
||||
// InitFlags normalizes and parses the command line flags
|
||||
func InitFlags() {
|
||||
pflag.CommandLine.SetWordSeparators([]string{"-", "_"})
|
||||
pflag.CommandLine.SetNormalizeFunc(WordSepNormalizeFunc)
|
||||
AddAllFlagsToPFlags()
|
||||
pflag.Parse()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user