mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
kubeadm: add GetSupportedShells() to completion.go
Add the function GetSupportedShells() in completion.go and export it. It will be re-used in tests to obtain the valid list of supported shells.
This commit is contained in:
parent
23a9136d4e
commit
8303f8ecc8
@ -89,13 +89,17 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewCmdCompletion return command for executing "kubeadm completion" command
|
// GetSupportedShells returns a list of supported shells
|
||||||
func NewCmdCompletion(out io.Writer, boilerPlate string) *cobra.Command {
|
func GetSupportedShells() []string {
|
||||||
shells := []string{}
|
shells := []string{}
|
||||||
for s := range completionShells {
|
for s := range completionShells {
|
||||||
shells = append(shells, s)
|
shells = append(shells, s)
|
||||||
}
|
}
|
||||||
|
return shells
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewCmdCompletion returns the "kubeadm completion" command
|
||||||
|
func NewCmdCompletion(out io.Writer, boilerPlate string) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "completion SHELL",
|
Use: "completion SHELL",
|
||||||
Short: i18n.T("Output shell completion code for the specified shell (bash or zsh)."),
|
Short: i18n.T("Output shell completion code for the specified shell (bash or zsh)."),
|
||||||
@ -105,7 +109,7 @@ func NewCmdCompletion(out io.Writer, boilerPlate string) *cobra.Command {
|
|||||||
err := RunCompletion(out, boilerPlate, cmd, args)
|
err := RunCompletion(out, boilerPlate, cmd, args)
|
||||||
kubeadmutil.CheckErr(err)
|
kubeadmutil.CheckErr(err)
|
||||||
},
|
},
|
||||||
ValidArgs: shells,
|
ValidArgs: GetSupportedShells(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
Loading…
Reference in New Issue
Block a user