mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-08 05:56:37 +00:00
config: fix validation error with empty config files (#2080)
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -134,6 +135,11 @@ func NewConfigFileResolver(filePath string) (*Resolver, error) {
|
||||
decoder.KnownFields(true)
|
||||
|
||||
if err = decoder.Decode(&configFileStructure); err != nil {
|
||||
// Handle EOF error gracefully, indicating no configuration was found.
|
||||
if errors.Is(err, io.EOF) {
|
||||
return &Resolver{flags: flags}, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("configuration file validation error: %w", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user