From b82be5bd081d9d13c16543c3417277b8ddac0403 Mon Sep 17 00:00:00 2001 From: kun Date: Tue, 1 Oct 2024 15:41:07 +0000 Subject: [PATCH] fix: 'nf_discovery.go' range-based loop & linter errors --- internal/sbi/api_bootstrapping.go | 4 +--- internal/sbi/api_nfmanagement.go | 3 --- internal/sbi/consumer/nrf_service.go | 2 +- internal/sbi/processor/nf_discovery.go | 28 +++++++++++++------------- pkg/factory/config.go | 2 +- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/internal/sbi/api_bootstrapping.go b/internal/sbi/api_bootstrapping.go index 1a301e2..5d780f2 100644 --- a/internal/sbi/api_bootstrapping.go +++ b/internal/sbi/api_bootstrapping.go @@ -1,5 +1,3 @@ - - package sbi import ( @@ -29,4 +27,4 @@ func (s *Server) getBootstrappingRoutes() []Route { func (s *Server) HTTPBootstrappingInfoRequest(c *gin.Context) { c.JSON(http.StatusNotImplemented, gin.H{}) -} \ No newline at end of file +} diff --git a/internal/sbi/api_nfmanagement.go b/internal/sbi/api_nfmanagement.go index 86b3f04..fc49c9d 100644 --- a/internal/sbi/api_nfmanagement.go +++ b/internal/sbi/api_nfmanagement.go @@ -18,15 +18,12 @@ import ( "github.com/gin-gonic/gin" "github.com/mitchellh/mapstructure" - // "go.mongodb.org/mongo-driver/bson" // nrf_context "github.com/free5gc/nrf/internal/context" "github.com/free5gc/nrf/internal/logger" "github.com/free5gc/nrf/internal/util" "github.com/free5gc/openapi" "github.com/free5gc/openapi/models" - // timedecode "github.com/free5gc/util/mapstruct" - // "github.com/free5gc/util/mongoapi" ) func (s *Server) getNfRegisterRoute() []Route { diff --git a/internal/sbi/consumer/nrf_service.go b/internal/sbi/consumer/nrf_service.go index b11ed19..6a445ff 100644 --- a/internal/sbi/consumer/nrf_service.go +++ b/internal/sbi/consumer/nrf_service.go @@ -84,6 +84,6 @@ func (s *nnrfService) SendNFStatusNotify( } return problemDetails } - + return nil } diff --git a/internal/sbi/processor/nf_discovery.go b/internal/sbi/processor/nf_discovery.go index 8ff3ea2..1438e15 100644 --- a/internal/sbi/processor/nf_discovery.go +++ b/internal/sbi/processor/nf_discovery.go @@ -143,31 +143,31 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val // handle ipv4 & ipv6 if queryParameters["target-nf-type"][0] == "BSF" { - for i, nfProfile := range nfProfilesStruct { + for _, nfProfile := range nfProfilesStruct { if nfProfile.BsfInfo != nil && nfProfile.BsfInfo.Ipv4AddressRanges != nil { - for j := range nfProfile.BsfInfo.Ipv4AddressRanges { - ipv4IntStart, errAtoi := strconv.Atoi(nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges[j].Start) + for addressRange := range nfProfile.BsfInfo.Ipv4AddressRanges { + ipv4IntStart, errAtoi := strconv.Atoi(nfProfile.BsfInfo.Ipv4AddressRanges[addressRange].Start) if errAtoi != nil { logger.DiscLog.Warnln("ipv4IntStart Atoi Error: ", errAtoi) - } - ((nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges)[j]).Start = nrf_context.Ipv4IntToIpv4String(int64(ipv4IntStart)) - ipv4IntEnd, errAtoi := strconv.Atoi((((nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges)[j]).End)) + } + ((nfProfile.BsfInfo.Ipv4AddressRanges)[addressRange]).Start = nrf_context.Ipv4IntToIpv4String(int64(ipv4IntStart)) + ipv4IntEnd, errAtoi := strconv.Atoi((((nfProfile.BsfInfo.Ipv4AddressRanges)[addressRange]).End)) if errAtoi != nil { logger.DiscLog.Warnln("ipv4IntEnd Atoi Error: ", errAtoi) - } - ((nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges)[j]).End = nrf_context.Ipv4IntToIpv4String(int64(ipv4IntEnd)) + } + ((nfProfile.BsfInfo.Ipv4AddressRanges)[addressRange]).End = nrf_context.Ipv4IntToIpv4String(int64(ipv4IntEnd)) } } - + if nfProfile.BsfInfo != nil && nfProfile.BsfInfo.Ipv6PrefixRanges != nil { - for j := range nfProfile.BsfInfo.Ipv6PrefixRanges { + for prefixRange := range nfProfile.BsfInfo.Ipv6PrefixRanges { ipv6IntStart := new(big.Int) - ipv6IntStart.SetString(((nfProfilesStruct[i].BsfInfo.Ipv6PrefixRanges)[j]).Start, 10) - ((nfProfilesStruct[i].BsfInfo.Ipv6PrefixRanges)[j]).Start = nrf_context.Ipv6IntToIpv6String(ipv6IntStart) + ipv6IntStart.SetString(((nfProfile.BsfInfo.Ipv6PrefixRanges)[prefixRange]).Start, 10) + ((nfProfile.BsfInfo.Ipv6PrefixRanges)[prefixRange]).Start = nrf_context.Ipv6IntToIpv6String(ipv6IntStart) ipv6IntEnd := new(big.Int) - ipv6IntEnd.SetString(((nfProfilesStruct[i].BsfInfo.Ipv6PrefixRanges)[j]).End, 10) - ((nfProfilesStruct[i].BsfInfo.Ipv6PrefixRanges)[j]).End = nrf_context.Ipv6IntToIpv6String(ipv6IntEnd) + ipv6IntEnd.SetString(((nfProfile.BsfInfo.Ipv6PrefixRanges)[prefixRange]).End, 10) + ((nfProfile.BsfInfo.Ipv6PrefixRanges)[prefixRange]).End = nrf_context.Ipv6IntToIpv6String(ipv6IntEnd) } } } diff --git a/pkg/factory/config.go b/pkg/factory/config.go index 1f767ea..ed5c8f8 100644 --- a/pkg/factory/config.go +++ b/pkg/factory/config.go @@ -30,7 +30,7 @@ const ( NrfSbiDefaultScheme = "https" NrfNfmResUriPrefix = "/nnrf-nfm/v1" NrfDiscResUriPrefix = "/nnrf-disc/v1" - NrfBootstrappingPrefix = "/bootstrapping" + NrfBootstrappingPrefix = "/bootstrapping" ) type Config struct {