Skip to content

Commit

Permalink
chore: fix nf_discovery 'range-based loop'
Browse files Browse the repository at this point in the history
  • Loading branch information
KunLee76 committed Sep 18, 2024
1 parent 8e15619 commit b19c499
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
46 changes: 23 additions & 23 deletions internal/sbi/api_nfmanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,15 @@ func (s *Server) GetNrfInfo() *models.NrfInfo {
// init
var nrfinfo models.NrfInfo

nrfinfo.ServedUdrInfo = s.getUdrInfo()
nrfinfo.ServedUdmInfo = s.getUdmInfo()
nrfinfo.ServedAusfInfo = s.getAusfInfo()
//nrfinfo.ServedUdrInfo = s.getUdrInfo()
//nrfinfo.ServedUdmInfo = s.getUdmInfo()
//nrfinfo.ServedAusfInfo = s.getAusfInfo()
nrfinfo.ServedAmfInfo = s.getAmfInfo()
nrfinfo.ServedSmfInfo = s.getSmfInfo()
nrfinfo.ServedUpfInfo = s.getUpfInfo()
nrfinfo.ServedPcfInfo = s.getPcfInfo()
//nrfinfo.ServedSmfInfo = s.getSmfInfo()
//nrfinfo.ServedUpfInfo = s.getUpfInfo()
//nrfinfo.ServedPcfInfo = s.getPcfInfo()
nrfinfo.ServedBsfInfo = s.getBsfInfo()
nrfinfo.ServedChfInfo = s.getChfInfo()
//nrfinfo.ServedChfInfo = s.getChfInfo()

return &nrfinfo
}
Expand Down Expand Up @@ -357,8 +357,8 @@ func (s *Server) getUdrInfo() map[string]interface{} {
return servedUdrInfo
}

func (s *Server) getUdmInfo() map[string]interface{} {
servedUdmInfo := make(map[string]interface{})
func (s *Server) getUdmInfo() map[string]models.UdmInfo {
servedUdmInfo := make(map[string]models.UdmInfo)
var UDMProfile models.NrfNfManagementNfProfile

collName := nrf_context.NfProfileCollName
Expand All @@ -385,8 +385,8 @@ func (s *Server) getUdmInfo() map[string]interface{} {
return servedUdmInfo
}

func (s *Server) getAusfInfo() map[string]interface{} {
servedAusfInfo := make(map[string]interface{})
func (s *Server) getAusfInfo() map[string]models.AusfInfo {
servedAusfInfo := make(map[string]models.AusfInfo)
var AUSFProfile models.NrfNfManagementNfProfile

collName := nrf_context.NfProfileCollName
Expand All @@ -412,8 +412,8 @@ func (s *Server) getAusfInfo() map[string]interface{} {
return servedAusfInfo
}

func (s *Server) getAmfInfo() map[string]interface{} {
servedAmfinfo := make(map[string]interface{})
func (s *Server) getAmfInfo() map[string]models.AmfInfo {

Check failure on line 415 in internal/sbi/api_nfmanagement.go

View workflow job for this annotation

GitHub Actions / build (1.21)

undefined: models.AmfInfo

Check failure on line 415 in internal/sbi/api_nfmanagement.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

undefined: models.AmfInfo
servedAmfinfo := make(map[string]models.AmfInfo)

Check failure on line 416 in internal/sbi/api_nfmanagement.go

View workflow job for this annotation

GitHub Actions / build (1.21)

undefined: models.AmfInfo

Check failure on line 416 in internal/sbi/api_nfmanagement.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

undefined: models.AmfInfo
var AMFProfile models.NrfNfManagementNfProfile

collName := nrf_context.NfProfileCollName
Expand All @@ -439,8 +439,8 @@ func (s *Server) getAmfInfo() map[string]interface{} {
return servedAmfinfo
}

func (s *Server) getSmfInfo() map[string]interface{} {
servedSmfInfo := make(map[string]interface{})
func (s *Server) getSmfInfo() map[string]models.SmfInfo {
servedSmfInfo := make(map[string]models.SmfInfo)
var SMFProfile models.NrfNfManagementNfProfile

collName := nrf_context.NfProfileCollName
Expand All @@ -466,8 +466,8 @@ func (s *Server) getSmfInfo() map[string]interface{} {
return servedSmfInfo
}

func (s *Server) getUpfInfo() map[string]interface{} {
servedUpfInfo := make(map[string]interface{})
func (s *Server) getUpfInfo() map[string]models.UpfInfo {
servedUpfInfo := make(map[string]models.UpfInfo)
var UPFProfile models.NrfNfManagementNfProfile

collName := nrf_context.NfProfileCollName
Expand All @@ -493,8 +493,8 @@ func (s *Server) getUpfInfo() map[string]interface{} {
return servedUpfInfo
}

func (s *Server) getPcfInfo() map[string]interface{} {
servedPcfInfo := make(map[string]interface{})
func (s *Server) getPcfInfo() map[string]models.PcfInfo {
servedPcfInfo := make(map[string]models.PcfInfo)
var PCFProfile models.NrfNfManagementNfProfile

collName := nrf_context.NfProfileCollName
Expand All @@ -520,8 +520,8 @@ func (s *Server) getPcfInfo() map[string]interface{} {
return servedPcfInfo
}

func (s *Server) getBsfInfo() map[string]interface{} {
servedBsfInfo := make(map[string]interface{})
func (s *Server) getBsfInfo() map[string]models.BsfInfo {

Check failure on line 523 in internal/sbi/api_nfmanagement.go

View workflow job for this annotation

GitHub Actions / build (1.21)

undefined: models.BsfInfo

Check failure on line 523 in internal/sbi/api_nfmanagement.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

undefined: models.BsfInfo
servedBsfInfo := make(map[string]models.BsfInfo)

Check failure on line 524 in internal/sbi/api_nfmanagement.go

View workflow job for this annotation

GitHub Actions / build (1.21)

undefined: models.BsfInfo

Check failure on line 524 in internal/sbi/api_nfmanagement.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

undefined: models.BsfInfo (typecheck)
var BSFProfile models.NrfNfManagementNfProfile

collName := nrf_context.NfProfileCollName
Expand All @@ -547,8 +547,8 @@ func (s *Server) getBsfInfo() map[string]interface{} {
return servedBsfInfo
}

func (s *Server) getChfInfo() map[string]interface{} {
servedChfInfo := make(map[string]interface{})
func (s *Server) getChfInfo() map[string]models.ChfInfo {
servedChfInfo := make(map[string]models.ChfInfo)
var CHFProfile models.NrfNfManagementNfProfile

collName := nrf_context.NfProfileCollName
Expand Down
9 changes: 4 additions & 5 deletions internal/sbi/processor/nf_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,22 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val

// handle ipv4 & ipv6
if queryParameters["target-nf-type"][0] == "BSF" {
for i := 0; i < len(nfProfilesStruct); i++ {
nfProfile := nfProfilesStruct[i]
for i, nfProfile := range nfProfilesStruct {

Check failure on line 146 in internal/sbi/processor/nf_discovery.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

rangeValCopy: each iteration copies 880 bytes (consider pointers or indexing) (gocritic)
if nfProfile.BsfInfo != nil && nfProfile.BsfInfo.Ipv4AddressRanges != nil {
for j := range nfProfile.BsfInfo.Ipv4AddressRanges {
ipv4IntStart, errAtoi := strconv.Atoi(nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges[j].Start)
if errAtoi != nil {
logger.DiscLog.Warnln("ipv4IntStart Atoi Error: ", errAtoi)
}
}

Check failure on line 152 in internal/sbi/processor/nf_discovery.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/free5gc) --custom-order (gci)
((nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges)[j]).Start = nrf_context.Ipv4IntToIpv4String(int64(ipv4IntStart))
ipv4IntEnd, errAtoi := strconv.Atoi((((nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges)[j]).End))
if errAtoi != nil {
logger.DiscLog.Warnln("ipv4IntEnd Atoi Error: ", errAtoi)
}
}

Check failure on line 157 in internal/sbi/processor/nf_discovery.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/free5gc) --custom-order (gci)
((nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges)[j]).End = nrf_context.Ipv4IntToIpv4String(int64(ipv4IntEnd))
}
}

Check failure on line 161 in internal/sbi/processor/nf_discovery.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/free5gc) --custom-order (gci)
if nfProfile.BsfInfo != nil && nfProfile.BsfInfo.Ipv6PrefixRanges != nil {
for j := range nfProfile.BsfInfo.Ipv6PrefixRanges {
ipv6IntStart := new(big.Int)
Expand All @@ -173,7 +173,6 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val
}
}
validityPeriod := 100

// Build SearchResult model
searchResult := &models.SearchResult{
ValidityPeriod: int32(validityPeriod),
Expand Down

0 comments on commit b19c499

Please sign in to comment.