From a1ea3df0f1a59b3a68e43cfc20b46f0896bd5035 Mon Sep 17 00:00:00 2001 From: Anastasis Andronidis Date: Wed, 20 May 2015 21:55:29 +0200 Subject: [PATCH 1/2] updated cobra and pflag --- Godeps/Godeps.json | 4 +- .../src/github.com/spf13/cobra/cobra_test.go | 66 +++++++++- .../src/github.com/spf13/cobra/command.go | 54 +++++++-- .../src/github.com/spf13/cobra/md_docs.go | 26 +++- .../src/github.com/spf13/cobra/md_docs.md | 48 +++++++- .../src/github.com/spf13/pflag/.travis.yml | 8 ++ .../src/github.com/spf13/pflag/README.md | 36 ++++++ .../src/github.com/spf13/pflag/bool_test.go | 10 +- .../src/github.com/spf13/pflag/flag.go | 113 +++++++++--------- .../src/github.com/spf13/pflag/flag_test.go | 66 ++++++++-- 10 files changed, 331 insertions(+), 100 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/.travis.yml diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 99ff32c8e10..98922b6fad6 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -413,11 +413,11 @@ }, { "ImportPath": "github.com/spf13/cobra", - "Rev": "bba56042cf767e329430e7c7f68c3f9f640b4b8b" + "Rev": "8f5946caaeeff40a98d67f60c25e89c3525038a3" }, { "ImportPath": "github.com/spf13/pflag", - "Rev": "d4ebabf889f7b016ffcb5f74c350e1e5424b2094" + "Rev": "b91b2a94780f4e6b4d3b0c12fd9b5f4b05b1aa45" }, { "ImportPath": "github.com/stretchr/objx", diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/cobra_test.go b/Godeps/_workspace/src/github.com/spf13/cobra/cobra_test.go index 56746495a89..9848d211f49 100644 --- a/Godeps/_workspace/src/github.com/spf13/cobra/cobra_test.go +++ b/Godeps/_workspace/src/github.com/spf13/cobra/cobra_test.go @@ -4,15 +4,18 @@ import ( "bytes" "fmt" "os" + "reflect" "runtime" "strings" "testing" + + "github.com/spf13/pflag" ) var _ = fmt.Println var _ = os.Stderr -var tp, te, tt, t1 []string +var tp, te, tt, t1, tr []string var rootPersPre, echoPre, echoPersPre, timesPersPre []string var flagb1, flagb2, flagb3, flagbr, flagbp bool var flags1, flags2a, flags2b, flags3 string @@ -99,6 +102,7 @@ var cmdRootWithRun = &Command{ Short: "The root can run it's own function", Long: "The root description for help", Run: func(cmd *Command, args []string) { + tr = args rootcalled = true }, } @@ -181,7 +185,7 @@ func initializeWithSameName() *Command { func initializeWithRootCmd() *Command { cmdRootWithRun.ResetCommands() - tt, tp, te, rootcalled = nil, nil, nil, false + tt, tp, te, tr, rootcalled = nil, nil, nil, nil, false flagInit() cmdRootWithRun.Flags().BoolVarP(&flagbr, "boolroot", "b", false, "help message for flag boolroot") cmdRootWithRun.Flags().IntVarP(&flagir, "introot", "i", 321, "help message for flag introot") @@ -481,7 +485,7 @@ func TestChildCommandFlags(t *testing.T) { t.Errorf("invalid input should generate error") } - if !strings.Contains(r.Output, "invalid argument \"10E\" for -i10E") { + if !strings.Contains(r.Output, "invalid argument \"10E\" for i10E") { t.Errorf("Wrong error message displayed, \n %s", r.Output) } } @@ -494,7 +498,7 @@ func TestTrailingCommandFlags(t *testing.T) { } } -func TestInvalidSubCommandFlags(t *testing.T) { +func TestInvalidSubcommandFlags(t *testing.T) { cmd := initializeWithRootCmd() cmd.AddCommand(cmdTimes) @@ -508,7 +512,7 @@ func TestInvalidSubCommandFlags(t *testing.T) { } -func TestSubCommandArgEvaluation(t *testing.T) { +func TestSubcommandArgEvaluation(t *testing.T) { cmd := initializeWithRootCmd() first := &Command{ @@ -777,7 +781,7 @@ func TestFlagsBeforeCommand(t *testing.T) { // With parsing error properly reported x = fullSetupTest("-i10E echo") - if !strings.Contains(x.Output, "invalid argument \"10E\" for -i10E") { + if !strings.Contains(x.Output, "invalid argument \"10E\" for i10E") { t.Errorf("Wrong error message displayed, \n %s", x.Output) } @@ -819,6 +823,31 @@ func TestRemoveCommand(t *testing.T) { } } +func TestCommandWithoutSubcommands(t *testing.T) { + c := initializeWithRootCmd() + + x := simpleTester(c, "") + if x.Error != nil { + t.Errorf("Calling command without subcommands should not have error: %v", x.Error) + return + } +} + +func TestCommandWithoutSubcommandsWithArg(t *testing.T) { + c := initializeWithRootCmd() + expectedArgs := []string{"arg"} + + x := simpleTester(c, "arg") + if x.Error != nil { + t.Errorf("Calling command without subcommands but with arg should not have error: %v", x.Error) + return + } + if !reflect.DeepEqual(expectedArgs, tr) { + t.Errorf("Calling command without subcommands but with arg has wrong args: expected: %v, actual: %v", expectedArgs, tr) + return + } +} + func TestReplaceCommandWithRemove(t *testing.T) { versionUsed = 0 c := initializeWithRootCmd() @@ -886,3 +915,28 @@ func TestPeristentPreRunPropagation(t *testing.T) { t.Error("RootCmd PersistentPreRun not called but should have been") } } + +func TestGlobalNormFuncPropagation(t *testing.T) { + normFunc := func(f *pflag.FlagSet, name string) pflag.NormalizedName { + return pflag.NormalizedName(name) + } + + rootCmd := initialize() + rootCmd.SetGlobalNormalizationFunc(normFunc) + if reflect.ValueOf(normFunc) != reflect.ValueOf(rootCmd.GlobalNormalizationFunc()) { + t.Error("rootCmd seems to have a wrong normalization function") + } + + // First add the cmdEchoSub to cmdPrint + cmdPrint.AddCommand(cmdEchoSub) + if cmdPrint.GlobalNormalizationFunc() != nil && cmdEchoSub.GlobalNormalizationFunc() != nil { + t.Error("cmdPrint and cmdEchoSub should had no normalization functions") + } + + // Now add cmdPrint to rootCmd + rootCmd.AddCommand(cmdPrint) + if reflect.ValueOf(cmdPrint.GlobalNormalizationFunc()).Pointer() != reflect.ValueOf(rootCmd.GlobalNormalizationFunc()).Pointer() || + reflect.ValueOf(cmdEchoSub.GlobalNormalizationFunc()).Pointer() != reflect.ValueOf(rootCmd.GlobalNormalizationFunc()).Pointer() { + t.Error("cmdPrint and cmdEchoSub should had the normalization function of rootCmd") + } +} diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/command.go b/Godeps/_workspace/src/github.com/spf13/cobra/command.go index 978c4b09634..3831c3376bd 100644 --- a/Godeps/_workspace/src/github.com/spf13/cobra/command.go +++ b/Godeps/_workspace/src/github.com/spf13/cobra/command.go @@ -18,13 +18,14 @@ package cobra import ( "bytes" "fmt" - "github.com/inconshreveable/mousetrap" - flag "github.com/spf13/pflag" "io" "os" "runtime" "strings" "time" + + "github.com/inconshreveable/mousetrap" + flag "github.com/spf13/pflag" ) // Command is just that, a command for your application. @@ -93,6 +94,8 @@ type Command struct { helpFunc func(*Command, []string) // Help can be defined by application helpCommand *Command // The help command helpFlagVal bool + // The global normalization function that we can use on every pFlag set and children commands + globNormFunc func(f *flag.FlagSet, name string) flag.NormalizedName } // os.Args[1:] by default, if desired, can be overridden @@ -151,6 +154,19 @@ func (c *Command) SetHelpTemplate(s string) { c.helpTemplate = s } +// SetGlobalNormalizationFunc sets a normalization function to all flag sets and also to child commands. +// The user should not have a cyclic dependency on commands. +func (c *Command) SetGlobalNormalizationFunc(n func(f *flag.FlagSet, name string) flag.NormalizedName) { + c.Flags().SetNormalizeFunc(n) + c.PersistentFlags().SetNormalizeFunc(n) + c.LocalFlags().SetNormalizeFunc(n) + c.globNormFunc = n + + for _, command := range c.commands { + command.SetGlobalNormalizationFunc(n) + } +} + func (c *Command) UsageFunc() (f func(*Command) error) { if c.usageFunc != nil { return c.usageFunc @@ -360,25 +376,28 @@ func argsMinusFirstX(args []string, x string) []string { // find the target command given the args and command tree // Meant to be run on the highest node. Only searches down. -func (c *Command) Find(arrs []string) (*Command, []string, error) { +func (c *Command) Find(args []string) (*Command, []string, error) { if c == nil { return nil, nil, fmt.Errorf("Called find() on a nil Command") } - if len(arrs) == 0 { - return c.Root(), arrs, nil + // If there are no arguments, return the root command. If the root has no + // subcommands, args reflects arguments that should actually be passed to + // the root command, so also return the root command. + if len(args) == 0 || !c.Root().HasSubCommands() { + return c.Root(), args, nil } var innerfind func(*Command, []string) (*Command, []string) - innerfind = func(c *Command, args []string) (*Command, []string) { - if len(args) > 0 && c.HasSubCommands() { - argsWOflags := stripFlags(args, c) + innerfind = func(c *Command, innerArgs []string) (*Command, []string) { + if len(innerArgs) > 0 && c.HasSubCommands() { + argsWOflags := stripFlags(innerArgs, c) if len(argsWOflags) > 0 { matches := make([]*Command, 0) for _, cmd := range c.commands { if cmd.Name() == argsWOflags[0] || cmd.HasAlias(argsWOflags[0]) { // exact name or alias match - return innerfind(cmd, argsMinusFirstX(args, argsWOflags[0])) + return innerfind(cmd, argsMinusFirstX(innerArgs, argsWOflags[0])) } else if EnablePrefixMatching { if strings.HasPrefix(cmd.Name(), argsWOflags[0]) { // prefix match matches = append(matches, cmd) @@ -393,18 +412,18 @@ func (c *Command) Find(arrs []string) (*Command, []string, error) { // only accept a single prefix match - multiple matches would be ambiguous if len(matches) == 1 { - return innerfind(matches[0], argsMinusFirstX(args, argsWOflags[0])) + return innerfind(matches[0], argsMinusFirstX(innerArgs, argsWOflags[0])) } } } - return c, args + return c, innerArgs } - commandFound, a := innerfind(c, arrs) + commandFound, a := innerfind(c, args) // If we matched on the root, but we asked for a subcommand, return an error - if commandFound.Name() == c.Name() && len(stripFlags(arrs, c)) > 0 && commandFound.Name() != arrs[0] { + if commandFound.Name() == c.Name() && len(stripFlags(args, c)) > 0 && commandFound.Name() != args[0] { return nil, a, fmt.Errorf("unknown command %q", a[0]) } @@ -606,6 +625,10 @@ func (c *Command) AddCommand(cmds ...*Command) { if nameLen > c.commandsMaxNameLen { c.commandsMaxNameLen = nameLen } + // If glabal normalization function exists, update all children + if c.globNormFunc != nil { + x.SetGlobalNormalizationFunc(c.globNormFunc) + } c.commands = append(c.commands, x) } } @@ -830,6 +853,11 @@ func (c *Command) HasParent() bool { return c.parent != nil } +// GlobalNormalizationFunc returns the global normalization function or nil if doesn't exists +func (c *Command) GlobalNormalizationFunc() func(f *flag.FlagSet, name string) flag.NormalizedName { + return c.globNormFunc +} + // Get the complete FlagSet that applies to this command (local and persistent declared here and by all parents) func (c *Command) Flags() *flag.FlagSet { if c.flags == nil { diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/md_docs.go b/Godeps/_workspace/src/github.com/spf13/cobra/md_docs.go index 4a57ebd0c6e..6092c85af68 100644 --- a/Godeps/_workspace/src/github.com/spf13/cobra/md_docs.go +++ b/Godeps/_workspace/src/github.com/spf13/cobra/md_docs.go @@ -47,6 +47,10 @@ func (s byName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s byName) Less(i, j int) bool { return s[i].Name() < s[j].Name() } func GenMarkdown(cmd *Command, out *bytes.Buffer) { + GenMarkdownCustom(cmd, out, func(s string) string { return s }) +} + +func GenMarkdownCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string) string) { name := cmd.CommandPath() short := cmd.Short @@ -78,7 +82,7 @@ func GenMarkdown(cmd *Command, out *bytes.Buffer) { pname := parent.CommandPath() link := pname + ".md" link = strings.Replace(link, " ", "_", -1) - fmt.Fprintf(out, "* [%s](%s)\t - %s\n", pname, link, parent.Short) + fmt.Fprintf(out, "* [%s](%s)\t - %s\n", pname, linkHandler(link), parent.Short) } children := cmd.Commands() @@ -91,7 +95,7 @@ func GenMarkdown(cmd *Command, out *bytes.Buffer) { cname := name + " " + child.Name() link := cname + ".md" link = strings.Replace(link, " ", "_", -1) - fmt.Fprintf(out, "* [%s](%s)\t - %s\n", cname, link, child.Short) + fmt.Fprintf(out, "* [%s](%s)\t - %s\n", cname, linkHandler(link), child.Short) } fmt.Fprintf(out, "\n") } @@ -100,13 +104,18 @@ func GenMarkdown(cmd *Command, out *bytes.Buffer) { } func GenMarkdownTree(cmd *Command, dir string) { - for _, c := range cmd.Commands() { - GenMarkdownTree(c, dir) - } + identity := func(s string) string { return s } + emptyStr := func(s string) string { return "" } + GenMarkdownTreeCustom(cmd, dir, emptyStr, identity) +} +func GenMarkdownTreeCustom(cmd *Command, dir string, filePrepender func(string) string, linkHandler func(string) string) { + for _, c := range cmd.Commands() { + GenMarkdownTreeCustom(c, dir, filePrepender, linkHandler) + } out := new(bytes.Buffer) - GenMarkdown(cmd, out) + GenMarkdownCustom(cmd, out, linkHandler) filename := cmd.CommandPath() filename = dir + strings.Replace(filename, " ", "_", -1) + ".md" @@ -116,6 +125,11 @@ func GenMarkdownTree(cmd *Command, dir string) { os.Exit(1) } defer outFile.Close() + _, err = outFile.WriteString(filePrepender(filename)) + if err != nil { + fmt.Println(err) + os.Exit(1) + } _, err = outFile.Write(out.Bytes()) if err != nil { fmt.Println(err) diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/md_docs.md b/Godeps/_workspace/src/github.com/spf13/cobra/md_docs.md index 43b6c994713..3a0d55ab902 100644 --- a/Godeps/_workspace/src/github.com/spf13/cobra/md_docs.md +++ b/Godeps/_workspace/src/github.com/spf13/cobra/md_docs.md @@ -25,7 +25,7 @@ This will generate a whole series of files, one for each command in the tree, in ## Generate markdown docs for a single command -You may wish to have more control over the output, or only generate for a single command, instead of the entire command tree. If this is the case you may prefer to `GenMarkdown()` instead of `GenMarkdownTree` +You may wish to have more control over the output, or only generate for a single command, instead of the entire command tree. If this is the case you may prefer to `GenMarkdown` instead of `GenMarkdownTree` ```go out := new(bytes.Buffer) @@ -33,3 +33,49 @@ You may wish to have more control over the output, or only generate for a single ``` This will write the markdown doc for ONLY "cmd" into the out, buffer. + +## Customize the output + +Both `GenMarkdown` and `GenMarkdownTree` have alternate versions with callbacks to get some control of the output: + +```go +func GenMarkdownTreeCustom(cmd *Command, dir string, filePrepender func(string) string, linkHandler func(string) string) { + //... +} +``` + +```go +func GenMarkdownCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string) string) { + //... +} +``` + +The `filePrepender` will prepend the return value given the full filepath to the rendered Markdown file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/): + +```go +const fmTemplate = `--- +date: %s +title: "%s" +slug: %s +url: %s +--- +` + +filePrepender := func(filename string) string { + now := time.Now().Format(time.RFC3339) + name := filepath.Base(filename) + base := strings.TrimSuffix(name, path.Ext(name)) + url := "/commands/" + strings.ToLower(base) + "/" + return fmt.Sprintf(fmTemplate, now, strings.Replace(base, "_", " ", -1), base, url) +} +``` + +The `linkHandler` can be used to customize the rendered internal links to the commands, given a filename: + +```go +linkHandler := func(name string) string { + base := strings.TrimSuffix(name, path.Ext(name)) + return "/commands/" + strings.ToLower(base) + "/" +} +``` + diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/.travis.yml b/Godeps/_workspace/src/github.com/spf13/pflag/.travis.yml new file mode 100644 index 00000000000..c4d88e37495 --- /dev/null +++ b/Godeps/_workspace/src/github.com/spf13/pflag/.travis.yml @@ -0,0 +1,8 @@ +sudo: false + +language: go + +go: + - 1.3 + - 1.4 + - tip diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/README.md b/Godeps/_workspace/src/github.com/spf13/pflag/README.md index a12d94df404..f7d63500f5b 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/README.md +++ b/Godeps/_workspace/src/github.com/spf13/pflag/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/spf13/pflag.svg?branch=master)](https://travis-ci.org/spf13/pflag) + ## Description pflag is a drop-in replacement for Go's flag package, implementing @@ -143,6 +145,40 @@ Boolean flags (in their long form) accept 1, 0, t, f, true, false, TRUE, FALSE, True, False. Duration flags accept any input valid for time.ParseDuration. +## Mutating or "Normalizing" Flag names + +It is possible to set a custom flag name 'normalization function.' It allows flag names to be mutated both when created in the code and when used on the command line to some 'normalized' form. The 'normalized' form is used for comparison. Two examples of using the custom normalization func follow. + +**Example #1**: You want -, _, and . in flags to compare the same. aka --my-flag == --my_flag == --my.flag + +```go +func wordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName { + from := []string{"-", "_"} + to := "." + for _, sep := range from { + name = strings.Replace(name, sep, to, -1) + } + return pflag.NormalizedName(name) +} + +myFlagSet.SetNormalizeFunc(wordSepNormalizeFunc) +``` + +**Example #2**: You want to alias two flags. aka --old-flag-name == --new-flag-name + +```go +func aliasNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName { + switch name { + case "old-flag-name": + name = "new-flag-name" + break + } + return pflag.NormalizedName(name) +} + +myFlagSet.SetNormalizeFunc(aliasNormalizeFunc) +``` + ## More info You can see the full reference documentation of the pflag package diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/bool_test.go b/Godeps/_workspace/src/github.com/spf13/pflag/bool_test.go index 20735907fa6..a2e1c5dcccb 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/bool_test.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/bool_test.go @@ -2,14 +2,13 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package pflag_test +package pflag import ( + "bytes" "fmt" "strconv" "testing" - - . "github.com/spf13/pflag" ) // This value can be a boolean ("true", "false") or "maybe" @@ -156,8 +155,9 @@ func TestImplicitFalse(t *testing.T) { func TestInvalidValue(t *testing.T) { var tristate triStateValue f := setUpFlagSet(&tristate) - args := []string{"--tristate=invalid"} - _, err := parseReturnStderr(t, f, args) + var buf bytes.Buffer + f.SetOutput(&buf) + err := f.Parse([]string{"--tristate=invalid"}) if err == nil { t.Fatal("expected an error but did not get any, tristate has value", tristate) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/flag.go b/Godeps/_workspace/src/github.com/spf13/pflag/flag.go index 55594df40d3..9f16733b705 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/flag.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/flag.go @@ -184,7 +184,9 @@ func (f *FlagSet) SetNormalizeFunc(n func(f *FlagSet, name string) NormalizedNam f.normalizeNameFunc = n for k, v := range f.formal { delete(f.formal, k) - f.formal[f.normalizeFlagName(string(k))] = v + nname := f.normalizeFlagName(string(k)) + f.formal[nname] = v + v.Name = string(nname) } } @@ -421,7 +423,10 @@ func (f *FlagSet) VarP(value Value, name, shorthand, usage string) { } func (f *FlagSet) AddFlag(flag *Flag) { - _, alreadythere := f.formal[f.normalizeFlagName(flag.Name)] + // Call normalizeFlagName function only once + var normalizedFlagName NormalizedName = f.normalizeFlagName(flag.Name) + + _, alreadythere := f.formal[normalizedFlagName] if alreadythere { msg := fmt.Sprintf("%s flag redefined: %s", f.name, flag.Name) fmt.Fprintln(f.out(), msg) @@ -430,7 +435,9 @@ func (f *FlagSet) AddFlag(flag *Flag) { if f.formal == nil { f.formal = make(map[NormalizedName]*Flag) } - f.formal[f.normalizeFlagName(flag.Name)] = flag + + flag.Name = string(normalizedFlagName) + f.formal[normalizedFlagName] = flag if len(flag.Shorthand) == 0 { return @@ -505,10 +512,6 @@ func (f *FlagSet) setFlag(flag *Flag, value string, origArg string) error { func (f *FlagSet) parseLongArg(s string, args []string) (a []string, err error) { a = args - if len(s) == 2 { // "--" terminates the flags - f.args = append(f.args, args...) - return - } name := s[2:] if len(name) == 0 || name[0] == '-' || name[0] == '=' { err = f.failf("bad flag syntax: %s", s) @@ -516,75 +519,74 @@ func (f *FlagSet) parseLongArg(s string, args []string) (a []string, err error) } split := strings.SplitN(name, "=", 2) name = split[0] - m := f.formal - flag, alreadythere := m[f.normalizeFlagName(name)] // BUG + flag, alreadythere := f.formal[f.normalizeFlagName(name)] if !alreadythere { if name == "help" { // special case for nice help message. f.usage() - return args, ErrHelp + return a, ErrHelp } err = f.failf("unknown flag: --%s", name) return } + var value string if len(split) == 1 { if bv, ok := flag.Value.(boolFlag); !ok || !bv.IsBoolFlag() { err = f.failf("flag needs an argument: %s", s) return } - f.setFlag(flag, "true", s) + value = "true" } else { - if e := f.setFlag(flag, split[1], s); e != nil { - err = e + value = split[1] + } + err = f.setFlag(flag, value, s) + return +} + +func (f *FlagSet) parseSingleShortArg(shorthands string, args []string) (outShorts string, outArgs []string, err error) { + outArgs = args + outShorts = shorthands[1:] + c := shorthands[0] + + flag, alreadythere := f.shorthands[c] + if !alreadythere { + if c == 'h' { // special case for nice help message. + f.usage() + err = ErrHelp return } + //TODO continue on error + err = f.failf("unknown shorthand flag: %q in -%s", c, shorthands) + return } - return args, nil + var value string + if len(shorthands) > 2 && shorthands[1] == '=' { + value = shorthands[2:] + outShorts = "" + } else if bv, ok := flag.Value.(boolFlag); ok && bv.IsBoolFlag() { + value = "true" + } else if len(shorthands) > 1 { + value = shorthands[1:] + outShorts = "" + } else if len(args) > 0 { + value = args[0] + outArgs = args[1:] + } else { + err = f.failf("flag needs an argument: %q in -%s", c, shorthands) + return + } + err = f.setFlag(flag, value, shorthands) + return } func (f *FlagSet) parseShortArg(s string, args []string) (a []string, err error) { a = args shorthands := s[1:] - for i := 0; i < len(shorthands); i++ { - c := shorthands[i] - flag, alreadythere := f.shorthands[c] - if !alreadythere { - if c == 'h' { // special case for nice help message. - f.usage() - err = ErrHelp - return - } - //TODO continue on error - err = f.failf("unknown shorthand flag: %q in -%s", c, shorthands) - if len(args) == 0 { - return - } + for len(shorthands) > 0 { + shorthands, a, err = f.parseSingleShortArg(shorthands, args) + if err != nil { return } - if alreadythere { - if bv, ok := flag.Value.(boolFlag); ok && bv.IsBoolFlag() { - f.setFlag(flag, "true", s) - continue - } - if i < len(shorthands)-1 { - v := strings.TrimPrefix(shorthands[i+1:], "=") - if e := f.setFlag(flag, v, s); e != nil { - err = e - return - } - break - } - if len(args) == 0 { - err = f.failf("flag needs an argument: %q in -%s", c, shorthands) - return - } - if e := f.setFlag(flag, args[0], s); e != nil { - err = e - return - } - } - a = args[1:] - break // should be unnecessary } return @@ -605,12 +607,11 @@ func (f *FlagSet) parseArgs(args []string) (err error) { } if s[1] == '-' { - args, err = f.parseLongArg(s, args) - - if len(s) == 2 { - // stop parsing after -- + if len(s) == 2 { // "--" terminates the flags + f.args = append(f.args, args...) break } + args, err = f.parseLongArg(s, args) } else { args, err = f.parseShortArg(s, args) } diff --git a/Godeps/_workspace/src/github.com/spf13/pflag/flag_test.go b/Godeps/_workspace/src/github.com/spf13/pflag/flag_test.go index f552a2f5da3..765dfe0af70 100644 --- a/Godeps/_workspace/src/github.com/spf13/pflag/flag_test.go +++ b/Godeps/_workspace/src/github.com/spf13/pflag/flag_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package pflag_test +package pflag import ( "bytes" @@ -14,19 +14,18 @@ import ( "strings" "testing" "time" - - . "github.com/spf13/pflag" ) var ( - test_bool = Bool("test_bool", false, "bool value") - test_int = Int("test_int", 0, "int value") - test_int64 = Int64("test_int64", 0, "int64 value") - test_uint = Uint("test_uint", 0, "uint value") - test_uint64 = Uint64("test_uint64", 0, "uint64 value") - test_string = String("test_string", "0", "string value") - test_float64 = Float64("test_float64", 0, "float64 value") - test_duration = Duration("test_duration", 0, "time.Duration value") + test_bool = Bool("test_bool", false, "bool value") + test_int = Int("test_int", 0, "int value") + test_int64 = Int64("test_int64", 0, "int64 value") + test_uint = Uint("test_uint", 0, "uint value") + test_uint64 = Uint64("test_uint64", 0, "uint64 value") + test_string = String("test_string", "0", "string value") + test_float64 = Float64("test_float64", 0, "float64 value") + test_duration = Duration("test_duration", 0, "time.Duration value") + normalizeFlagNameInvocations = 0 ) func boolString(s string) string { @@ -186,6 +185,7 @@ func TestShorthand(t *testing.T) { boolaFlag := f.BoolP("boola", "a", false, "bool value") boolbFlag := f.BoolP("boolb", "b", false, "bool2 value") boolcFlag := f.BoolP("boolc", "c", false, "bool3 value") + booldFlag := f.BoolP("boold", "d", false, "bool4 value") stringaFlag := f.StringP("stringa", "s", "0", "string value") stringzFlag := f.StringP("stringz", "z", "0", "string value") extra := "interspersed-argument" @@ -196,6 +196,7 @@ func TestShorthand(t *testing.T) { "-cs", "hello", "-z=something", + "-d=true", "--", notaflag, } @@ -215,6 +216,9 @@ func TestShorthand(t *testing.T) { if *boolcFlag != true { t.Error("boolc flag should be true, is ", *boolcFlag) } + if *booldFlag != true { + t.Error("boold flag should be true, is ", *booldFlag) + } if *stringaFlag != "hello" { t.Error("stringa flag should be `hello`, is ", *stringaFlag) } @@ -251,6 +255,8 @@ func replaceSeparators(name string, from []string, to string) string { func wordSepNormalizeFunc(f *FlagSet, name string) NormalizedName { seps := []string{"-", "_"} name = replaceSeparators(name, seps, ".") + normalizeFlagNameInvocations++ + return NormalizedName(name) } @@ -343,6 +349,31 @@ func TestCustomNormalizedNames(t *testing.T) { } } +// Every flag we add, the name (displayed also in usage) should normalized +func TestNormalizationFuncShouldChangeFlagName(t *testing.T) { + // Test normalization after addition + f := NewFlagSet("normalized", ContinueOnError) + + f.Bool("valid_flag", false, "bool value") + if f.Lookup("valid_flag").Name != "valid_flag" { + t.Error("The new flag should have the name 'valid_flag' instead of ", f.Lookup("valid_flag").Name) + } + + f.SetNormalizeFunc(wordSepNormalizeFunc) + if f.Lookup("valid_flag").Name != "valid.flag" { + t.Error("The new flag should have the name 'valid.flag' instead of ", f.Lookup("valid_flag").Name) + } + + // Test normalization before addition + f = NewFlagSet("normalized", ContinueOnError) + f.SetNormalizeFunc(wordSepNormalizeFunc) + + f.Bool("valid_flag", false, "bool value") + if f.Lookup("valid_flag").Name != "valid.flag" { + t.Error("The new flag should have the name 'valid.flag' instead of ", f.Lookup("valid_flag").Name) + } +} + // Declare a user-defined flag type. type flagVar []string @@ -571,3 +602,16 @@ func TestDeprecatedFlagUsageNormalized(t *testing.T) { t.Errorf("usageMsg not printed when using a deprecated flag!") } } + +// Name normalization function should be called only once on flag addition +func TestMultipleNormalizeFlagNameInvocations(t *testing.T) { + normalizeFlagNameInvocations = 0 + + f := NewFlagSet("normalized", ContinueOnError) + f.SetNormalizeFunc(wordSepNormalizeFunc) + f.Bool("with_under_flag", false, "bool value") + + if normalizeFlagNameInvocations != 1 { + t.Fatal("Expected normalizeFlagNameInvocations to be 1; got ", normalizeFlagNameInvocations) + } +} From 5eae2378d6ef71d7125c59a5fdb452a3591753ff Mon Sep 17 00:00:00 2001 From: Anastasis Andronidis Date: Sat, 16 May 2015 18:44:42 +0200 Subject: [PATCH 2/2] Warn for every _ flag user or cmd defined also renames all global _ flags to - --- contrib/completions/bash/kubectl | 6 ++--- docs/kubectl.md | 6 ++--- docs/kubectl_api-versions.md | 8 +++--- docs/kubectl_cluster-info.md | 8 +++--- docs/kubectl_config.md | 8 +++--- docs/kubectl_config_set-cluster.md | 8 +++--- docs/kubectl_config_set-context.md | 8 +++--- docs/kubectl_config_set-credentials.md | 8 +++--- docs/kubectl_config_set.md | 8 +++--- docs/kubectl_config_unset.md | 8 +++--- docs/kubectl_config_use-context.md | 8 +++--- docs/kubectl_config_view.md | 8 +++--- docs/kubectl_create.md | 8 +++--- docs/kubectl_delete.md | 8 +++--- docs/kubectl_describe.md | 8 +++--- docs/kubectl_exec.md | 8 +++--- docs/kubectl_expose.md | 8 +++--- docs/kubectl_get.md | 6 ++--- docs/kubectl_label.md | 8 +++--- docs/kubectl_logs.md | 6 ++--- docs/kubectl_namespace.md | 8 +++--- docs/kubectl_port-forward.md | 8 +++--- docs/kubectl_proxy.md | 8 +++--- docs/kubectl_resize.md | 8 +++--- docs/kubectl_rolling-update.md | 8 +++--- docs/kubectl_run-container.md | 8 +++--- docs/kubectl_stop.md | 8 +++--- docs/kubectl_update.md | 8 +++--- docs/kubectl_version.md | 8 +++--- docs/man/man1/kubectl-api-versions.1 | 6 ++--- docs/man/man1/kubectl-cluster-info.1 | 6 ++--- docs/man/man1/kubectl-config-set-cluster.1 | 6 ++--- docs/man/man1/kubectl-config-set-context.1 | 6 ++--- .../man/man1/kubectl-config-set-credentials.1 | 6 ++--- docs/man/man1/kubectl-config-set.1 | 6 ++--- docs/man/man1/kubectl-config-unset.1 | 6 ++--- docs/man/man1/kubectl-config-use-context.1 | 6 ++--- docs/man/man1/kubectl-config-view.1 | 6 ++--- docs/man/man1/kubectl-config.1 | 6 ++--- docs/man/man1/kubectl-create.1 | 6 ++--- docs/man/man1/kubectl-delete.1 | 6 ++--- docs/man/man1/kubectl-describe.1 | 6 ++--- docs/man/man1/kubectl-exec.1 | 6 ++--- docs/man/man1/kubectl-expose.1 | 6 ++--- docs/man/man1/kubectl-get.1 | 6 ++--- docs/man/man1/kubectl-label.1 | 6 ++--- docs/man/man1/kubectl-logs.1 | 6 ++--- docs/man/man1/kubectl-namespace.1 | 6 ++--- docs/man/man1/kubectl-port-forward.1 | 6 ++--- docs/man/man1/kubectl-proxy.1 | 6 ++--- docs/man/man1/kubectl-resize.1 | 6 ++--- docs/man/man1/kubectl-rolling-update.1 | 6 ++--- docs/man/man1/kubectl-run-container.1 | 6 ++--- docs/man/man1/kubectl-stop.1 | 6 ++--- docs/man/man1/kubectl-update.1 | 6 ++--- docs/man/man1/kubectl-version.1 | 6 ++--- docs/man/man1/kubectl.1 | 6 ++--- pkg/kubectl/cmd/cmd.go | 4 +++ pkg/kubectl/cmd/cmd_test.go | 27 +++++++++++++++++++ pkg/kubectl/cmd/util/factory.go | 13 ++++----- pkg/kubectl/cmd/util/factory_test.go | 13 +++++++++ pkg/util/flags.go | 20 ++++++++++---- pkg/util/pflag_import.go | 18 +++++++------ 63 files changed, 272 insertions(+), 215 deletions(-) diff --git a/contrib/completions/bash/kubectl b/contrib/completions/bash/kubectl index d5a05a1b838..ff6fa418155 100644 --- a/contrib/completions/bash/kubectl +++ b/contrib/completions/bash/kubectl @@ -926,9 +926,9 @@ _kubectl() flags+=("-h") flags+=("--insecure-skip-tls-verify") flags+=("--kubeconfig=") - flags+=("--log_backtrace_at=") - flags+=("--log_dir=") - flags+=("--log_flush_frequency=") + flags+=("--log-backtrace-at=") + flags+=("--log-dir=") + flags+=("--log-flush-frequency=") flags+=("--logtostderr") flags+=("--match-server-version") flags+=("--namespace=") diff --git a/docs/kubectl.md b/docs/kubectl.md index 664e8adc06b..fdfc56bd77d 100644 --- a/docs/kubectl.md +++ b/docs/kubectl.md @@ -26,9 +26,9 @@ kubectl -h, --help=false: help for kubectl --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. diff --git a/docs/kubectl_api-versions.md b/docs/kubectl_api-versions.md index db233306f7c..84cc4657bd2 100644 --- a/docs/kubectl_api-versions.md +++ b/docs/kubectl_api-versions.md @@ -29,9 +29,9 @@ kubectl api-versions --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -49,6 +49,6 @@ kubectl api-versions ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.555704962 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.231770799 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_api-versions.md?pixel)]() diff --git a/docs/kubectl_cluster-info.md b/docs/kubectl_cluster-info.md index f25121ec121..833c465b595 100644 --- a/docs/kubectl_cluster-info.md +++ b/docs/kubectl_cluster-info.md @@ -29,9 +29,9 @@ kubectl cluster-info --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -49,6 +49,6 @@ kubectl cluster-info ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.555514789 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.230831561 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_cluster-info.md?pixel)]() diff --git a/docs/kubectl_config.md b/docs/kubectl_config.md index 56963f8adf8..28bc1db5707 100644 --- a/docs/kubectl_config.md +++ b/docs/kubectl_config.md @@ -35,9 +35,9 @@ kubectl config SUBCOMMAND --cluster="": The name of the kubeconfig cluster to use --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -62,6 +62,6 @@ kubectl config SUBCOMMAND * [kubectl config use-context](kubectl_config_use-context.md) - Sets the current-context in a kubeconfig file * [kubectl config view](kubectl_config_view.md) - displays Merged kubeconfig settings or a specified kubeconfig file. -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.555327159 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.229842268 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_config.md?pixel)]() diff --git a/docs/kubectl_config_set-cluster.md b/docs/kubectl_config_set-cluster.md index 081cc21922a..84310b3b7a8 100644 --- a/docs/kubectl_config_set-cluster.md +++ b/docs/kubectl_config_set-cluster.md @@ -45,9 +45,9 @@ $ kubectl config set-cluster e2e --insecure-skip-tls-verify=true --cluster="": The name of the kubeconfig cluster to use --context="": The name of the kubeconfig context to use --kubeconfig="": use a particular kubeconfig file - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -64,6 +64,6 @@ $ kubectl config set-cluster e2e --insecure-skip-tls-verify=true ### SEE ALSO * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.553839852 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.222182293 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_config_set-cluster.md?pixel)]() diff --git a/docs/kubectl_config_set-context.md b/docs/kubectl_config_set-context.md index 0c6a2c7d124..a3bdc0596c8 100644 --- a/docs/kubectl_config_set-context.md +++ b/docs/kubectl_config_set-context.md @@ -39,9 +39,9 @@ $ kubectl config set-context gce --user=cluster-admin --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --password="": Password for basic authentication to the API server. @@ -57,6 +57,6 @@ $ kubectl config set-context gce --user=cluster-admin ### SEE ALSO * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.554224777 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.225463229 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_config_set-context.md?pixel)]() diff --git a/docs/kubectl_config_set-credentials.md b/docs/kubectl_config_set-credentials.md index f85fcdc0375..9f7f9639aee 100644 --- a/docs/kubectl_config_set-credentials.md +++ b/docs/kubectl_config_set-credentials.md @@ -60,9 +60,9 @@ $ kubectl set-credentials cluster-admin --client-certificate=~/.kube/admin.crt - --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -77,6 +77,6 @@ $ kubectl set-credentials cluster-admin --client-certificate=~/.kube/admin.crt - ### SEE ALSO * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.55402965 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.22419139 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_config_set-credentials.md?pixel)]() diff --git a/docs/kubectl_config_set.md b/docs/kubectl_config_set.md index 3d71b197004..a4bfb564bb6 100644 --- a/docs/kubectl_config_set.md +++ b/docs/kubectl_config_set.md @@ -31,9 +31,9 @@ kubectl config set PROPERTY_NAME PROPERTY_VALUE --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -51,6 +51,6 @@ kubectl config set PROPERTY_NAME PROPERTY_VALUE ### SEE ALSO * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.554534222 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.226564217 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_config_set.md?pixel)]() diff --git a/docs/kubectl_config_unset.md b/docs/kubectl_config_unset.md index edef529c373..1a1c567cc46 100644 --- a/docs/kubectl_config_unset.md +++ b/docs/kubectl_config_unset.md @@ -30,9 +30,9 @@ kubectl config unset PROPERTY_NAME --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -50,6 +50,6 @@ kubectl config unset PROPERTY_NAME ### SEE ALSO * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.554933161 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.228039789 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_config_unset.md?pixel)]() diff --git a/docs/kubectl_config_use-context.md b/docs/kubectl_config_use-context.md index 7a370fdbedd..bb978a9ce9e 100644 --- a/docs/kubectl_config_use-context.md +++ b/docs/kubectl_config_use-context.md @@ -29,9 +29,9 @@ kubectl config use-context CONTEXT_NAME --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -49,6 +49,6 @@ kubectl config use-context CONTEXT_NAME ### SEE ALSO * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.555123528 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.228948447 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_config_use-context.md?pixel)]() diff --git a/docs/kubectl_config_view.md b/docs/kubectl_config_view.md index 76635a2c9bd..3b3f92d085c 100644 --- a/docs/kubectl_config_view.md +++ b/docs/kubectl_config_view.md @@ -52,9 +52,9 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2 --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": use a particular kubeconfig file - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -72,6 +72,6 @@ $ kubectl config view -o template --template='{{range .users}}{{ if eq .name "e2 ### SEE ALSO * [kubectl config](kubectl_config.md) - config modifies kubeconfig files -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.553648867 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.216559289 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_config_view.md?pixel)]() diff --git a/docs/kubectl_create.md b/docs/kubectl_create.md index 6ceee542d5b..df449ef0706 100644 --- a/docs/kubectl_create.md +++ b/docs/kubectl_create.md @@ -42,9 +42,9 @@ $ cat pod.json | kubectl create -f - --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -62,6 +62,6 @@ $ cat pod.json | kubectl create -f - ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.550199549 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.178299587 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_create.md?pixel)]() diff --git a/docs/kubectl_delete.md b/docs/kubectl_delete.md index 1e02a90a35b..df5e54cbc68 100644 --- a/docs/kubectl_delete.md +++ b/docs/kubectl_delete.md @@ -62,9 +62,9 @@ $ kubectl delete pods --all --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -82,6 +82,6 @@ $ kubectl delete pods --all ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.550666007 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.18056941 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_delete.md?pixel)]() diff --git a/docs/kubectl_describe.md b/docs/kubectl_describe.md index a1bfc2a467a..a4936229b97 100644 --- a/docs/kubectl_describe.md +++ b/docs/kubectl_describe.md @@ -42,9 +42,9 @@ $ kubectl describe pods/nginx --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -62,6 +62,6 @@ $ kubectl describe pods/nginx ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.549970974 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.177122438 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_describe.md?pixel)]() diff --git a/docs/kubectl_exec.md b/docs/kubectl_exec.md index 827877f6097..6bae1d1b1c6 100644 --- a/docs/kubectl_exec.md +++ b/docs/kubectl_exec.md @@ -43,9 +43,9 @@ $ kubectl exec -p 123456-7890 -c ruby-container -i -t -- bash -il --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -63,6 +63,6 @@ $ kubectl exec -p 123456-7890 -c ruby-container -i -t -- bash -il ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.551970235 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.186469192 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_exec.md?pixel)]() diff --git a/docs/kubectl_expose.md b/docs/kubectl_expose.md index 95d8eda686e..2bf78a3d245 100644 --- a/docs/kubectl_expose.md +++ b/docs/kubectl_expose.md @@ -63,9 +63,9 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -83,6 +83,6 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-19 14:12:47.467953048 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.197790185 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_expose.md?pixel)]() diff --git a/docs/kubectl_get.md b/docs/kubectl_get.md index 9e94863c178..9522f4dd4c0 100644 --- a/docs/kubectl_get.md +++ b/docs/kubectl_get.md @@ -65,9 +65,9 @@ $ kubectl get rc/web service/frontend pods/web-pod-13je7 --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. diff --git a/docs/kubectl_label.md b/docs/kubectl_label.md index 38b62e34542..9897bdaa331 100644 --- a/docs/kubectl_label.md +++ b/docs/kubectl_label.md @@ -60,9 +60,9 @@ $ kubectl label pods foo bar- --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -80,6 +80,6 @@ $ kubectl label pods foo bar- ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.553433439 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.210679161 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_label.md?pixel)]() diff --git a/docs/kubectl_logs.md b/docs/kubectl_logs.md index 73964e20c64..669e08c3a0b 100644 --- a/docs/kubectl_logs.md +++ b/docs/kubectl_logs.md @@ -45,9 +45,9 @@ $ kubectl logs -f 123456-7890 ruby-container --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. diff --git a/docs/kubectl_namespace.md b/docs/kubectl_namespace.md index 8a5d903c12e..a87e6f5e905 100644 --- a/docs/kubectl_namespace.md +++ b/docs/kubectl_namespace.md @@ -32,9 +32,9 @@ kubectl namespace [namespace] --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -52,6 +52,6 @@ kubectl namespace [namespace] ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.550855698 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.181662849 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_namespace.md?pixel)]() diff --git a/docs/kubectl_port-forward.md b/docs/kubectl_port-forward.md index cc276949414..fc127cd59d0 100644 --- a/docs/kubectl_port-forward.md +++ b/docs/kubectl_port-forward.md @@ -47,9 +47,9 @@ $ kubectl port-forward -p mypod 0:5000 --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -67,6 +67,6 @@ $ kubectl port-forward -p mypod 0:5000 ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.552168206 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.187520496 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_port-forward.md?pixel)]() diff --git a/docs/kubectl_proxy.md b/docs/kubectl_proxy.md index 91e5d0bff28..abf695beaaa 100644 --- a/docs/kubectl_proxy.md +++ b/docs/kubectl_proxy.md @@ -44,9 +44,9 @@ $ kubectl proxy --api-prefix=k8s-api --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -64,6 +64,6 @@ $ kubectl proxy --api-prefix=k8s-api ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.552348175 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.188518514 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_proxy.md?pixel)]() diff --git a/docs/kubectl_resize.md b/docs/kubectl_resize.md index 7c4117dd18d..c2e61e7531a 100644 --- a/docs/kubectl_resize.md +++ b/docs/kubectl_resize.md @@ -47,9 +47,9 @@ $ kubectl resize --current-replicas=2 --replicas=3 replicationcontrollers foo --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -67,6 +67,6 @@ $ kubectl resize --current-replicas=2 --replicas=3 replicationcontrollers foo ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.551722394 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.185268791 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_resize.md?pixel)]() diff --git a/docs/kubectl_rolling-update.md b/docs/kubectl_rolling-update.md index 627583d63e7..31a3650a907 100644 --- a/docs/kubectl_rolling-update.md +++ b/docs/kubectl_rolling-update.md @@ -63,9 +63,9 @@ $ kubectl rolling-update frontend --image=image:v2 --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -83,6 +83,6 @@ $ kubectl rolling-update frontend --image=image:v2 ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.551455635 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.184123104 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_rolling-update.md?pixel)]() diff --git a/docs/kubectl_run-container.md b/docs/kubectl_run-container.md index f557f8c21fb..5c03489da9f 100644 --- a/docs/kubectl_run-container.md +++ b/docs/kubectl_run-container.md @@ -58,9 +58,9 @@ $ kubectl run-container nginx --image=nginx --overrides='{ "apiVersion": "v1beta --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -78,6 +78,6 @@ $ kubectl run-container nginx --image=nginx --overrides='{ "apiVersion": "v1beta ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-18 20:22:53.529935618 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.189857293 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_run-container.md?pixel)]() diff --git a/docs/kubectl_stop.md b/docs/kubectl_stop.md index 23546e95239..8269bc82a12 100644 --- a/docs/kubectl_stop.md +++ b/docs/kubectl_stop.md @@ -52,9 +52,9 @@ $ kubectl stop -f path/to/resources --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -72,6 +72,6 @@ $ kubectl stop -f path/to/resources ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.552969845 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.190996891 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_stop.md?pixel)]() diff --git a/docs/kubectl_update.md b/docs/kubectl_update.md index 9b5cbaa48a5..6029b2aee2e 100644 --- a/docs/kubectl_update.md +++ b/docs/kubectl_update.md @@ -46,9 +46,9 @@ $ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState": --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -66,6 +66,6 @@ $ kubectl update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState": ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.550430092 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.179469636 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_update.md?pixel)]() diff --git a/docs/kubectl_version.md b/docs/kubectl_version.md index 79365f56356..9c2effe792c 100644 --- a/docs/kubectl_version.md +++ b/docs/kubectl_version.md @@ -30,9 +30,9 @@ kubectl version --context="": The name of the kubeconfig context to use --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. --kubeconfig="": Path to the kubeconfig file to use for CLI requests. - --log_backtrace_at=:0: when logging hits line file:N, emit a stack trace - --log_dir=: If non-empty, write log files in this directory - --log_flush_frequency=5s: Maximum number of seconds between log flushes + --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace + --log-dir=: If non-empty, write log files in this directory + --log-flush-frequency=5s: Maximum number of seconds between log flushes --logtostderr=true: log to standard error instead of files --match-server-version=false: Require server version to match client version --namespace="": If present, the namespace scope for this CLI request. @@ -50,6 +50,6 @@ kubectl version ### SEE ALSO * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra at 2015-05-15 00:05:04.555991019 +0000 UTC +###### Auto generated by spf13/cobra at 2015-05-21 10:33:11.232741611 +0000 UTC [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/kubectl_version.md?pixel)]() diff --git a/docs/man/man1/kubectl-api-versions.1 b/docs/man/man1/kubectl-api-versions.1 index 0c66fdba938..c4212fd1d46 100644 --- a/docs/man/man1/kubectl-api-versions.1 +++ b/docs/man/man1/kubectl-api-versions.1 @@ -60,15 +60,15 @@ Print available API versions. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-cluster-info.1 b/docs/man/man1/kubectl-cluster-info.1 index df5e04fd01c..3f64ae37ab1 100644 --- a/docs/man/man1/kubectl-cluster-info.1 +++ b/docs/man/man1/kubectl-cluster-info.1 @@ -60,15 +60,15 @@ Display addresses of the master and services with label kubernetes.io/cluster\-s Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-config-set-cluster.1 b/docs/man/man1/kubectl-config-set-cluster.1 index a99b2cee93f..374e37bbad7 100644 --- a/docs/man/man1/kubectl-config-set-cluster.1 +++ b/docs/man/man1/kubectl-config-set-cluster.1 @@ -69,15 +69,15 @@ Specifying a name that already exists will merge new fields on top of existing v use a particular kubeconfig file .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-config-set-context.1 b/docs/man/man1/kubectl-config-set-context.1 index 987073b8f77..4e7928418ed 100644 --- a/docs/man/man1/kubectl-config-set-context.1 +++ b/docs/man/man1/kubectl-config-set-context.1 @@ -69,15 +69,15 @@ Specifying a name that already exists will merge new fields on top of existing v use a particular kubeconfig file .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-config-set-credentials.1 b/docs/man/man1/kubectl-config-set-credentials.1 index 63e4ad24026..1638f4bed7c 100644 --- a/docs/man/man1/kubectl-config-set-credentials.1 +++ b/docs/man/man1/kubectl-config-set-credentials.1 @@ -92,15 +92,15 @@ Bearer token and basic auth are mutually exclusive. use a particular kubeconfig file .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-config-set.1 b/docs/man/man1/kubectl-config-set.1 index 25a449dc44f..f83ea2edaa2 100644 --- a/docs/man/man1/kubectl-config-set.1 +++ b/docs/man/man1/kubectl-config-set.1 @@ -62,15 +62,15 @@ PROPERTY\_VALUE is the new value you wish to set. use a particular kubeconfig file .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-config-unset.1 b/docs/man/man1/kubectl-config-unset.1 index ea10fae82a7..cea12d2e81a 100644 --- a/docs/man/man1/kubectl-config-unset.1 +++ b/docs/man/man1/kubectl-config-unset.1 @@ -61,15 +61,15 @@ PROPERTY\_NAME is a dot delimited name where each token represents either a attr use a particular kubeconfig file .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-config-use-context.1 b/docs/man/man1/kubectl-config-use-context.1 index cabbdaf8aad..4ae194bd2a6 100644 --- a/docs/man/man1/kubectl-config-use-context.1 +++ b/docs/man/man1/kubectl-config-use-context.1 @@ -60,15 +60,15 @@ Sets the current\-context in a kubeconfig file use a particular kubeconfig file .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-config-view.1 b/docs/man/man1/kubectl-config-view.1 index 5036cabcc23..85ab4c3c7d7 100644 --- a/docs/man/man1/kubectl-config-view.1 +++ b/docs/man/man1/kubectl-config-view.1 @@ -96,15 +96,15 @@ You can use \-\-output=template \-\-template=TEMPLATE to extract specific values use a particular kubeconfig file .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-config.1 b/docs/man/man1/kubectl-config.1 index fb6687cf2e1..66eb5e8a1a2 100644 --- a/docs/man/man1/kubectl-config.1 +++ b/docs/man/man1/kubectl-config.1 @@ -66,15 +66,15 @@ The loading order follows these rules: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-create.1 b/docs/man/man1/kubectl-create.1 index f77d10e17d4..b0c511d36d1 100644 --- a/docs/man/man1/kubectl-create.1 +++ b/docs/man/man1/kubectl-create.1 @@ -67,15 +67,15 @@ JSON and YAML formats are accepted. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-delete.1 b/docs/man/man1/kubectl-delete.1 index c28b1d15c32..bf955c71261 100644 --- a/docs/man/man1/kubectl-delete.1 +++ b/docs/man/man1/kubectl-delete.1 @@ -92,15 +92,15 @@ will be lost along with the rest of the resource. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-describe.1 b/docs/man/man1/kubectl-describe.1 index a165eca4d1c..f8856055a3f 100644 --- a/docs/man/man1/kubectl-describe.1 +++ b/docs/man/man1/kubectl-describe.1 @@ -64,15 +64,15 @@ given resource. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-exec.1 b/docs/man/man1/kubectl-exec.1 index c22746ab7e3..927ddfa52f7 100644 --- a/docs/man/man1/kubectl-exec.1 +++ b/docs/man/man1/kubectl-exec.1 @@ -76,15 +76,15 @@ Execute a command in a container. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-expose.1 b/docs/man/man1/kubectl-expose.1 index 15fc38cd831..27080b546df 100644 --- a/docs/man/man1/kubectl-expose.1 +++ b/docs/man/man1/kubectl-expose.1 @@ -134,15 +134,15 @@ re\-use the labels from the resource it exposes. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-get.1 b/docs/man/man1/kubectl-get.1 index 3644ab9a061..8414924bad5 100644 --- a/docs/man/man1/kubectl-get.1 +++ b/docs/man/man1/kubectl-get.1 @@ -101,15 +101,15 @@ of the \-\-template flag, you can filter the attributes of the fetched resource( Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-label.1 b/docs/man/man1/kubectl-label.1 index 00946e8319b..fe7037eee90 100644 --- a/docs/man/man1/kubectl-label.1 +++ b/docs/man/man1/kubectl-label.1 @@ -97,15 +97,15 @@ If \-\-resource\-version is specified, then updates will use this resource versi Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-logs.1 b/docs/man/man1/kubectl-logs.1 index 97d2da1ff40..148efd87678 100644 --- a/docs/man/man1/kubectl-logs.1 +++ b/docs/man/man1/kubectl-logs.1 @@ -72,15 +72,15 @@ Print the logs for a container in a pod. If the pod has only one container, the Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-namespace.1 b/docs/man/man1/kubectl-namespace.1 index 95094304347..94b04c52a9e 100644 --- a/docs/man/man1/kubectl-namespace.1 +++ b/docs/man/man1/kubectl-namespace.1 @@ -63,15 +63,15 @@ namespace has been superceded by the context.namespace field of .kubeconfig file Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-port-forward.1 b/docs/man/man1/kubectl-port-forward.1 index ee535ccd456..6d52308dd3e 100644 --- a/docs/man/man1/kubectl-port-forward.1 +++ b/docs/man/man1/kubectl-port-forward.1 @@ -64,15 +64,15 @@ Forward one or more local ports to a pod. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-proxy.1 b/docs/man/man1/kubectl-proxy.1 index ccb42822da0..8d977ee583e 100644 --- a/docs/man/man1/kubectl-proxy.1 +++ b/docs/man/man1/kubectl-proxy.1 @@ -76,15 +76,15 @@ Run a proxy to the Kubernetes API server. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-resize.1 b/docs/man/man1/kubectl-resize.1 index 86ecbb583b0..f14c8e7e6a3 100644 --- a/docs/man/man1/kubectl-resize.1 +++ b/docs/man/man1/kubectl-resize.1 @@ -78,15 +78,15 @@ resize is sent to the server. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-rolling-update.1 b/docs/man/man1/kubectl-rolling-update.1 index c5d28ffe22f..6483932c16e 100644 --- a/docs/man/man1/kubectl-rolling-update.1 +++ b/docs/man/man1/kubectl-rolling-update.1 @@ -114,15 +114,15 @@ existing controller and overwrite at least one (common) label in its replicaSele Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-run-container.1 b/docs/man/man1/kubectl-run-container.1 index 11633c2d32f..ab4f97ff47f 100644 --- a/docs/man/man1/kubectl-run-container.1 +++ b/docs/man/man1/kubectl-run-container.1 @@ -110,15 +110,15 @@ Creates a replication controller to manage the created container(s). Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-stop.1 b/docs/man/man1/kubectl-stop.1 index 54de59515af..a37ec617f94 100644 --- a/docs/man/man1/kubectl-stop.1 +++ b/docs/man/man1/kubectl-stop.1 @@ -80,15 +80,15 @@ If the resource is resizable it will be resized to 0 before deletion. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-update.1 b/docs/man/man1/kubectl-update.1 index 92e8dfac6a7..2740c025edd 100644 --- a/docs/man/man1/kubectl-update.1 +++ b/docs/man/man1/kubectl-update.1 @@ -71,15 +71,15 @@ JSON and YAML formats are accepted. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl-version.1 b/docs/man/man1/kubectl-version.1 index 984fb3810ef..d91fca6c10f 100644 --- a/docs/man/man1/kubectl-version.1 +++ b/docs/man/man1/kubectl-version.1 @@ -64,15 +64,15 @@ Print the client and server version information. Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/docs/man/man1/kubectl.1 b/docs/man/man1/kubectl.1 index c571f300926..60edc87cd53 100644 --- a/docs/man/man1/kubectl.1 +++ b/docs/man/man1/kubectl.1 @@ -62,15 +62,15 @@ Find more information at Path to the kubeconfig file to use for CLI requests. .PP -\fB\-\-log\_backtrace\_at\fP=:0 +\fB\-\-log\-backtrace\-at\fP=:0 when logging hits line file:N, emit a stack trace .PP -\fB\-\-log\_dir\fP="" +\fB\-\-log\-dir\fP="" If non\-empty, write log files in this directory .PP -\fB\-\-log\_flush\_frequency\fP=5s +\fB\-\-log\-flush\-frequency\fP=5s Maximum number of seconds between log flushes .PP diff --git a/pkg/kubectl/cmd/cmd.go b/pkg/kubectl/cmd/cmd.go index c251f60d65e..e6859c9d5d3 100644 --- a/pkg/kubectl/cmd/cmd.go +++ b/pkg/kubectl/cmd/cmd.go @@ -21,6 +21,7 @@ import ( cmdconfig "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/config" cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util" + "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/golang/glog" "github.com/spf13/cobra" @@ -107,6 +108,9 @@ Find more information at https://github.com/GoogleCloudPlatform/kubernetes.`, f.BindFlags(cmds.PersistentFlags()) + // From this point and forward we get warnings on flags that contain "_" separators + cmds.SetGlobalNormalizationFunc(util.WarnWordSepNormalizeFunc) + cmds.AddCommand(NewCmdGet(f, out)) cmds.AddCommand(NewCmdDescribe(f, out)) cmds.AddCommand(NewCmdCreate(f, out)) diff --git a/pkg/kubectl/cmd/cmd_test.go b/pkg/kubectl/cmd/cmd_test.go index 777a39d673e..c95f26c29e1 100644 --- a/pkg/kubectl/cmd/cmd_test.go +++ b/pkg/kubectl/cmd/cmd_test.go @@ -22,6 +22,7 @@ import ( "io" "io/ioutil" "os" + "reflect" "testing" "github.com/GoogleCloudPlatform/kubernetes/pkg/api" @@ -276,3 +277,29 @@ func ExamplePrintReplicationController() { // CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS // foo foo someimage foo=bar 1 } + +func TestNormalizationFuncGlobalExistance(t *testing.T) { + // This test can be safely deleted when we will not support multiple flag formats + root := NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, os.Stdout, os.Stderr) + + if root.Parent() != nil { + t.Fatal("We expect the root command to be returned") + } + if root.GlobalNormalizationFunc() == nil { + t.Fatal("We expect that root command has a global normalization function") + } + + if reflect.ValueOf(root.GlobalNormalizationFunc()).Pointer() != reflect.ValueOf(root.Flags().GetNormalizeFunc()).Pointer() { + t.Fatal("root command seems to have a wrong normalization function") + } + + sub := root + for sub.HasSubCommands() { + sub = sub.Commands()[0] + } + + // In case of failure of this test check this PR: spf13/cobra#110 + if reflect.ValueOf(sub.Flags().GetNormalizeFunc()).Pointer() != reflect.ValueOf(root.Flags().GetNormalizeFunc()).Pointer() { + t.Fatal("child and root commands should have the same normalization functions") + } +} diff --git a/pkg/kubectl/cmd/util/factory.go b/pkg/kubectl/cmd/util/factory.go index c92b57a885b..18e86181dd7 100644 --- a/pkg/kubectl/cmd/util/factory.go +++ b/pkg/kubectl/cmd/util/factory.go @@ -90,7 +90,7 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory { mapper := kubectl.ShortcutExpander{latest.RESTMapper} flags := pflag.NewFlagSet("", pflag.ContinueOnError) - flags.SetNormalizeFunc(util.WordSepNormalizeFunc) + flags.SetNormalizeFunc(util.WarnWordSepNormalizeFunc) // Warn for "_" flags generators := map[string]kubectl.Generator{ "run-container/v1": kubectl.BasicReplicationController{}, @@ -236,17 +236,18 @@ func (f *Factory) BindFlags(flags *pflag.FlagSet) { f.flags.Bool("validate", false, "If true, use a schema to validate the input before sending it") } - if f.flags != nil { - f.flags.VisitAll(func(flag *pflag.Flag) { - flags.AddFlag(flag) - }) - } + // Merge factory's flags + util.AddPFlagSetToPFlagSet(f.flags, flags) // Globally persistent flags across all subcommands. // TODO Change flag names to consts to allow safer lookup from subcommands. // TODO Add a verbose flag that turns on glog logging. Probably need a way // to do that automatically for every subcommand. flags.BoolVar(&f.clients.matchVersion, FlagMatchBinaryVersion, false, "Require server version to match client version") + + // Normalize all flags that are comming from other packages or pre-configurations + // a.k.a. change all "_" to "-". e.g. glog package + flags.SetNormalizeFunc(util.WordSepNormalizeFunc) } func getPorts(spec api.PodSpec) []string { diff --git a/pkg/kubectl/cmd/util/factory_test.go b/pkg/kubectl/cmd/util/factory_test.go index 06569027fa9..ead27c09474 100644 --- a/pkg/kubectl/cmd/util/factory_test.go +++ b/pkg/kubectl/cmd/util/factory_test.go @@ -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) + } +} diff --git a/pkg/util/flags.go b/pkg/util/flags.go index 3d9a9544ccf..fb422c4cc11 100644 --- a/pkg/util/flags.go +++ b/pkg/util/flags.go @@ -19,14 +19,24 @@ package util import "strings" import "github.com/spf13/pflag" +import "github.com/golang/glog" +// WordSepNormalizeFunc changes all flags that contain "_" separators func WordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName { - from := []string{"-", "_"} - to := "." - for _, sep := range from { - name = strings.Replace(name, sep, to, -1) + if strings.Contains(name, "_") { + return pflag.NormalizedName(strings.Replace(name, "_", "-", -1)) + } + return pflag.NormalizedName(name) +} + +// WarnWordSepNormalizeFunc changes and warns for flags that contain "_" separators +func WarnWordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName { + if strings.Contains(name, "_") { + nname := strings.Replace(name, "_", "-", -1) + glog.Warningf("%s is DEPRECATED and will be removed in a future version. Use %s instead.", name, nname) + + return pflag.NormalizedName(nname) } - // Type convert to indicate normalization has been done. return pflag.NormalizedName(name) } diff --git a/pkg/util/pflag_import.go b/pkg/util/pflag_import.go index 9fdc8799c8f..3e8d4d9ce8c 100644 --- a/pkg/util/pflag_import.go +++ b/pkg/util/pflag_import.go @@ -85,23 +85,25 @@ func addFlagToPFlagSet(f *flag.Flag, fs *pflag.FlagSet) { } } -// Adds all of the flags in a 'flag.FlagSet' package flags to a 'pflag.FlagSet'. +// AddFlagSetToPFlagSet adds all of the flags in a 'flag.FlagSet' package flags to a 'pflag.FlagSet'. func AddFlagSetToPFlagSet(fsIn *flag.FlagSet, fsOut *pflag.FlagSet) { fsIn.VisitAll(func(f *flag.Flag) { addFlagToPFlagSet(f, fsOut) }) } -// Add all of the top level 'flag' package flags to the top level 'pflag' flags. +// AddAllFlagsToPFlags adds all of the top level 'flag' package flags to the top level 'pflag' flags. func AddAllFlagsToPFlags() { AddFlagSetToPFlagSet(flag.CommandLine, pflag.CommandLine) } -// Merge all of the flags from fsFrom into fsTo. +// AddPFlagSetToPFlagSet merges the flags of fsFrom into fsTo. func AddPFlagSetToPFlagSet(fsFrom *pflag.FlagSet, fsTo *pflag.FlagSet) { - fsFrom.VisitAll(func(f *pflag.Flag) { - if fsTo.Lookup(f.Name) == nil { - fsTo.AddFlag(f) - } - }) + if fsFrom != nil && fsTo != nil { + fsFrom.VisitAll(func(f *pflag.Flag) { + if fsTo.Lookup(f.Name) == nil { + fsTo.AddFlag(f) + } + }) + } }