Skip to content

Commit 9489eb5

Browse files
authored
Merge pull request #2051 from maciej-karas-form3/patch-1
🐛 Missing error log for in-cluster config
2 parents 007d240 + ebda1ad commit 9489eb5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/client/config/config.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func GetConfigWithContext(context string) (*rest.Config, error) {
113113
var loadInClusterConfig = rest.InClusterConfig
114114

115115
// loadConfig loads a REST Config as per the rules specified in GetConfig.
116-
func loadConfig(context string) (*rest.Config, error) {
116+
func loadConfig(context string) (config *rest.Config, configErr error) {
117117
// If a flag is specified with the config location, use that
118118
if len(kubeconfig) > 0 {
119119
return loadConfigWithContext("", &clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfig}, context)
@@ -123,9 +123,16 @@ func loadConfig(context string) (*rest.Config, error) {
123123
// try the in-cluster config.
124124
kubeconfigPath := os.Getenv(clientcmd.RecommendedConfigPathEnvVar)
125125
if len(kubeconfigPath) == 0 {
126-
if c, err := loadInClusterConfig(); err == nil {
126+
c, err := loadInClusterConfig()
127+
if err == nil {
127128
return c, nil
128129
}
130+
131+
defer func() {
132+
if configErr != nil {
133+
log.Error(err, "unable to load in-cluster config")
134+
}
135+
}()
129136
}
130137

131138
// If the recommended kubeconfig env variable is set, or there

0 commit comments

Comments
 (0)