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.
pull/8/head
Lubomir I. Ivanov 2018-03-08 18:13:10 +02:00
parent 23a9136d4e
commit 8303f8ecc8
1 changed files with 7 additions and 3 deletions

View File

@ -89,13 +89,17 @@ var (
}
)
// NewCmdCompletion return command for executing "kubeadm completion" command
func NewCmdCompletion(out io.Writer, boilerPlate string) *cobra.Command {
// GetSupportedShells returns a list of supported shells
func GetSupportedShells() []string {
shells := []string{}
for s := range completionShells {
shells = append(shells, s)
}
return shells
}
// NewCmdCompletion returns the "kubeadm completion" command
func NewCmdCompletion(out io.Writer, boilerPlate string) *cobra.Command {
cmd := &cobra.Command{
Use: "completion SHELL",
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)
kubeadmutil.CheckErr(err)
},
ValidArgs: shells,
ValidArgs: GetSupportedShells(),
}
return cmd