Add env vars?

This commit is contained in:
Owen Schwartz 2024-12-26 21:31:48 -05:00
parent 72d145aaa5
commit 0a09e6d1fc
No known key found for this signature in database
GPG key ID: 8271FDFFD9E0CCBD
2 changed files with 6 additions and 7 deletions

View file

@ -8,7 +8,7 @@ push:
docker push fossorial/newt:latest
test:
docker run -it -p 3002:3002 -v ./config_example.json:/config/config.json --cap-add=NET_ADMIN --cap-add=SYS_MODULE newt --config /config/config.json
docker run fossorial/newt:latest
local:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o newt

11
main.go
View file

@ -248,16 +248,15 @@ func main() {
flag.StringVar(&logLevel, "log-level", getEnvWithDefault("LOG_LEVEL", "INFO"), "Log level (DEBUG, INFO, WARN, ERROR, FATAL)")
flag.Parse()
// Validate required fields
if endpoint == "" || id == "" || secret == "" {
logger.Fatal("endpoint, id, and secret are required either via CLI flags or environment variables")
}
logger.Init()
loggerLevel := parseLogLevel(logLevel)
logger.GetLogger().SetLevel(parseLogLevel(logLevel))
// Validate required fields
if endpoint == "" || id == "" || secret == "" {
logger.Fatal("endpoint, id, and secret are required either via CLI flags or environment variables")
}
privateKey, err = wgtypes.GeneratePrivateKey()
if err != nil {
logger.Fatal("Failed to generate private key: %v", err)