Added support for environmental config values

Updated Go version to 1.20.0
This commit is contained in:
James Wells 2023-02-10 07:23:35 -08:00
parent 77c9399942
commit 4a9d4ceca8
Signed by: jwells
GPG key ID: 73196D10B8E65666
6 changed files with 23 additions and 6 deletions

View file

@ -1,7 +1,7 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.194.3/containers/go/.devcontainer/base.Dockerfile
# [Choice] Go version: 1, 1.16, 1.17
ARG VARIANT="1.19"
ARG VARIANT="1.20"
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}
COPY --from=aquasec/trivy:0.32.1 /usr/local/bin/trivy /usr/bin/trivy

View file

@ -3,12 +3,12 @@
{
"name": "Go",
"build": {
"dockerfile": "Dockerfile",
// "dockerfile": "Dockerfile",
"args": {
// Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.17
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local arm64/Apple Silicon.
"VARIANT": "1.19-bullseye",
// "VARIANT": "1.20-bullseye",
// Options
"NODE_VERSION": "none"
}

View file

@ -1,5 +1,5 @@
FROM dragonheim/golang:1.19 as builder
ARG SEMVER
FROM dragonheim/golang:1.20 as builder
ARG SEMVER=${SEMVER:-0.0.7}
WORKDIR /gagent
COPY . .

View file

@ -9,6 +9,8 @@ import (
autorestart "github.com/slayer/autorestart"
env "github.com/caarlos0/env/v6"
fqdn "github.com/Showmax/go-fqdn"
gstructs "github.com/dragonheim/gagent/internal/gstructs"
@ -52,6 +54,12 @@ var (
* 10 Router not connected
*/
var environment struct {
Mode string `env:"GAGENT_MODE" envDefault:"setup"`
Port int `env:"PORT" envDefault:"3000"`
UUID string `env:"GAGENT_UUID" envDefault:""`
}
var config gstructs.GagentConfig
func main() {
@ -112,9 +120,15 @@ func main() {
func init() {
// var err error
autorestart.StartWatcher()
cfg := environment
if err := env.Parse(&cfg); err != nil {
log.Printf("%+v\n", err)
}
log.Printf("%+v\n", cfg)
filter := &logutils.LevelFilter{
Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"},
MinLevel: logutils.LogLevel("DEBUG"),

1
go.mod
View file

@ -5,6 +5,7 @@ go 1.18
require (
github.com/Showmax/go-fqdn v1.0.0
github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a
github.com/caarlos0/env/v6 v6.10.1
github.com/hashicorp/hcl/v2 v2.15.0
github.com/hashicorp/logutils v1.0.0
github.com/jakehl/goid v1.1.0

2
go.sum
View file

@ -50,6 +50,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/II=
github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=