From ebda1ad1381b9b922d280b7d97bf6f23e7348f19 Mon Sep 17 00:00:00 2001 From: maciej-karas-form3 <105207041+maciej-karas-form3@users.noreply.github.com> Date: Mon, 21 Nov 2022 20:46:05 +0100 Subject: [PATCH] fix: Missing error log for in-cluster config --- pkg/client/config/config.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/client/config/config.go b/pkg/client/config/config.go index a81b1a878d..e4e8585cb0 100644 --- a/pkg/client/config/config.go +++ b/pkg/client/config/config.go @@ -113,7 +113,7 @@ func GetConfigWithContext(context string) (*rest.Config, error) { var loadInClusterConfig = rest.InClusterConfig // loadConfig loads a REST Config as per the rules specified in GetConfig. -func loadConfig(context string) (*rest.Config, error) { +func loadConfig(context string) (config *rest.Config, configErr error) { // If a flag is specified with the config location, use that if len(kubeconfig) > 0 { return loadConfigWithContext("", &clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfig}, context) @@ -123,9 +123,16 @@ func loadConfig(context string) (*rest.Config, error) { // try the in-cluster config. kubeconfigPath := os.Getenv(clientcmd.RecommendedConfigPathEnvVar) if len(kubeconfigPath) == 0 { - if c, err := loadInClusterConfig(); err == nil { + c, err := loadInClusterConfig() + if err == nil { return c, nil } + + defer func() { + if configErr != nil { + log.Error(err, "unable to load in-cluster config") + } + }() } // If the recommended kubeconfig env variable is set, or there