Skip to content

Commit

Permalink
Check for local file references in ReadValid()
Browse files Browse the repository at this point in the history
  • Loading branch information
timburks committed Oct 13, 2023
1 parent 1e05c6a commit 2a19a2f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ func ReadValid(name string) (c Configuration, err error) {
var r io.Reader = &bytes.Buffer{}
if file != "" {
if dir == "" {
name = filepath.Join(Directory, file)
// If name refers to a local file, preferentially read the local file.
// Otherwise assume name refers to a file in the config directory.
if info, err := os.Stat(file); errors.Is(err, os.ErrNotExist) || info.IsDir() {
name = filepath.Join(Directory, file)
}
}
r, err = os.Open(name)
if err != nil {
Expand Down

0 comments on commit 2a19a2f

Please sign in to comment.