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 path for configuration file, option(s) and Docker image #165

Merged
merged 3 commits into from
Nov 1, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

FROM golang:1.23.2-bookworm AS builder

LABEL maintainer="Aether SD-Core <dev@aetherproject.org>"

RUN apt-get update && \
apt-get -y install --no-install-recommends \
apt-transport-https \
Expand All @@ -28,7 +26,8 @@ RUN make all

FROM alpine:3.20 AS udm

LABEL description="ONF open source 5G Core Network" \
LABEL maintainer="Aether SD-Core <dev@list.aetherproject.org>" \
description="ONF open source 5G Core Network" \
version="Stage 3"

ARG DEBUG_TOOLS
Expand All @@ -38,8 +37,5 @@ RUN if [ "$DEBUG_TOOLS" = "true" ]; then \
apk update && apk add --no-cache -U vim strace net-tools curl netcat-openbsd bind-tools; \
fi

# Set working dir
WORKDIR /free5gc/udm

# Copy executable and default certs
COPY --from=builder /go/src/udm/bin/* .
# Copy executable
COPY --from=builder /go/src/udm/bin/* /usr/local/bin/.
1 change: 1 addition & 0 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Config struct {
Info *Info `yaml:"info"`
Configuration *Configuration `yaml:"configuration"`
Logger *logger.Logger `yaml:"logger"`
CfgLocation string
}

type Info struct {
Expand Down
6 changes: 3 additions & 3 deletions factory/udmcfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ configuration:
registerIPv4: 1.1.1.1
scheme: https
tls:
key: free5gc/support/TLS/udm.key
log: free5gc/udmsslkey.log
pem: free5gc/support/TLS/udm.pem
log: /opt/sslkey.log
key: /var/run/certs/tls.key
pem: /var/run/certs/tls.pem
serviceList:
- nudm-sdm
- nudm-uecm
Expand Down
81 changes: 0 additions & 81 deletions parameterprovision/api_subscription_data_update_test.go

This file was deleted.

48 changes: 19 additions & 29 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"os/exec"
"os/signal"
"path/filepath"
"sync"
"syscall"
"time"
Expand All @@ -36,7 +37,6 @@ import (
"github.com/omec-project/udm/util"
"github.com/omec-project/util/http2_util"
utilLogger "github.com/omec-project/util/logger"
"github.com/omec-project/util/path_util"
"github.com/urfave/cli"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand All @@ -53,20 +53,17 @@ func init() {
type (
// Config information.
Config struct {
udmcfg string
cfg string
}
)

var config Config

var udmCLi = []cli.Flag{
cli.StringFlag{
Name: "free5gccfg",
Usage: "common config file",
},
cli.StringFlag{
Name: "udmcfg",
Usage: "config file",
Name: "cfg",
Usage: "udm config file",
Required: true,
},
}

Expand All @@ -81,20 +78,21 @@ func (*UDM) GetCliCmd() (flags []cli.Flag) {

func (udm *UDM) Initialize(c *cli.Context) error {
config = Config{
udmcfg: c.String("udmcfg"),
cfg: c.String("cfg"),
}

if config.udmcfg != "" {
if err := factory.InitConfigFactory(config.udmcfg); err != nil {
return err
}
} else {
DefaultUdmConfigPath := path_util.Free5gcPath("free5gc/config/udmcfg.yaml")
if err := factory.InitConfigFactory(DefaultUdmConfigPath); err != nil {
return err
}
absPath, err := filepath.Abs(config.cfg)
if err != nil {
logger.CfgLog.Errorln(err)
return err
}

if err := factory.InitConfigFactory(absPath); err != nil {
return err
}

factory.UdmConfig.CfgLocation = absPath

udm.setLogLevel()

if err := factory.CheckConfigVersion(); err != nil {
Expand Down Expand Up @@ -224,15 +222,6 @@ func (udm *UDM) Start() {

go metrics.InitMetrics()

udmLogPath := path_util.Free5gcPath("omec-project/udmsslkey.log")
udmPemPath := path_util.Free5gcPath("free5gc/support/TLS/udm.pem")
udmKeyPath := path_util.Free5gcPath("free5gc/support/TLS/udm.key")
if sbi.Tls != nil {
udmLogPath = path_util.Free5gcPath(sbi.Tls.Log)
udmPemPath = sbi.Tls.Pem
udmKeyPath = sbi.Tls.Key
}

self := context.UDM_Self()
util.InitUDMContext(self)
context.UDM_Self().InitNFService(serviceName, config.Info.Version)
Expand All @@ -252,7 +241,8 @@ func (udm *UDM) Start() {
os.Exit(0)
}()

server, err := http2_util.NewServer(addr, udmLogPath, router)
sslLog := filepath.Dir(factory.UdmConfig.CfgLocation) + "/sslkey.log"
server, err := http2_util.NewServer(addr, sslLog, router)
if server == nil {
logger.InitLog.Errorf("initialize HTTP server failed: %+v", err)
return
Expand All @@ -266,7 +256,7 @@ func (udm *UDM) Start() {
if serverScheme == "http" {
err = server.ListenAndServe()
} else if serverScheme == "https" {
err = server.ListenAndServeTLS(udmPemPath, udmKeyPath)
err = server.ListenAndServeTLS(sbi.Tls.Pem, sbi.Tls.Key)
}

if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions udm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ func main() {
app := cli.NewApp()
app.Name = "udm"
logger.AppLog.Infoln(app.Name)
app.Usage = "-free5gccfg common configuration file -udmcfg udm configuration file"
app.Usage = "Unified Data Management"
app.UsageText = "udm -cfg <udm_config_file.conf>"
app.Action = action
app.Flags = UDM.GetCliCmd()
if err := app.Run(os.Args); err != nil {
logger.AppLog.Errorf("udm run error: %v", err)
logger.AppLog.Fatalf("UDM run error: %v", err)
}
}

Expand Down