Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ReadUERoutingConfig() in factory.go #77

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ func action(cliCtx *cli.Context) error {
}
factory.SmfConfig = cfg

ueRoutingCfg, err := factory.ReadUERoutingConfig(cliCtx.String("uerouting"))
if err != nil {
return err
}
factory.UERoutingConfig = ueRoutingCfg

smf, err := service.NewApp(cfg)
if err != nil {
return err
Expand Down
19 changes: 18 additions & 1 deletion pkg/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func InitConfigFactory(f string, cfg *Config) error {
return nil
}

func InitRoutingConfigFactory(f string, cfg *Config) error {
func InitRoutingConfigFactory(f string, cfg *RoutingConfig) error {
if f == "" {
// Use default config path
f = SmfDefaultUERoutingPath
Expand Down Expand Up @@ -71,3 +71,20 @@ func ReadConfig(cfgPath string) (*Config, error) {

return cfg, nil
}

func ReadUERoutingConfig(cfgPath string) (*RoutingConfig, error) {
ueRoutingCfg := &RoutingConfig{}
if err := InitRoutingConfigFactory(cfgPath, ueRoutingCfg); err != nil {
return nil, fmt.Errorf("ReadConfig [%s] Error: %+v", cfgPath, err)
}
if _, err := ueRoutingCfg.Validate(); err != nil {
validErrs := err.(govalidator.Errors).Errors()
for _, validErr := range validErrs {
logger.CfgLog.Errorf("%+v", validErr)
}
logger.CfgLog.Errorf("[-- PLEASE REFER TO SAMPLE CONFIG FILE COMMENTS --]")
return nil, fmt.Errorf("Config validate Error")
}

return ueRoutingCfg, nil
}