From ca60e0ea14d9e6ee3bbea63ed110caf270ed48a5 Mon Sep 17 00:00:00 2001 From: Abirdcfly Date: Tue, 19 Jul 2022 10:39:08 +0800 Subject: [PATCH] fix a possible panic because of taking the address of nil Signed-off-by: Abirdcfly Kubernetes-commit: c8c2819a4d7327f33a143f65c6af2bff5ef49735 --- tools/clientcmd/auth_loaders.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/clientcmd/auth_loaders.go b/tools/clientcmd/auth_loaders.go index 0e412776..5153a95a 100644 --- a/tools/clientcmd/auth_loaders.go +++ b/tools/clientcmd/auth_loaders.go @@ -51,10 +51,10 @@ func (a *PromptingAuthLoader) LoadAuth(path string) (*clientauth.Info, error) { // Prompt for user/pass and write a file if none exists. if _, err := os.Stat(path); os.IsNotExist(err) { authPtr, err := a.Prompt() - auth := *authPtr if err != nil { return nil, err } + auth := *authPtr data, err := json.Marshal(auth) if err != nil { return &auth, err