Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-functional linting warnings #131

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,35 +239,35 @@ linters-settings:
linters:
enable:
- gofmt
- govet
- errcheck
- staticcheck
- unused
- gosimple
- structcheck
# - govet
# - errcheck
# - staticcheck
# - unused
# - gosimple
# - structcheck
- varcheck
- ineffassign
- deadcode
# - deadcode
- typecheck
# Additional
- lll
# - lll
- godox
#- gomnd
#- goconst
# - gocognit
# - maligned
# - nestif
# - gomodguard
- nakedret
# - nakedret
- gci
- misspell
- gofumpt
- whitespace
- unconvert
# - unconvert
- predeclared
- noctx
- dogsled
- bodyclose
# - bodyclose
- asciicheck
#- stylecheck
# - unparam
Expand Down
5 changes: 2 additions & 3 deletions amf.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import (
"fmt"
"os"

"github.com/sirupsen/logrus"
"github.com/urfave/cli"

"github.com/omec-project/amf/logger"
"github.com/omec-project/amf/service"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)

var AMF = &service.AMF{}
Expand Down
4 changes: 2 additions & 2 deletions amf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ func TestUpdateConfig(t *testing.T) {
func TestRegisterNF(t *testing.T) {
// Save current function and restore at the end:
origRegisterNFInstance := consumer.SendRegisterNFInstance
//origSearchNFInstances := consumer.SendSearchNFInstances
// origSearchNFInstances := consumer.SendSearchNFInstances
origUpdateNFInstance := consumer.SendUpdateNFInstance
defer func() {
consumer.SendRegisterNFInstance = origRegisterNFInstance
//consumer.SendSearchNFInstances = origSearchNFInstances
// consumer.SendSearchNFInstances = origSearchNFInstances
consumer.SendUpdateNFInstance = origUpdateNFInstance
}()
fmt.Printf("test case TestRegisterNF \n")
Expand Down
3 changes: 2 additions & 1 deletion consumer/am_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func AMPolicyControlCreate(ue *amf_context.AmfUe, anType models.AccessType) (*mo
}

func AMPolicyControlUpdate(ue *amf_context.AmfUe, updateRequest models.PolicyAssociationUpdateRequest) (
problemDetails *models.ProblemDetails, err error) {
problemDetails *models.ProblemDetails, err error,
) {
configuration := Npcf_AMPolicy.NewConfiguration()
configuration.SetBasePath(ue.PcfUri)
client := Npcf_AMPolicy.NewAPIClient(configuration)
Expand Down
18 changes: 11 additions & 7 deletions consumer/communication.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (

func BuildUeContextCreateData(ue *amf_context.AmfUe, targetRanId models.NgRanTargetId,
sourceToTargetData models.N2InfoContent, pduSessionList []models.N2SmInformation,
n2NotifyUri string, ngapCause *models.NgApCause) models.UeContextCreateData {
n2NotifyUri string, ngapCause *models.NgApCause,
) models.UeContextCreateData {
var ueContextCreateData models.UeContextCreateData

ueContext := BuildUeContextModel(ue)
Expand Down Expand Up @@ -121,7 +122,8 @@ func buildAmPolicyReqTriggers(triggers []models.RequestTrigger) (amPolicyReqTrig
}

func CreateUEContextRequest(ue *amf_context.AmfUe, ueContextCreateData models.UeContextCreateData) (
ueContextCreatedData *models.UeContextCreatedData, problemDetails *models.ProblemDetails, err error) {
ueContextCreatedData *models.UeContextCreatedData, problemDetails *models.ProblemDetails, err error,
) {
configuration := Namf_Communication.NewConfiguration()
configuration.SetBasePath(ue.TargetAmfUri)
client := Namf_Communication.NewAPIClient(configuration)
Expand Down Expand Up @@ -150,7 +152,8 @@ func CreateUEContextRequest(ue *amf_context.AmfUe, ueContextCreateData models.Ue
}

func ReleaseUEContextRequest(ue *amf_context.AmfUe, ngapCause models.NgApCause) (
problemDetails *models.ProblemDetails, err error) {
problemDetails *models.ProblemDetails, err error,
) {
configuration := Namf_Communication.NewConfiguration()
configuration.SetBasePath(ue.TargetAmfUri)
client := Namf_Communication.NewAPIClient(configuration)
Expand Down Expand Up @@ -192,7 +195,8 @@ func ReleaseUEContextRequest(ue *amf_context.AmfUe, ngapCause models.NgApCause)

func UEContextTransferRequest(
ue *amf_context.AmfUe, accessType models.AccessType, transferReason models.TransferReason) (
ueContextTransferRspData *models.UeContextTransferRspData, problemDetails *models.ProblemDetails, err error) {
ueContextTransferRspData *models.UeContextTransferRspData, problemDetails *models.ProblemDetails, err error,
) {
configuration := Namf_Communication.NewConfiguration()
configuration.SetBasePath(ue.TargetAmfUri)
client := Namf_Communication.NewAPIClient(configuration)
Expand Down Expand Up @@ -241,16 +245,16 @@ func UEContextTransferRequest(

// This operation is called "RegistrationCompleteNotify" at TS 23.502
func RegistrationStatusUpdate(ue *amf_context.AmfUe, request models.UeRegStatusUpdateReqData) (
regStatusTransferComplete bool, problemDetails *models.ProblemDetails, err error) {
regStatusTransferComplete bool, problemDetails *models.ProblemDetails, err error,
) {
configuration := Namf_Communication.NewConfiguration()
configuration.SetBasePath(ue.TargetAmfUri)
client := Namf_Communication.NewAPIClient(configuration)

ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
defer cancel()
ueContextId := fmt.Sprintf("5g-guti-%s", ue.Guti)
res, httpResp, localErr :=
client.IndividualUeContextDocumentApi.RegistrationStatusUpdate(ctx, ueContextId, request)
res, httpResp, localErr := client.IndividualUeContextDocumentApi.RegistrationStatusUpdate(ctx, ueContextId, request)
if localErr == nil {
regStatusTransferComplete = res.RegStatusTransferComplete
} else if httpResp != nil {
Expand Down
19 changes: 11 additions & 8 deletions consumer/nf_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ import (
"fmt"
"net/http"

nrf_cache "github.com/omec-project/nrf/nrfcache"

amf_context "github.com/omec-project/amf/context"
"github.com/omec-project/amf/logger"
"github.com/omec-project/amf/util"
nrf_cache "github.com/omec-project/nrf/nrfcache"
"github.com/omec-project/openapi/Nnrf_NFDiscovery"
"github.com/omec-project/openapi/models"
)

func SendSearchNFInstances(nrfUri string, targetNfType, requestNfType models.NfType,
param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) (models.SearchResult, error) {

param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts,
) (models.SearchResult, error) {
if amf_context.AMF_Self().EnableNrfCaching {
return nrf_cache.SearchNFInstances(nrfUri, targetNfType, requestNfType, param)
} else {
Expand All @@ -30,7 +29,8 @@ func SendSearchNFInstances(nrfUri string, targetNfType, requestNfType models.NfT
}

func SendNfDiscoveryToNrf(nrfUri string, targetNfType, requestNfType models.NfType,
param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) (models.SearchResult, error) {
param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts,
) (models.SearchResult, error) {
// Set client and set url
configuration := Nnrf_NFDiscovery.NewConfiguration()
configuration.SetBasePath(nrfUri)
Expand Down Expand Up @@ -70,7 +70,8 @@ func SendNfDiscoveryToNrf(nrfUri string, targetNfType, requestNfType models.NfTy
}

func SearchUdmSdmInstance(ue *amf_context.AmfUe, nrfUri string, targetNfType, requestNfType models.NfType,
param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) error {
param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts,
) error {
resp, localErr := SendSearchNFInstances(nrfUri, targetNfType, requestNfType, param)
if localErr != nil {
return localErr
Expand All @@ -95,7 +96,8 @@ func SearchUdmSdmInstance(ue *amf_context.AmfUe, nrfUri string, targetNfType, re
}

func SearchNssfNSSelectionInstance(ue *amf_context.AmfUe, nrfUri string, targetNfType, requestNfType models.NfType,
param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) error {
param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts,
) error {
resp, localErr := SendSearchNFInstances(nrfUri, targetNfType, requestNfType, param)
if localErr != nil {
return localErr
Expand All @@ -118,7 +120,8 @@ func SearchNssfNSSelectionInstance(ue *amf_context.AmfUe, nrfUri string, targetN
}

func SearchAmfCommunicationInstance(ue *amf_context.AmfUe, nrfUri string, targetNfType,
requestNfType models.NfType, param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts) (err error) {
requestNfType models.NfType, param *Nnrf_NFDiscovery.SearchNFInstancesParamOpts,
) (err error) {
resp, localErr := SendSearchNFInstances(nrfUri, targetNfType, requestNfType, param)
if localErr != nil {
err = localErr
Expand Down
6 changes: 3 additions & 3 deletions consumer/nf_mangement.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ func BuildNFInstance(context *amf_context.AMFContext) (profile models.NfProfile,
NotificationType: models.NotificationType_N1_MESSAGES,
N1MessageClass: models.N1MessageClass__5_GMM,
}
profile.DefaultNotificationSubscriptions =
append(profile.DefaultNotificationSubscriptions, defaultNotificationSubscription)
profile.DefaultNotificationSubscriptions = append(profile.DefaultNotificationSubscriptions, defaultNotificationSubscription)
return profile, err
}

var SendRegisterNFInstance = func(nrfUri, nfInstanceId string, profile models.NfProfile) (
prof models.NfProfile, resouceNrfUri string, retrieveNfInstanceId string, err error) {
prof models.NfProfile, resouceNrfUri string, retrieveNfInstanceId string, err error,
) {
// Set client and set url
configuration := Nnrf_NFManagement.NewConfiguration()
configuration.SetBasePath(nrfUri)
Expand Down
7 changes: 4 additions & 3 deletions consumer/nsselection.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/antihax/optional"

amf_context "github.com/omec-project/amf/context"
"github.com/omec-project/amf/logger"
"github.com/omec-project/openapi"
Expand All @@ -21,7 +20,8 @@ import (
)

func NSSelectionGetForRegistration(ue *amf_context.AmfUe, requestedNssai []models.MappingOfSnssai) (
*models.ProblemDetails, error) {
*models.ProblemDetails, error,
) {
configuration := Nnssf_NSSelection.NewConfiguration()
configuration.SetBasePath(ue.NssfUri)
client := Nnssf_NSSelection.NewAPIClient(configuration)
Expand Down Expand Up @@ -71,7 +71,8 @@ func NSSelectionGetForRegistration(ue *amf_context.AmfUe, requestedNssai []model
}

func NSSelectionGetForPduSession(ue *amf_context.AmfUe, snssai models.Snssai) (
*models.AuthorizedNetworkSliceInfo, *models.ProblemDetails, error) {
*models.AuthorizedNetworkSliceInfo, *models.ProblemDetails, error,
) {
configuration := Nnssf_NSSelection.NewConfiguration()
configuration.SetBasePath(ue.NssfUri)
client := Nnssf_NSSelection.NewAPIClient(configuration)
Expand Down