From 30620fd5039924438f5fbdc8bb0e4f5ea5f3d7e8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 29 Jul 2023 00:57:23 +0800 Subject: [PATCH 1/3] change sd to lowercase --- pkg/factory/factory.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/factory/factory.go b/pkg/factory/factory.go index 35e57da0..340f507b 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,25 @@ 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 { + if UPNodes[i].SNssaiInfos != nil { + 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 +54,7 @@ func InitConfigFactory(f string, cfg *Config) error { return fmt.Errorf("[Factory] %+v", yamlErr) } } + changeSdToLowercase(cfg) return nil } From 8e3a7edeccd8642efe7270696598eb9eff0f9a6f Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 29 Jul 2023 16:45:35 +0800 Subject: [PATCH 2/3] gofumpt-ed --- pkg/factory/factory.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/factory/factory.go b/pkg/factory/factory.go index 340f507b..7c69eabb 100644 --- a/pkg/factory/factory.go +++ b/pkg/factory/factory.go @@ -21,13 +21,13 @@ var ( ) func changeSdToLowercase(cfg *Config) { - //snssaiInfos + // snssaiInfos SNssaiInfo := cfg.Configuration.SNssaiInfo for i := range SNssaiInfo { SNssaiInfo[i].SNssai.Sd = strings.ToLower(SNssaiInfo[i].SNssai.Sd) } - //userplaneInformation + // userplaneInformation UPNodes := cfg.Configuration.UserPlaneInformation.UPNodes for i := range UPNodes { if UPNodes[i].SNssaiInfos != nil { From d16420a0f0b8eeee4d5915055f3d12425bda53d9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 31 Jul 2023 13:01:35 +0800 Subject: [PATCH 3/3] deleted if --- pkg/factory/factory.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/factory/factory.go b/pkg/factory/factory.go index 7c69eabb..3629452a 100644 --- a/pkg/factory/factory.go +++ b/pkg/factory/factory.go @@ -30,11 +30,9 @@ func changeSdToLowercase(cfg *Config) { // userplaneInformation UPNodes := cfg.Configuration.UserPlaneInformation.UPNodes for i := range UPNodes { - if UPNodes[i].SNssaiInfos != nil { - SNssaiInfos := UPNodes[i].SNssaiInfos - for j := range SNssaiInfos { - SNssaiInfos[j].SNssai.Sd = strings.ToLower(SNssaiInfos[j].SNssai.Sd) - } + SNssaiInfos := UPNodes[i].SNssaiInfos + for j := range SNssaiInfos { + SNssaiInfos[j].SNssai.Sd = strings.ToLower(SNssaiInfos[j].SNssai.Sd) } } }