diff --git a/cmd/s3-gw/app_settings.go b/cmd/s3-gw/app_settings.go index fe473764..5d36f945 100644 --- a/cmd/s3-gw/app_settings.go +++ b/cmd/s3-gw/app_settings.go @@ -487,7 +487,7 @@ func fetchNamespacesConfig(l *zap.Logger, v *viper.Viper) NamespacesConfig { nsConfig, err := readNamespacesConfig(v.GetString(cfgNamespacesConfig)) if err != nil { - l.Warn(logs.FailedToParseNamespacesConfig) + l.Warn(logs.FailedToParseNamespacesConfig, zap.Error(err)) } defaultNamespacesNames := fetchDefaultNamespaces(l, v) @@ -521,18 +521,21 @@ func fetchNamespacesConfig(l *zap.Logger, v *viper.Viper) NamespacesConfig { } func readNamespacesConfig(filepath string) (NamespacesConfig, error) { + nsConfig := NamespacesConfig{ + Namespaces: make(Namespaces), + } + if filepath == "" { - return NamespacesConfig{}, nil + return nsConfig, nil } data, err := os.ReadFile(filepath) if err != nil { - return NamespacesConfig{}, fmt.Errorf("failed to read namespace config '%s': %w", filepath, err) + return nsConfig, fmt.Errorf("failed to read namespace config '%s': %w", filepath, err) } - var nsConfig NamespacesConfig if err = json.Unmarshal(data, &nsConfig); err != nil { - return NamespacesConfig{}, fmt.Errorf("failed to parse namespace config: %w", err) + return nsConfig, fmt.Errorf("failed to parse namespace config: %w", err) } return nsConfig, nil