Skip to content

Commit 3157724

Browse files
commetns addressed
1 parent 676c6a0 commit 3157724

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

internal/wrapper.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ func RunKubeStateMetricsWrapper(opts *options.Options) {
4848
cfgViper := viper.New()
4949
cfgViper.SetConfigType("yaml")
5050
cfgViper.SetConfigFile(file)
51-
var err error
52-
if err = cfgViper.ReadInConfig(); err != nil {
53-
if errors.Is(err, viper.ConfigFileNotFoundError{}) {
51+
var cfgViperReadInConfigErr error
52+
if cfgViperReadInConfigErr = cfgViper.ReadInConfig(); cfgViperReadInConfigErr != nil {
53+
if errors.Is(cfgViperReadInConfigErr, viper.ConfigFileNotFoundError{}) {
5454
klog.InfoS("Options configuration file not found at startup", "file", file)
55-
} else if _, err = os.Stat(filepath.Clean(file)); os.IsNotExist(err) {
55+
} else if _, isNotExisterr := os.Stat(filepath.Clean(file)); os.IsNotExist(isNotExisterr) {
5656
// TODO: Remove this check once viper.ConfigFileNotFoundError is working as expected, see this issue -
5757
// https://github.com/spf13/viper/issues/1783
5858
klog.InfoS("Options configuration file not found at startup", "file", file)
5959
} else {
60-
klog.ErrorS(err, "Error reading options configuration file", "file", file)
60+
klog.ErrorS(cfgViperReadInConfigErr, "Error reading options configuration file", "file", file)
6161
}
6262
if !opts.ContinueWithoutConfig {
6363
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
@@ -73,7 +73,7 @@ func RunKubeStateMetricsWrapper(opts *options.Options) {
7373
})
7474
cfgViper.WatchConfig()
7575

76-
if err == nil {
76+
if cfgViperReadInConfigErr == nil {
7777
// Merge configFile values with opts so we get the CustomResourceConfigFile from config as well
7878
configFile, err := os.ReadFile(filepath.Clean(file))
7979
if err != nil {

pkg/app/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ func resolveCustomResourceConfig(opts *options.Options) (customresourcestate.Con
548548
if file := opts.CustomResourceConfigFile; file != "" {
549549
if opts.ContinueWithoutCustomResourceConfigFile {
550550
if _, err := os.Stat(filepath.Clean(file)); os.IsNotExist(err) {
551-
klog.InfoS("custom resource config file does not exist,ignoring", "file", file)
551+
klog.ErrorS(err, "failed to open Custom Resource State Metrics file, ignoring", "file", file)
552552
}
553553
} else {
554554
f, err := os.Open(filepath.Clean(file))

0 commit comments

Comments
 (0)