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 #244

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
44 changes: 18 additions & 26 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# SPDX-FileCopyrightText: 2024 Intel Corporation
# SPDX-FileCopyrightText: 2021 Open Networking Foundation <[email protected]>
# Copyright 2019 free5GC.org
#
# SPDX-License-Identifier: Apache-2.0
#

# This file contains all available configuration options
# with their default values.
Expand All @@ -28,19 +27,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 @@ -56,7 +42,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 @@ -155,8 +141,6 @@ linters-settings:
# version: "< 1.1.0" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
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 @@ -199,14 +183,12 @@ 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
whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
gci:
local-prefixes: "bitbucket.org"
misspell:
#locale: US
ignore-words:
whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
wsl:
# If true append is only allowed to be cuddled if appending value is
# matching variables, fields or types on line above. Default is true.
Expand Down Expand Up @@ -234,7 +216,6 @@ linters:
- gofmt
- govet
- errcheck
- staticcheck
- unused
- gosimple
- ineffassign
Expand All @@ -257,9 +238,9 @@ linters:
- dogsled
- bodyclose
- asciicheck
#- stylecheck
# - stylecheck
- unparam
# - wsl
# - wsl

#disable-all: false
fast: true
Expand All @@ -270,6 +251,8 @@ issues:
# excluded by default patterns execute `golangci-lint run --help`
exclude:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-dirs:
- "configapi"
exclude-rules:
# Exclude some linters from running on tests files.
# Independently from option `exclude` we use default exclude patterns,
Expand Down Expand Up @@ -311,3 +294,12 @@ severity:
# The default value is false.
# If set to true severity-rules regular expressions become case sensitive.
case-sensitive: false
# Default value is empty list.
# When a list of severity rules are provided, severity information will be added to lint
# issues. Severity rules have the same filtering capability as exclude rules except you
# are allowed to specify one matcher per severity rule.
# Only affects out formats that support setting severity information.
rules:
- linters:
- gomnd
severity: ignore
13 changes: 4 additions & 9 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 <[email protected]>"

RUN apt-get update && \
apt-get -y install --no-install-recommends \
apt-transport-https \
Expand All @@ -29,19 +27,16 @@ RUN make all && \

FROM alpine:3.20 AS webui

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


# Install debug tools ~85MB (if DEBUG_TOOLS is set to true)
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/webconsole

# Copy executable and default certs
COPY --from=builder /go/src/webconsole/webconsole .
# Copy executable
COPY --from=builder /go/src/webconsole/webconsole /usr/local/bin/.
33 changes: 15 additions & 18 deletions backend/webui_service/webui_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"net/http"
_ "net/http/pprof"
"os/exec"
"path/filepath"
"strconv"
"sync"
"time"
Expand All @@ -22,7 +23,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/omec-project/util/http2_util"
utilLogger "github.com/omec-project/util/logger"
"github.com/omec-project/util/path_util"
"github.com/omec-project/webconsole/backend/auth"
"github.com/omec-project/webconsole/backend/factory"
"github.com/omec-project/webconsole/backend/logger"
Expand All @@ -42,20 +42,17 @@ type WEBUI struct{}
type (
// Config information.
Config struct {
webuicfg string
cfg string
}
)

var config Config

var webuiCLi = []cli.Flag{
cli.StringFlag{
Name: "free5gccfg",
Usage: "common config file",
},
cli.StringFlag{
Name: "webuicfg",
Usage: "config file",
Name: "cfg",
Usage: "webconsole config file",
Required: true,
},
}

Expand All @@ -65,18 +62,18 @@ func (*WEBUI) GetCliCmd() (flags []cli.Flag) {

func (webui *WEBUI) Initialize(c *cli.Context) {
config = Config{
webuicfg: c.String("webuicfg"),
cfg: c.String("cfg"),
}

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

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

webui.setLogLevel()
Expand Down
2 changes: 1 addition & 1 deletion config/default-ue-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
},
"AmPolicyData":{
"subscCats":[
"free5gc"
"aether"
]
},
"SmPolicyData":{
Expand Down
2 changes: 0 additions & 2 deletions configapi/api_inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ func TestInventoryPostHandlers_Success(t *testing.T) {
default:
t.Error("expected message in configChannel, but none received")
}

})
}
}
Expand Down Expand Up @@ -446,7 +445,6 @@ func TestInventoryDeleteHandlers_Success(t *testing.T) {
default:
t.Error("expected message in configChannel, but none received")
}

})
}
}
2 changes: 1 addition & 1 deletion configapi/api_sub_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func GetSampleJSON(c *gin.Context) {

amPolicyData := models.AmPolicyData{
SubscCats: []string{
"free5gc",
"aether",
},
}

Expand Down
2 changes: 1 addition & 1 deletion configmodels/model_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package configmodels

type Slice struct {
SliceName string `json:slice-name,omitempty"`
SliceName string `json:"slice-name,omitempty"`
gab-arrobo marked this conversation as resolved.
Show resolved Hide resolved

SliceId SliceSliceId `json:"slice-id,omitempty"`

Expand Down
2 changes: 1 addition & 1 deletion proto/server/configEvtHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func getDeletedImsisList(group, prevGroup *configmodels.DeviceGroups) (dimsis []
func updateAmPolicyData(imsi string) {
// ampolicydata
var amPolicy models.AmPolicyData
amPolicy.SubscCats = append(amPolicy.SubscCats, "free5gc")
amPolicy.SubscCats = append(amPolicy.SubscCats, "aether")
amPolicyDatBsonA := configmodels.ToBsonM(amPolicy)
amPolicyDatBsonA["ueId"] = "imsi-" + imsi
filter := bson.M{"ueId": "imsi-" + imsi}
Expand Down
5 changes: 3 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ func main() {
app := cli.NewApp()
app.Name = "webui"
logger.AppLog.Infoln(app.Name)
app.Usage = "-free5gccfg common configuration file -webuicfg webui configuration file"
app.Usage = "Web UI"
app.UsageText = "webconsole -cfg <webui_config_file.conf>"
app.Action = action
app.Flags = WEBUI.GetCliCmd()
if err := app.Run(os.Args); err != nil {
logger.AppLog.Warnf("error args: %v", err)
logger.AppLog.Fatalf("error args: %v", err)
}
}

Expand Down
Loading