Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/gin-gonic/g…
Browse files Browse the repository at this point in the history
…in-1.9.1
  • Loading branch information
tim-ywliu committed Oct 1, 2023
2 parents f7267e6 + f627355 commit 963d731
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.17', '1.18' ]
go: [ '1.18' ]
steps:
- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.17', '1.18' ]
go: [ '1.18' ]
steps:
- name: Set up Go
uses: actions/setup-go@v3
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.17
require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/evanphx/json-patch v0.5.2
github.com/free5gc/openapi v1.0.6
github.com/free5gc/util v1.0.5-0.20230511064842-2e120956883b
github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293
github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef
github.com/gin-gonic/gin v1.9.1
github.com/google/uuid v1.3.0
github.com/mitchellh/mapstructure v1.4.3
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k=
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
github.com/free5gc/openapi v1.0.6 h1:ytRjU/YZRI8UhKKyfajXSyGB6s1YDFkJ1weeAGJ8LXw=
github.com/free5gc/openapi v1.0.6/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI=
github.com/free5gc/util v1.0.5-0.20230511064842-2e120956883b h1:XMw3j+4AEXLeL/uyiZ7/qYE1X7Ul05RTwWBhzxCLi+0=
github.com/free5gc/util v1.0.5-0.20230511064842-2e120956883b/go.mod h1:l2Jrml4vojDomW5jdDJhIS60KdbrE9uPYhyAq/7OnF4=
github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293 h1:BSIvKCYu7646sE8J9R1L8v2R435otUik3wOFN33csfs=
github.com/free5gc/openapi v1.0.7-0.20230802173229-2b3ded4db293/go.mod h1:iw/N0E+FlX44EEx24IBi2EdZW8v+bkj3ETWPGnlK9DI=
github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef h1:ne0EMnst7wbLoaY2Uvn/2Kvp/KkXKMQJcaIJQKFe+a4=
github.com/free5gc/util v1.0.5-0.20230823103219-e511c4fd20ef/go.mod h1:l2Jrml4vojDomW5jdDJhIS60KdbrE9uPYhyAq/7OnF4=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
Expand Down
65 changes: 53 additions & 12 deletions internal/sbi/producer/data_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ func getDataFromDB(collName string, filter bson.M) (map[string]interface{}, *mod
return data, nil
}

func getDataFromDBWithArg(collName string, filter bson.M, strength int) (
map[string]interface{}, *models.ProblemDetails,
) {
data, err := mongoapi.RestfulAPIGetOneWithArg(collName, filter, strength)
if err != nil {
return nil, openapi.ProblemDetailsSystemFailure(err.Error())
}
if data == nil {
logger.ConsumerLog.Errorln("filter: ", filter)
return nil, util.ProblemDetailsNotFound("DATA_NOT_FOUND")
}

return data, nil
}

func deleteDataFromDB(collName string, filter bson.M) {
if err := mongoapi.RestfulAPIDeleteOne(collName, filter); err != nil {
logger.DataRepoLog.Errorf("deleteDataFromDB: %+v", err)
Expand Down Expand Up @@ -1436,19 +1451,43 @@ func PolicyDataUesUeIdSmDataGetProcedure(collName string, ueId string, snssai mo
) (*models.SmPolicyData, *models.ProblemDetails) {
filter := bson.M{"ueId": ueId}

if !reflect.DeepEqual(snssai, models.Snssai{}) {
filter["smPolicySnssaiData."+util.SnssaiModelsToHex(snssai)] = bson.M{"$exists": true}
}
if !reflect.DeepEqual(snssai, models.Snssai{}) && dnn != "" {
dnnKey := util.EscapeDnn(dnn)
filter["smPolicySnssaiData."+util.SnssaiModelsToHex(snssai)+".smPolicyDnnData."+dnnKey] = bson.M{"$exists": true}
}

smPolicyData, pd := getDataFromDB(collName, filter)
smPolicyData, pd := getDataFromDBWithArg(collName, filter, mongoapi.COLLATION_STRENGTH_IGNORE_CASE)
if pd != nil {
return nil, pd
}

hex_snssai := util.SnssaiModelsToHex(snssai)
found := false
smPolicySnssaiDatas, ok := smPolicyData["smPolicySnssaiData"].(map[string]interface{})
if !ok {
return nil, util.ProblemDetailsNotFound("DATA_NOT_FOUND")
}
for snssai, v := range smPolicySnssaiDatas {
if !strings.EqualFold(snssai, hex_snssai) {
continue
}
smPolicySnssaiData, ok := v.(map[string]interface{})
if !ok {
break
}
smPolicyDnnDatas, ok := smPolicySnssaiData["smPolicyDnnData"].(map[string]interface{})
if !ok {
break
}
for dnn := range smPolicyDnnDatas {
if strings.EqualFold(dnn, util.EscapeDnn(dnn)) {
found = true
break
}
}
if found {
break
}
}
if !found {
return nil, util.ProblemDetailsNotFound("DATA_NOT_FOUND")
}

var smPolicyDataResp models.SmPolicyData
err := json.Unmarshal(util.MapToByte(smPolicyData), &smPolicyDataResp)
if err != nil {
Expand Down Expand Up @@ -2402,7 +2441,8 @@ func QueryProvisionedDataProcedure(ueId string, servingPlmnId string,

collName = "subscriptionData.provisionedData.smData"
filter = bson.M{"ueId": ueId, "servingPlmnId": servingPlmnId}
sessionManagementSubscriptionDatas, err := mongoapi.RestfulAPIGetMany(collName, filter)
sessionManagementSubscriptionDatas, err := mongoapi.
RestfulAPIGetManyWithArg(collName, filter, mongoapi.COLLATION_STRENGTH_IGNORE_CASE)
if err != nil {
logger.DataRepoLog.Errorf("QueryProvisionedDataProcedure get sessionManagementSubscriptionDatas err: %+v", err)
return nil, openapi.ProblemDetailsSystemFailure(err.Error())
Expand Down Expand Up @@ -2776,7 +2816,8 @@ func QuerySmDataProcedure(collName string, ueId string, servingPlmnId string,
filter["dnnConfigurations."+dnnKey] = bson.M{"$exists": true}
}

sessionManagementSubscriptionDatas, err := mongoapi.RestfulAPIGetMany(collName, filter)
sessionManagementSubscriptionDatas, err := mongoapi.
RestfulAPIGetManyWithArg(collName, filter, mongoapi.COLLATION_STRENGTH_IGNORE_CASE)
if err != nil {
logger.DataRepoLog.Errorf("QuerySmDataProcedure err: %+v", err)
return nil
Expand Down Expand Up @@ -2913,7 +2954,7 @@ func HandleQuerySmfRegList(request *httpwrapper.Request) *httpwrapper.Response {

func QuerySmfRegListProcedure(collName string, ueId string) *[]map[string]interface{} {
filter := bson.M{"ueId": ueId}
smfRegList, err := mongoapi.RestfulAPIGetMany(collName, filter)
smfRegList, err := mongoapi.RestfulAPIGetManyWithArg(collName, filter, mongoapi.COLLATION_STRENGTH_IGNORE_CASE)
if err != nil {
logger.DataRepoLog.Errorf("QuerySmfRegListProcedure err: %+v", err)
return nil
Expand Down

0 comments on commit 963d731

Please sign in to comment.