Skip to content

Commit

Permalink
Merge branch 'omec-project:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mbilal92 authored Dec 12, 2024
2 parents 9a40658 + f5f3bb3 commit 9d87c07
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 227 deletions.
20 changes: 0 additions & 20 deletions .fossa.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- uses: actions/checkout@v4

- name: reuse lint
uses: fsfe/reuse-action@v4
uses: fsfe/reuse-action@v5

fossa-check:
runs-on: ubuntu-latest
Expand Down
44 changes: 16 additions & 28 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-FileCopyrightText: 2024 Intel Corporation
# Copyright 2019 free5GC.org
#
# SPDX-License-Identifier: Apache-2.0
#

# This file contains all available configuration options
# with their default values.
Expand All @@ -27,19 +26,6 @@ run:
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-files:
- "api_.*\\.go$"
- "model_.*\\.go$"
- "routers.go"
- "client.go"
- "configuration.go"
- "nas.go"
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
Expand All @@ -55,7 +41,7 @@ run:
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
formats: colored-line-number
# print lines of code with issue, default is true
print-issued-lines: true
# print linter name in the end of issue text, default is true
Expand Down Expand Up @@ -138,13 +124,15 @@ linters-settings:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
gomnd:
settings:
mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks: argument,case,condition,operation,return,assign
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks:
- argument
- case
- condition
- operation
- return
- assign
govet:
# report about shadowed variables
check-shadowing: true
# settings per analyzer
settings:
printf: # analyzer name, run `go tool vet help` to see all analyzers
Expand Down Expand Up @@ -184,8 +172,6 @@ linters-settings:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
gci:
local-prefixes: "bitbucket.org"
misspell:
#locale: US
ignore-words:
Expand Down Expand Up @@ -242,9 +228,9 @@ linters:
- dogsled
# - bodyclose
- asciicheck
#- stylecheck
# - unparam
# - wsl
# - stylecheck
# - unparam
# - wsl

#disable-all: false
fast: true
Expand All @@ -255,6 +241,8 @@ issues:
# excluded by default patterns execute `golangci-lint run --help`
exclude:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-files:
- "routers.go"
exclude-rules:
# Exclude some linters from running on tests files.
# Independently from option `exclude` we use default exclude patterns,
Expand Down Expand Up @@ -303,5 +291,5 @@ severity:
# Only affects out formats that support setting severity information.
rules:
- linters:
- gomnd
- gomnd
severity: ignore
16 changes: 6 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# SPDX-License-Identifier: Apache-2.0
#

FROM golang:1.23.2-bookworm AS builder

LABEL maintainer="Aether SD-Core <[email protected]>"
FROM golang:1.23.4-bookworm AS builder

RUN apt-get update && \
apt-get -y install --no-install-recommends \
Expand All @@ -25,9 +23,10 @@ WORKDIR $GOPATH/src/ausf
COPY . .
RUN make all

FROM alpine:3.20 AS ausf
FROM alpine:3.21 AS ausf

LABEL description="ONF open source 5G Core Network" \
LABEL maintainer="Aether SD-Core <[email protected]>" \
description="ONF open source 5G Core Network" \
version="Stage 3"

ARG DEBUG_TOOLS
Expand All @@ -37,8 +36,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/ausf/

# Copy executable and default certs
COPY --from=builder /go/src/ausf/bin/* .
# Copy executable
COPY --from=builder /go/src/ausf/bin/* /usr/local/bin/.
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,22 @@ docker-push:
for target in $(DOCKER_TARGETS); do \
docker push ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}5gc-$$target:${DOCKER_TAG}; \
done

.coverage:
rm -rf $(CURDIR)/.coverage
mkdir -p $(CURDIR)/.coverage

test: .coverage
docker run --rm -v $(CURDIR):/ausf -w /ausf golang:latest \
go test \
-failfast \
-coverprofile=.coverage/coverage-unit.txt \
-covermode=atomic \
-v \
./ ./...

fmt:
@go fmt ./...

golint:
@docker run --rm -v $(CURDIR):/app -w /app golangci/golangci-lint:latest golangci-lint run -v --config /app/.golangci.yml
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.1-dev
1.6.1-dev
15 changes: 5 additions & 10 deletions ausf.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-FileCopyrightText: 2024 Intel Corporation
// Copyright 2019 free5GC.org
//
// SPDX-License-Identifier: Apache-2.0
Expand All @@ -18,29 +19,23 @@ import (
"os"

"github.com/urfave/cli"
"go.uber.org/zap"

"github.com/omec-project/ausf/logger"
"github.com/omec-project/ausf/service"
)

var AUSF = &service.AUSF{}

var appLog *zap.SugaredLogger

func init() {
appLog = logger.AppLog
}

func main() {
app := cli.NewApp()
app.Name = "ausf"
appLog.Infoln(app.Name)
app.Usage = "-free5gccfg common configuration file -ausfcfg ausf configuration file"
logger.AppLog.Infoln(app.Name)
app.Usage = "Authentication Server Function"
app.UsageText = "ausf -cfg <ausf_config_file.conf>"
app.Action = action
app.Flags = AUSF.GetCliCmd()
if err := app.Run(os.Args); err != nil {
appLog.Errorf("AUSF Run error: %v", err)
logger.AppLog.Fatalf("AUSF run error: %v", err)
}
}

Expand Down
16 changes: 1 addition & 15 deletions context/ausf_context_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,9 @@ import (
"github.com/google/uuid"
"github.com/omec-project/ausf/factory"
"github.com/omec-project/ausf/logger"
"github.com/omec-project/ausf/util"
"github.com/omec-project/openapi/models"
"github.com/omec-project/util/path_util"
)

func TestInit() {
// load config
DefaultAusfConfigPath := path_util.Free5gcPath("free5gc/config/ausfcfg.yaml")
if err := factory.InitConfigFactory(DefaultAusfConfigPath); err != nil {
panic(err)
}
Init()
}

func InitAusfContext(context *AUSFContext) {
config := factory.AusfConfig
logger.InitLog.Infof("ausfconfig Info: Version[%s] Description[%s]", config.Info.Version, config.Info.Description)
Expand All @@ -41,8 +30,6 @@ func InitAusfContext(context *AUSFContext) {
context.UriScheme = models.UriScheme(configuration.Sbi.Scheme) // default uri scheme
context.RegisterIPv4 = factory.AUSF_DEFAULT_IPV4 // default localhost
context.SBIPort = factory.AUSF_DEFAULT_PORT_INT // default port
context.Key = util.AusfKeyPath // default key path
context.PEM = util.AusfPemPath // default PEM path
if sbi != nil {
if sbi.RegisterIPv4 != "" {
context.RegisterIPv4 = sbi.RegisterIPv4
Expand Down Expand Up @@ -78,8 +65,7 @@ func InitAusfContext(context *AUSFContext) {
}

context.Url = string(context.UriScheme) + "://" + context.RegisterIPv4 + ":" + strconv.Itoa(context.SBIPort)
roc := os.Getenv("MANAGED_BY_CONFIG_POD")
if roc != "true" {
if os.Getenv("MANAGED_BY_CONFIG_POD") != "true" {
context.PlmnList = append(context.PlmnList, configuration.PlmnSupportList...)
}
context.EnableScaling = configuration.EnableScaling
Expand Down
1 change: 1 addition & 0 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Config struct {
Info *Info `yaml:"info"`
Configuration *Configuration `yaml:"configuration"`
Logger *logger.Logger `yaml:"logger"`
CfgLocation string
}

type Info struct {
Expand Down
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module github.com/omec-project/ausf

go 1.21
go 1.23

require (
github.com/antihax/optional v1.0.0
github.com/bronze1man/radius v0.0.0-20190516032554-afd8baec892d
github.com/gin-gonic/gin v1.10.0
github.com/google/gopacket v1.1.19
github.com/google/uuid v1.6.0
github.com/omec-project/config5g v1.5.1
github.com/omec-project/openapi v1.3.1
github.com/omec-project/util v1.2.3
github.com/omec-project/config5g v1.5.5
github.com/omec-project/openapi v1.3.2
github.com/omec-project/util v1.2.6
github.com/prometheus/client_golang v1.20.5
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
github.com/urfave/cli v1.22.16
go.uber.org/zap v1.27.0
gopkg.in/yaml.v2 v2.4.0
Expand Down Expand Up @@ -56,14 +56,14 @@ require (
github.com/ugorji/go/codec v1.2.12 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.68.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/h2non/gock.v1 v1.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 9d87c07

Please sign in to comment.