validate flag cfgPath to make sure it is not empty

This commit is contained in:
navist2020 2021-10-13 15:52:22 +08:00
parent e054181e51
commit cc2802d9bb

View File

@ -20,6 +20,7 @@ import (
"io"
"time"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"k8s.io/klog/v2"
@ -78,6 +79,9 @@ func newCmdUserKubeConfig(out io.Writer) *cobra.Command {
Long: userKubeconfigLongDesc,
Example: userKubeconfigExample,
RunE: func(cmd *cobra.Command, args []string) error {
if len(cfgPath) == 0 {
return errors.New("the kubeadm configuration path cannot be empty")
}
// This call returns the ready-to-use configuration based on the defaults populated by flags
internalCfg, err := configutil.LoadOrDefaultInitConfiguration(cfgPath, initCfg, clusterCfg)
if err != nil {