refactor config file type

This commit is contained in:
2025-09-05 23:51:21 +04:00
parent 1eb969480b
commit c3292dee5f
8 changed files with 94 additions and 179 deletions

View File

@@ -1,7 +1,6 @@
package parser
import (
"errors"
"flag"
"fmt"
"net/url"
@@ -173,17 +172,6 @@ func (parser ConfigCLIParser) Parse() (*config.Config, error) {
configFileParsed, err := types.ParseConfigFile(configFile)
_ = utils.HandleErrorOrDie(err,
utils.OnSentinelError(types.ErrConfigFileExtensionNotFound, func(err error) error {
fieldParseErrors = append(
fieldParseErrors,
*types.NewFieldParseError(
fmt.Sprintf("config-file[%d]", i),
configFile,
errors.New("file extension not found"),
),
)
return nil
}),
utils.OnCustomError(func(err types.RemoteConfigFileParseError) error {
fieldParseErrors = append(
fieldParseErrors,
@@ -195,17 +183,6 @@ func (parser ConfigCLIParser) Parse() (*config.Config, error) {
)
return nil
}),
utils.OnCustomError(func(err types.UnknownConfigFileTypeError) error {
fieldParseErrors = append(
fieldParseErrors,
*types.NewFieldParseError(
fmt.Sprintf("config-file[%d]", i),
configFile,
fmt.Errorf("file type '%s' not supported (supported types: %s)", err.Type, types.ConfigFileTypeYAML),
),
)
return nil
}),
)
if err == nil {