Skip to content

Commit

Permalink
Fix: Rebase & rollback config
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Dec 12, 2023
1 parent a2e86c1 commit 97a23bd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
15 changes: 5 additions & 10 deletions internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ func InitUdmContext(context *UDMContext) {
if configuration.NrfCertPem != "" {
context.NrfCertPem = configuration.NrfCertPem
}
servingNameList := configuration.ServiceNameList

serviceList := configuration.ServiceList
udmContext.SuciProfiles = configuration.SuciProfiles

udmContext.InitNFService(serviceList, config.Info.Version)
udmContext.InitNFService(servingNameList, config.Info.Version)
}

func (context *UDMContext) ManageSmData(smDatafromUDR []models.SessionManagementSubscriptionData, snssaiFromReq string,
Expand Down Expand Up @@ -455,15 +455,11 @@ func (context *UDMContext) GetSDMUri() string {
return context.GetIPv4Uri() + factory.UdmSdmResUriPrefix
}

func (context *UDMContext) InitNFService(serviceList []factory.ServiceList, version string) {
func (context *UDMContext) InitNFService(serviceName []string, version string) {
tmpVersion := strings.Split(version, ".")
versionUri := "v" + tmpVersion[0]
for index, service := range serviceList {
name := models.ServiceName(service.ServiceName)
allowNfTypes := make([]models.NfType, len(service.AllowedNfTypes))
for idx, nf := range service.AllowedNfTypes {
allowNfTypes[idx] = models.NfType(nf)
}
for index, nameString := range serviceName {
name := models.ServiceName(nameString)
context.NfService[name] = models.NfService{
ServiceInstanceId: strconv.Itoa(index),
ServiceName: name,
Expand All @@ -483,7 +479,6 @@ func (context *UDMContext) InitNFService(serviceList []factory.ServiceList, vers
Port: int32(context.SBIPort),
},
},
AllowedNfTypes: allowNfTypes,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/util/init_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func InitUDMContext(udmContext *context.UDMContext) {
}
}
udmContext.NrfUri = configuration.NrfUri
serviceList := configuration.ServiceList
servingNameList := configuration.ServiceNameList

udmContext.SuciProfiles = configuration.SuciProfiles

udmContext.InitNFService(serviceList, config.Info.Version)
udmContext.InitNFService(servingNameList, config.Info.Version)
}
2 changes: 1 addition & 1 deletion internal/util/nf_authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func AuthorizationCheck(c *gin.Context, serviceName string) error {
if udm_context.GetSelf().OAuth2Required {
oauth_err := oauth.VerifyOAuth(c.Request.Header.Get("Authorization"), serviceName,
udm_context.GetSelf().NrfCerPem)
udm_context.GetSelf().NrfCertPem)
if oauth_err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": oauth_err.Error()})
return oauth_err
Expand Down
10 changes: 2 additions & 8 deletions pkg/factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ type Info struct {
Description string `yaml:"description,omitempty" valid:"type(string)"`
}

type ServiceList struct {
ServiceName string `yaml:"serviceName" valid:"required"`
AllowedNfTypes []string `yaml:"allowedNfTypes,omitempty" valid:"optional"`
}

type Configuration struct {
Sbi *Sbi `yaml:"sbi,omitempty" valid:"required"`
ServiceNameList []string `yaml:"serviceNameList,omitempty" valid:"required"`
Expand All @@ -83,10 +78,9 @@ func (c *Configuration) validate() (bool, error) {
}
}

if c.ServiceList != nil {
if c.ServiceNameList != nil {
var errs govalidator.Errors
for _, service := range c.ServiceList {
v := service.ServiceName
for _, v := range c.ServiceNameList {
if v != "nudm-sdm" && v != "nudm-uecm" && v != "nudm-ueau" && v != "nudm-ee" && v != "nudm-pp" {
err := fmt.Errorf("Invalid ServiceNameList: [%s],"+
" value should be nudm-sdm or nudm-uecm or nudm-ueau or nudm-ee or nudm-pp", v)
Expand Down

0 comments on commit 97a23bd

Please sign in to comment.