Skip to content

Commit

Permalink
fix: Missing error log for in-cluster config
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-karas-form3 committed Nov 28, 2022
1 parent accd262 commit 23be164
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/client/config/config.go
Expand Up @@ -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)
Expand All @@ -125,6 +125,12 @@ func loadConfig(context string) (*rest.Config, error) {
if len(kubeconfigPath) == 0 {
if c, err := loadInClusterConfig(); err == nil {
return c, nil
} else {
defer func() {
if configErr != nil {
log.Error(err, "unable to load in-cluster config")
}
}()
}
}

Expand Down

0 comments on commit 23be164

Please sign in to comment.