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

refactor: App, Server, Processor, Consumer #26

Merged
merged 22 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
package main

import (
"context"
"fmt"
"os"
"os/signal"
"path/filepath"
"runtime/debug"
"syscall"

"github.com/urfave/cli"

Expand Down Expand Up @@ -64,19 +67,32 @@ func action(cliCtx *cli.Context) error {
logger.MainLog.Infoln(cliCtx.App.Name)
logger.MainLog.Infoln("PCF version: ", version.GetVersion())

ctx, cancel := context.WithCancel(context.Background())
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM)

go func() {
<-sigCh // Wait for interrupt signal to gracefully shutdown UPF
cancel() // Notify each goroutine and wait them stopped
}()

cfg, err := factory.ReadConfig(cliCtx.String("config"))
if err != nil {
sigCh <- nil
return err
}
factory.PcfConfig = cfg

pcf, err := service.NewApp(cfg)
pcf, err := service.NewApp(ctx, cfg, tlsKeyLogPath)
if err != nil {
sigCh <- nil
return err
}
PCF = pcf

pcf.Start(tlsKeyLogPath)
if pcf == nil {
logger.MainLog.Infoln("pcf is nil")
}
pcf.Start()

return nil
}
Expand Down
9 changes: 2 additions & 7 deletions internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type NFContext interface {

var _ NFContext = &PCFContext{}

func InitpcfContext(context *PCFContext) {
func InitPcfContext(context *PCFContext) {
config := factory.PcfConfig
logger.UtilLog.Infof("pcfconfig Info: Version[%s] Description[%s]", config.Info.Version, config.Info.Description)
configuration := config.Configuration
Expand Down Expand Up @@ -157,7 +157,7 @@ func Init() {
pcfContext.PcfSuppFeats = make(map[models.ServiceName]openapi.SupportedFeature)
pcfContext.BdtPolicyIDGenerator = idgenerator.NewGenerator(1, math.MaxInt64)
pcfContext.RatingGroupIdGenerator = idgenerator.NewGenerator(1, math.MaxInt64)
InitpcfContext(&pcfContext)
InitPcfContext(&pcfContext)
}

// Create new PCF context
Expand Down Expand Up @@ -458,11 +458,6 @@ func (c *PCFContext) AuthorizationCheck(token string, serviceName models.Service
logger.UtilLog.Debugf("PCFContext::AuthorizationCheck: OAuth2 not required\n")
return nil
}
// TODO: free5gc webconsole uses npcf-oam but it can't get token since it's not an NF.
if serviceName == models.ServiceName_NPCF_OAM {
logger.UtilLog.Warnf("OAuth2 is enable but namf-oam didn't check token now.")
return nil
}

logger.UtilLog.Debugf("PCFContext::AuthorizationCheck: token[%s] serviceName[%s]\n", token, serviceName)
return oauth.VerifyOAuth(token, string(serviceName), c.NrfCertPem)
Expand Down
2 changes: 2 additions & 0 deletions internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var (
CfgLog *logrus.Entry
CtxLog *logrus.Entry
GinLog *logrus.Entry
SBILog *logrus.Entry
AmPolicyLog *logrus.Entry
BdtPolicyLog *logrus.Entry
ConsumerLog *logrus.Entry
Expand All @@ -38,6 +39,7 @@ func init() {
CfgLog = NfLog.WithField(logger_util.FieldCategory, "CFG")
CtxLog = NfLog.WithField(logger_util.FieldCategory, "CTX")
GinLog = NfLog.WithField(logger_util.FieldCategory, "GIN")
SBILog = NfLog.WithField(logger_util.FieldCategory, "SBI")
AmPolicyLog = NfLog.WithField(logger_util.FieldCategory, "AmPol")
BdtPolicyLog = NfLog.WithField(logger_util.FieldCategory, "BdtPol")
ConsumerLog = NfLog.WithField(logger_util.FieldCategory, "Consumer")
Expand Down
173 changes: 0 additions & 173 deletions internal/sbi/ampolicy/api_default.go

This file was deleted.

113 changes: 0 additions & 113 deletions internal/sbi/ampolicy/routers.go

This file was deleted.

Loading
Loading