From 8303f8ecc853a3a3a201c1b6fb5ff45826183d41 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Thu, 8 Mar 2018 18:13:10 +0200 Subject: [PATCH] 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. --- cmd/kubeadm/app/cmd/completion.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/kubeadm/app/cmd/completion.go b/cmd/kubeadm/app/cmd/completion.go index 48282b20dd2..33d5526f9a8 100644 --- a/cmd/kubeadm/app/cmd/completion.go +++ b/cmd/kubeadm/app/cmd/completion.go @@ -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