Unverified Commit 09f321c8 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #61334 from dixudx/cobra_flag_terminate

Automatic merge from submit-queue (batch tested with PRs 60793, 61181, 61267, 61252, 61334). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. bump spf13/cobra(c439c4): Terminate the stripping of flags when -- is found **What this PR does / why we need it**: spf13/cobra was recently bumped in #60689. The changes between then and now are: * Terminate the stripping of flags when `--` is found: [spf13/cobra@c439c4](https://github.com/spf13/cobra/commit/c439c4) **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #61184 **Special notes for your reviewer**: No license changes. **Release note**: ```release-note None ```
parents 787b8c0c 87cfc33b
...@@ -2582,13 +2582,13 @@ ...@@ -2582,13 +2582,13 @@
}, },
{ {
"ImportPath": "github.com/spf13/cobra", "ImportPath": "github.com/spf13/cobra",
"Comment": "v0.0.1-32-g6644d46", "Comment": "v0.0.1-34-gc439c4f",
"Rev": "6644d46b81fa1831979c4cded0106e774e0ef0ab" "Rev": "c439c4fa093711d42e1b01acb1235b52004753c1"
}, },
{ {
"ImportPath": "github.com/spf13/cobra/doc", "ImportPath": "github.com/spf13/cobra/doc",
"Comment": "v0.0.1-32-g6644d46", "Comment": "v0.0.1-34-gc439c4f",
"Rev": "6644d46b81fa1831979c4cded0106e774e0ef0ab" "Rev": "c439c4fa093711d42e1b01acb1235b52004753c1"
}, },
{ {
"ImportPath": "github.com/spf13/jwalterweatherman", "ImportPath": "github.com/spf13/jwalterweatherman",
......
...@@ -584,7 +584,7 @@ ...@@ -584,7 +584,7 @@
}, },
{ {
"ImportPath": "github.com/spf13/cobra", "ImportPath": "github.com/spf13/cobra",
"Rev": "6644d46b81fa1831979c4cded0106e774e0ef0ab" "Rev": "c439c4fa093711d42e1b01acb1235b52004753c1"
}, },
{ {
"ImportPath": "github.com/spf13/pflag", "ImportPath": "github.com/spf13/pflag",
......
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
}, },
{ {
"ImportPath": "github.com/spf13/cobra", "ImportPath": "github.com/spf13/cobra",
"Rev": "6644d46b81fa1831979c4cded0106e774e0ef0ab" "Rev": "c439c4fa093711d42e1b01acb1235b52004753c1"
}, },
{ {
"ImportPath": "github.com/spf13/pflag", "ImportPath": "github.com/spf13/pflag",
......
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
}, },
{ {
"ImportPath": "github.com/spf13/cobra", "ImportPath": "github.com/spf13/cobra",
"Rev": "6644d46b81fa1831979c4cded0106e774e0ef0ab" "Rev": "c439c4fa093711d42e1b01acb1235b52004753c1"
}, },
{ {
"ImportPath": "github.com/spf13/pflag", "ImportPath": "github.com/spf13/pflag",
......
...@@ -6,15 +6,16 @@ Generating bash completions from a cobra command is incredibly easy. An actual p ...@@ -6,15 +6,16 @@ Generating bash completions from a cobra command is incredibly easy. An actual p
package main package main
import ( import (
"io/ioutil" "io/ioutil"
"os" "os"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd" "k8s.io/kubernetes/pkg/kubectl/cmd"
"k8s.io/kubernetes/pkg/kubectl/cmd/util"
) )
func main() { func main() {
kubectl := cmd.NewFactory(nil).NewKubectlCommand(os.Stdin, ioutil.Discard, ioutil.Discard) kubectl := cmd.NewKubectlCommand(util.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)
kubectl.GenBashCompletionFile("out.sh") kubectl.GenBashCompletionFile("out.sh")
} }
``` ```
......
...@@ -475,6 +475,9 @@ Loop: ...@@ -475,6 +475,9 @@ Loop:
s := args[0] s := args[0]
args = args[1:] args = args[1:]
switch { switch {
case s == "--":
// "--" terminates the flags
break Loop
case strings.HasPrefix(s, "--") && !strings.Contains(s, "=") && !hasNoOptDefVal(s[2:], flags): case strings.HasPrefix(s, "--") && !strings.Contains(s, "=") && !hasNoOptDefVal(s[2:], flags):
// If '--flag arg' then // If '--flag arg' then
// delete arg from args. // delete arg from args.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment