From abec5eee22d00ed563f492357ecf680449aead69 Mon Sep 17 00:00:00 2001 From: danielh1204 <80144195+danielh1204@users.noreply.github.com> Date: Tue, 1 Aug 2023 14:56:49 +0800 Subject: [PATCH] changed sd to lowercase (#81) * change sd to lowercase * gofumpt-ed * deleted if --- pkg/factory/factory.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/factory/factory.go b/pkg/factory/factory.go index 35e57da0..3629452a 100644 --- a/pkg/factory/factory.go +++ b/pkg/factory/factory.go @@ -7,6 +7,7 @@ package factory import ( "fmt" "io/ioutil" + "strings" "github.com/asaskevich/govalidator" "gopkg.in/yaml.v2" @@ -19,6 +20,23 @@ var ( UERoutingConfig *RoutingConfig ) +func changeSdToLowercase(cfg *Config) { + // snssaiInfos + SNssaiInfo := cfg.Configuration.SNssaiInfo + for i := range SNssaiInfo { + SNssaiInfo[i].SNssai.Sd = strings.ToLower(SNssaiInfo[i].SNssai.Sd) + } + + // userplaneInformation + UPNodes := cfg.Configuration.UserPlaneInformation.UPNodes + for i := range UPNodes { + SNssaiInfos := UPNodes[i].SNssaiInfos + for j := range SNssaiInfos { + SNssaiInfos[j].SNssai.Sd = strings.ToLower(SNssaiInfos[j].SNssai.Sd) + } + } +} + // TODO: Support configuration update from REST api func InitConfigFactory(f string, cfg *Config) error { if f == "" { @@ -34,6 +52,7 @@ func InitConfigFactory(f string, cfg *Config) error { return fmt.Errorf("[Factory] %+v", yamlErr) } } + changeSdToLowercase(cfg) return nil }