Skip to content

Commit 54a6806

Browse files
adding additional check
1 parent efb4086 commit 54a6806

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/wrapper.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func RunKubeStateMetricsWrapper(opts *options.Options) {
5252
if err = cfgViper.ReadInConfig(); err != nil {
5353
if errors.Is(err, 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) {
56+
// Adding this check in addition to the above since viper.ConfigFileNotFoundError is not working as expected due to this issue -
57+
// https://github.com/spf13/viper/issues/1783
58+
klog.InfoS("Options configuration file not found at startup", "file", file)
5559
} else {
5660
klog.ErrorS(err, "Error reading options configuration file", "file", file)
5761
klog.FlushAndExit(klog.ExitFlushTimeout, 1)

0 commit comments

Comments
 (0)