Skip to content

Commit

Permalink
chore: Adds go vet analyzers in CI (#47)
Browse files Browse the repository at this point in the history
* Enable go vet checks in CI

Signed-off-by: Patricia Reinoso <[email protected]>

* Enable fieldalignment go vet check

Signed-off-by: Patricia Reinoso <[email protected]>

* Fix nilness go vet check

Signed-off-by: Patricia Reinoso <[email protected]>

* Update context/context.go

Co-authored-by: gab-arrobo <[email protected]>

* apply gofmt to context.go file

---------

Signed-off-by: Patricia Reinoso <[email protected]>
Co-authored-by: gab-arrobo <[email protected]>
  • Loading branch information
patriciareinoso and gab-arrobo authored Jan 15, 2024
1 parent 73984f3 commit 6412402
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 33 deletions.
9 changes: 2 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,8 @@ linters-settings:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
# enable or disable analyzers by name
enable:
- atomicalign
enable-all: false
disable:
- shadow
disable-all: false
# enable all analyzers
enable-all: true
depguard:
list-type: blacklist
include-go-root: false
Expand Down
11 changes: 5 additions & 6 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@ func init() {
}

type NSSFContext struct {
NfId string
Name string
UriScheme models.UriScheme
RegisterIPv4 string
// HttpIpv6Address string
NfId string
Name string
UriScheme models.UriScheme
RegisterIPv4 string
BindingIPv4 string
SBIPort int
NfService map[models.ServiceName]models.NfService
NrfUri string
SupportedPlmnList []models.PlmnId
SBIPort int
}

// Initialize NSSF context with configuration factory
Expand Down
4 changes: 2 additions & 2 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const (
type Config struct {
Info *Info `yaml:"info"`
Configuration *Configuration `yaml:"configuration"`
Subscriptions []Subscription `yaml:"subscriptions,omitempty"`
Logger *logger_util.Logger `yaml:"logger"`
Subscriptions []Subscription `yaml:"subscriptions,omitempty"`
}

type Info struct {
Expand Down Expand Up @@ -100,8 +100,8 @@ type MappingFromPlmnConfig struct {
}

type Subscription struct {
SubscriptionId string `yaml:"subscriptionId"`
SubscriptionData *models.NssfEventSubscriptionCreateData `yaml:"subscriptionData"`
SubscriptionId string `yaml:"subscriptionId"`
}

var ConfigPodTrigger chan bool
Expand Down
10 changes: 5 additions & 5 deletions producer/nssaiavailability_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NSSAIAvailabilityDeleteProcedure(nfId string) *models.ProblemDetails {
}
}

*problemDetails = models.ProblemDetails{
problemDetails = &models.ProblemDetails{
Title: util.UNSUPPORTED_RESOURCE,
Status: http.StatusNotFound,
Detail: fmt.Sprintf("AMF ID '%s' does not exist", nfId),
Expand Down Expand Up @@ -87,7 +87,7 @@ func NSSAIAvailabilityPatchProcedure(nssaiAvailabilityUpdateInfo plugin.PatchDoc
}
factory.ConfigLock.RUnlock()
if !hitAmf {
*problemDetails = models.ProblemDetails{
problemDetails = &models.ProblemDetails{
Title: util.UNSUPPORTED_RESOURCE,
Status: http.StatusNotFound,
Detail: fmt.Sprintf("AMF ID '%s' does not exist", nfId),
Expand All @@ -114,7 +114,7 @@ func NSSAIAvailabilityPatchProcedure(nssaiAvailabilityUpdateInfo plugin.PatchDoc

patch, err := jsonpatch.DecodePatch(patchJSON)
if err != nil {
*problemDetails = models.ProblemDetails{
problemDetails = &models.ProblemDetails{
Title: util.MALFORMED_REQUEST,
Status: http.StatusBadRequest,
Detail: err.Error(),
Expand All @@ -124,7 +124,7 @@ func NSSAIAvailabilityPatchProcedure(nssaiAvailabilityUpdateInfo plugin.PatchDoc

modified, err := patch.Apply(original)
if err != nil {
*problemDetails = models.ProblemDetails{
problemDetails = &models.ProblemDetails{
Title: util.INVALID_REQUEST,
Status: http.StatusConflict,
Detail: err.Error(),
Expand All @@ -136,7 +136,7 @@ func NSSAIAvailabilityPatchProcedure(nssaiAvailabilityUpdateInfo plugin.PatchDoc
err = json.Unmarshal(modified, &factory.NssfConfig.Configuration.AmfList[amfIdx].SupportedNssaiAvailabilityData)
factory.ConfigLock.Unlock()
if err != nil {
*problemDetails = models.ProblemDetails{
problemDetails = &models.ProblemDetails{
Title: util.INVALID_REQUEST,
Status: http.StatusBadRequest,
Detail: err.Error(),
Expand Down
4 changes: 2 additions & 2 deletions producer/nssaiavailability_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NSSAIAvailabilityPostProcedure(createData models.NssfEventSubscriptionCreat
if err != nil {
logger.Nssaiavailability.Warnf(err.Error())

*problemDetails = models.ProblemDetails{
problemDetails = &models.ProblemDetails{
Title: util.UNSUPPORTED_RESOURCE,
Status: http.StatusNotFound,
Detail: err.Error(),
Expand Down Expand Up @@ -99,7 +99,7 @@ func NSSAIAvailabilityUnsubscribeProcedure(subscriptionId string) *models.Proble
}

// No specific subscription ID exists
*problemDetails = models.ProblemDetails{
problemDetails = &models.ProblemDetails{
Title: util.UNSUPPORTED_RESOURCE,
Status: http.StatusNotFound,
Detail: fmt.Sprintf("Subscription ID '%s' is not available", subscriptionId),
Expand Down
15 changes: 8 additions & 7 deletions producer/subscription_id_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/omec-project/http_wrapper"
"github.com/omec-project/nssf/logger"
"github.com/omec-project/openapi/models"
"reflect"
)

// HandleNSSAIAvailabilityUnsubscribe - Deletes an already existing NSSAI availability notification subscription
Expand All @@ -32,12 +33,12 @@ func HandleNSSAIAvailabilityUnsubscribe(request *http_wrapper.Request) *http_wra

if problemDetails == nil {
return http_wrapper.NewResponse(http.StatusNoContent, nil, nil)
} else if problemDetails != nil {
return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails)
} else if reflect.DeepEqual(*problemDetails, models.ProblemDetails{}) {
problemDetails = &models.ProblemDetails{
Status: http.StatusForbidden,
Cause: "UNSPECIFIED",
}
return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails)
}
problemDetails = &models.ProblemDetails{
Status: http.StatusForbidden,
Cause: "UNSPECIFIED",
}
return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails)
return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails)
}
6 changes: 2 additions & 4 deletions test/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ type TestingUtil struct {
}

type TestingNsselection struct {
ConfigFile string

GenerateNonRoamingQueryParameter func() NsselectionQueryParameter

GenerateRoamingQueryParameter func() NsselectionQueryParameter
GenerateRoamingQueryParameter func() NsselectionQueryParameter
ConfigFile string
}

type TestingNssaiavailability struct {
Expand Down

0 comments on commit 6412402

Please sign in to comment.