mirror of https://github.com/kubernetes/kops.git
Upgrade Cobra to 1.2.1
This commit is contained in:
parent
d8f7b6d14a
commit
04943c8e3b
2
go.mod
2
go.mod
|
|
@ -68,7 +68,7 @@ require (
|
||||||
github.com/pkg/sftp v1.13.0
|
github.com/pkg/sftp v1.13.0
|
||||||
github.com/prometheus/client_golang v1.11.0
|
github.com/prometheus/client_golang v1.11.0
|
||||||
github.com/sergi/go-diff v1.2.0
|
github.com/sergi/go-diff v1.2.0
|
||||||
github.com/spf13/cobra v1.2.0
|
github.com/spf13/cobra v1.2.1
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/spf13/viper v1.8.1
|
github.com/spf13/viper v1.8.1
|
||||||
github.com/spotinst/spotinst-sdk-go v1.85.0
|
github.com/spotinst/spotinst-sdk-go v1.85.0
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -1069,8 +1069,8 @@ github.com/spf13/cobra v0.0.7/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHN
|
||||||
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
||||||
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
|
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
|
||||||
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
|
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
|
||||||
github.com/spf13/cobra v1.2.0 h1:IHGo93KUJjih0Gz449MCBDKuaWPqcKcbuUM7GXWFnlw=
|
github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=
|
||||||
github.com/spf13/cobra v1.2.0/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
|
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
|
||||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
||||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
||||||
|
|
|
||||||
|
|
@ -1344,8 +1344,8 @@ github.com/spf13/cobra v0.0.7/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHN
|
||||||
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
|
||||||
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
|
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
|
||||||
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
|
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
|
||||||
github.com/spf13/cobra v1.2.0 h1:IHGo93KUJjih0Gz449MCBDKuaWPqcKcbuUM7GXWFnlw=
|
github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=
|
||||||
github.com/spf13/cobra v1.2.0/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
|
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
|
||||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
||||||
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
|
|
|
||||||
|
|
@ -512,7 +512,9 @@ func writeLocalNonPersistentFlag(buf io.StringWriter, flag *pflag.Flag) {
|
||||||
|
|
||||||
// Setup annotations for go completions for registered flags
|
// Setup annotations for go completions for registered flags
|
||||||
func prepareCustomAnnotationsForFlags(cmd *Command) {
|
func prepareCustomAnnotationsForFlags(cmd *Command) {
|
||||||
for flag := range cmd.Root().flagCompletionFunctions {
|
flagCompletionMutex.RLock()
|
||||||
|
defer flagCompletionMutex.RUnlock()
|
||||||
|
for flag := range flagCompletionFunctions {
|
||||||
// Make sure the completion script calls the __*_go_custom_completion function for
|
// Make sure the completion script calls the __*_go_custom_completion function for
|
||||||
// every registered flag. We need to do this here (and not when the flag was registered
|
// every registered flag. We need to do this here (and not when the flag was registered
|
||||||
// for completion) so that we can know the root command name for the prefix
|
// for completion) so that we can know the root command name for the prefix
|
||||||
|
|
|
||||||
|
|
@ -142,9 +142,6 @@ type Command struct {
|
||||||
// that we can use on every pflag set and children commands
|
// that we can use on every pflag set and children commands
|
||||||
globNormFunc func(f *flag.FlagSet, name string) flag.NormalizedName
|
globNormFunc func(f *flag.FlagSet, name string) flag.NormalizedName
|
||||||
|
|
||||||
//flagCompletionFunctions is map of flag completion functions.
|
|
||||||
flagCompletionFunctions map[*flag.Flag]func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)
|
|
||||||
|
|
||||||
// usageFunc is usage func defined by user.
|
// usageFunc is usage func defined by user.
|
||||||
usageFunc func(*Command) error
|
usageFunc func(*Command) error
|
||||||
// usageTemplate is usage template defined by user.
|
// usageTemplate is usage template defined by user.
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
@ -17,6 +18,12 @@ const (
|
||||||
ShellCompNoDescRequestCmd = "__completeNoDesc"
|
ShellCompNoDescRequestCmd = "__completeNoDesc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Global map of flag completion functions. Make sure to use flagCompletionMutex before you try to read and write from it.
|
||||||
|
var flagCompletionFunctions = map[*pflag.Flag]func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective){}
|
||||||
|
|
||||||
|
// lock for reading and writing from flagCompletionFunctions
|
||||||
|
var flagCompletionMutex = &sync.RWMutex{}
|
||||||
|
|
||||||
// ShellCompDirective is a bit map representing the different behaviors the shell
|
// ShellCompDirective is a bit map representing the different behaviors the shell
|
||||||
// can be instructed to have once completions have been provided.
|
// can be instructed to have once completions have been provided.
|
||||||
type ShellCompDirective int
|
type ShellCompDirective int
|
||||||
|
|
@ -100,15 +107,13 @@ func (c *Command) RegisterFlagCompletionFunc(flagName string, f func(cmd *Comman
|
||||||
if flag == nil {
|
if flag == nil {
|
||||||
return fmt.Errorf("RegisterFlagCompletionFunc: flag '%s' does not exist", flagName)
|
return fmt.Errorf("RegisterFlagCompletionFunc: flag '%s' does not exist", flagName)
|
||||||
}
|
}
|
||||||
|
flagCompletionMutex.Lock()
|
||||||
|
defer flagCompletionMutex.Unlock()
|
||||||
|
|
||||||
root := c.Root()
|
if _, exists := flagCompletionFunctions[flag]; exists {
|
||||||
if _, exists := root.flagCompletionFunctions[flag]; exists {
|
|
||||||
return fmt.Errorf("RegisterFlagCompletionFunc: flag '%s' already registered", flagName)
|
return fmt.Errorf("RegisterFlagCompletionFunc: flag '%s' already registered", flagName)
|
||||||
}
|
}
|
||||||
if root.flagCompletionFunctions == nil {
|
flagCompletionFunctions[flag] = f
|
||||||
root.flagCompletionFunctions = map[*pflag.Flag]func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective){}
|
|
||||||
}
|
|
||||||
root.flagCompletionFunctions[flag] = f
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -402,7 +407,9 @@ func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDi
|
||||||
// Find the completion function for the flag or command
|
// Find the completion function for the flag or command
|
||||||
var completionFn func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)
|
var completionFn func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)
|
||||||
if flag != nil && flagCompletion {
|
if flag != nil && flagCompletion {
|
||||||
completionFn = c.Root().flagCompletionFunctions[flag]
|
flagCompletionMutex.RLock()
|
||||||
|
completionFn = flagCompletionFunctions[flag]
|
||||||
|
flagCompletionMutex.RUnlock()
|
||||||
} else {
|
} else {
|
||||||
completionFn = finalCmd.ValidArgsFunction
|
completionFn = finalCmd.ValidArgsFunction
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,11 +152,11 @@ function __%[1]s_prepare_completions
|
||||||
# We don't need descriptions anyway since there is only a single
|
# We don't need descriptions anyway since there is only a single
|
||||||
# real completion which the shell will expand immediately.
|
# real completion which the shell will expand immediately.
|
||||||
set -l split (string split --max 1 \t $__%[1]s_comp_results[1])
|
set -l split (string split --max 1 \t $__%[1]s_comp_results[1])
|
||||||
|
|
||||||
# Fish won't add a space if the completion ends with any
|
# Fish won't add a space if the completion ends with any
|
||||||
# of the following characters: @=/:.,
|
# of the following characters: @=/:.,
|
||||||
set -l lastChar (string sub -s -1 -- $split)
|
set -l lastChar (string sub -s -1 -- $split)
|
||||||
if not string match -r -q "[@=/:.,]" -- "$lastChar"
|
if not string match -r -q "[@=/:.,]" -- "$lastChar"
|
||||||
# In other cases, to support the "nospace" directive we trick the shell
|
# In other cases, to support the "nospace" directive we trick the shell
|
||||||
# by outputting an extra, longer completion.
|
# by outputting an extra, longer completion.
|
||||||
__%[1]s_debug "Adding second completion to perform nospace directive"
|
__%[1]s_debug "Adding second completion to perform nospace directive"
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,7 @@ github.com/spf13/afero
|
||||||
github.com/spf13/afero/mem
|
github.com/spf13/afero/mem
|
||||||
# github.com/spf13/cast v1.3.1
|
# github.com/spf13/cast v1.3.1
|
||||||
github.com/spf13/cast
|
github.com/spf13/cast
|
||||||
# github.com/spf13/cobra v1.2.0
|
# github.com/spf13/cobra v1.2.1
|
||||||
## explicit
|
## explicit
|
||||||
github.com/spf13/cobra
|
github.com/spf13/cobra
|
||||||
github.com/spf13/cobra/doc
|
github.com/spf13/cobra/doc
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue