Skip to content

Commit

Permalink
chore: Adds lint checks (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
gruyaume authored Jan 5, 2024
1 parent b4b1e4b commit 21056df
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
7 changes: 3 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,11 @@ linters:
# Additional
# - lll
- godox
#- gomnd
#- goconst
- gomnd
- goconst
# - gocognit
# - maligned
# - nestif
# - gomodguard
- gomodguard
- nakedret
# - gci
- misspell
Expand Down
3 changes: 2 additions & 1 deletion consumer/nf_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ var SendRegisterNFInstance = func(nrfUri, nfInstanceId string, profile models.Nf
configuration := Nnrf_NFManagement.NewConfiguration()
configuration.SetBasePath(nrfUri)
apiClient := Nnrf_NFManagement.NewAPIClient(configuration)
var waitTime time.Duration = 2

var res *http.Response
for {
prof, res, err = apiClient.NFInstanceIDDocumentApi.RegisterNFInstance(context.TODO(), nfInstanceId, profile)
if err != nil || res == nil {
// TODO : add log
logger.ConsumerLog.Errorf("NSSF register to NRF Error[%s]", err.Error())
time.Sleep(2 * time.Second)
time.Sleep(waitTime * time.Second)
continue
}
defer func() {
Expand Down
6 changes: 4 additions & 2 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (

var nssfContext = NSSFContext{}

const port int = 29510

// Initialize NSSF context with default value
func init() {
nssfContext.NfId = uuid.New().String()
Expand All @@ -43,7 +45,7 @@ func init() {
}
nssfContext.NfService = initNfService(serviceName, "1.0.0")

nssfContext.NrfUri = fmt.Sprintf("%s://%s:%d", models.UriScheme_HTTPS, nssfContext.RegisterIPv4, 29510)
nssfContext.NrfUri = fmt.Sprintf("%s://%s:%d", models.UriScheme_HTTPS, nssfContext.RegisterIPv4, port)
}

type NSSFContext struct {
Expand Down Expand Up @@ -91,7 +93,7 @@ func InitNssfContext() {
nssfContext.NrfUri = nssfConfig.Configuration.NrfUri
} else {
logger.InitLog.Warn("NRF Uri is empty! Using localhost as NRF IPv4 address.")
nssfContext.NrfUri = fmt.Sprintf("%s://%s:%d", nssfContext.UriScheme, "127.0.0.1", 29510)
nssfContext.NrfUri = fmt.Sprintf("%s://%s:%d", nssfContext.UriScheme, "127.0.0.1", port)
}

nssfContext.SupportedPlmnList = nssfConfig.Configuration.SupportedPlmnList
Expand Down
5 changes: 3 additions & 2 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ func (nssf *NSSF) Exec(c *cli.Context) error {
initLog.Fatalln(err)
}
wg := sync.WaitGroup{}
wg.Add(3)
goRoutines := 3
wg.Add(goRoutines)
go func() {
in := bufio.NewScanner(stdout)
for in.Scan() {
Expand Down Expand Up @@ -311,7 +312,7 @@ func (nssf *NSSF) UpdateNF() {
if problemDetails != nil {
initLog.Errorf("NSSF update to NRF ProblemDetails[%v]", problemDetails)
//5xx response from NRF, 404 Not Found, 400 Bad Request
if (problemDetails.Status/100) == 5 ||
if (problemDetails.Status >= 500 && problemDetails.Status <= 599) ||
problemDetails.Status == 404 || problemDetails.Status == 400 {
//register with NRF full profile
nfProfile, err = nssf.BuildAndSendRegisterNFInstance()
Expand Down
3 changes: 2 additions & 1 deletion util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,11 @@ func FindMappingWithHomeSnssai(snssai models.Snssai, mappings []models.MappingOf
func AddAllowedSnssai(allowedSnssai models.AllowedSnssai, accessType models.AccessType,
authorizedNetworkSliceInfo *models.AuthorizedNetworkSliceInfo) {
hitAllowedNssai := false
allowedNssaiNum := 8
for i := range authorizedNetworkSliceInfo.AllowedNssaiList {
if authorizedNetworkSliceInfo.AllowedNssaiList[i].AccessType == accessType {
hitAllowedNssai = true
if len(authorizedNetworkSliceInfo.AllowedNssaiList[i].AllowedSnssaiList) == 8 {
if len(authorizedNetworkSliceInfo.AllowedNssaiList[i].AllowedSnssaiList) == allowedNssaiNum {
logger.Util.Infof("Unable to add a new Allowed S-NSSAI since already eight S-NSSAIs in Allowed NSSAI")
} else {
authorizedNetworkSliceInfo.AllowedNssaiList[i].AllowedSnssaiList =
Expand Down

0 comments on commit 21056df

Please sign in to comment.