Skip to content

Commit

Permalink
Return error for all config file not exist
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia committed Jan 3, 2025
1 parent 7023bee commit b02dc1c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/config/file_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ func (fs *FileSource) loadFromFile() error {
configFiles = fs.files
fs.RUnlock()

notExistsNum := 0
for _, configFile := range configFiles {
if _, err := os.Stat(configFile); err != nil {
if os.IsNotExist(err) {
notExistsNum++
continue
}
return err
Expand All @@ -149,6 +151,10 @@ func (fs *FileSource) loadFromFile() error {

flattenAndMergeMap("", config, newConfig)
}
// not allow all config files missing, return error for this case
if notExistsNum == len(configFiles) {
return errors.Newf("all config files not exists, files: %v", configFiles)
}

return fs.update(newConfig)
}
Expand Down

0 comments on commit b02dc1c

Please sign in to comment.