[MM-40712] config: Bugfix on path resolution; fail if given config does not exist (#19360)

* config: bugfix on path resolution; fail if given config does not exist

* reflect review comments

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-01-31 17:15:32 +03:00
коммит произвёл GitHub
родитель c554bbd977
Коммит e03384c4d1
12 изменённых файлов: 146 добавлений и 89 удалений

Просмотреть файл

@@ -45,7 +45,7 @@ func StoreOverride(override interface{}) Option {
// config loaded from the dsn on top of the normal defaults
func Config(dsn string, readOnly bool, configDefaults *model.Config) Option {
return func(s *Server) error {
configStore, err := config.NewStoreFromDSN(dsn, readOnly, configDefaults)
configStore, err := config.NewStoreFromDSN(dsn, readOnly, configDefaults, true)
if err != nil {
return errors.Wrap(err, "failed to apply Config option")
}

Просмотреть файл

@@ -210,7 +210,7 @@ func NewServer(options ...Option) (*Server, error) {
//
// Step 1: Config.
if s.configStore == nil {
innerStore, err := config.NewFileStore("config.json")
innerStore, err := config.NewFileStore("config.json", true)
if err != nil {
return nil, errors.Wrap(err, "failed to load config")
}

Просмотреть файл

@@ -168,7 +168,7 @@ func TestStartServerNoS3Bucket(t *testing.T) {
s3Endpoint := fmt.Sprintf("%s:%s", s3Host, s3Port)
s, err := NewServer(func(server *Server) error {
configStore, _ := config.NewFileStore("config.json")
configStore, _ := config.NewFileStore("config.json", true)
store, _ := config.NewStoreFromBacking(configStore, nil, false)
server.configStore = store
server.UpdateConfig(func(cfg *model.Config) {