mirror of
https://github.com/dragonheim/gagent.git
synced 2025-01-18 09:36:28 -08:00
Added support for environmental config values
Updated Go version to 1.20.0
This commit is contained in:
parent
77c9399942
commit
4a9d4ceca8
6 changed files with 23 additions and 6 deletions
|
@ -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
|
# 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
|
# [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}
|
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}
|
||||||
|
|
||||||
COPY --from=aquasec/trivy:0.32.1 /usr/local/bin/trivy /usr/bin/trivy
|
COPY --from=aquasec/trivy:0.32.1 /usr/local/bin/trivy /usr/bin/trivy
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
{
|
{
|
||||||
"name": "Go",
|
"name": "Go",
|
||||||
"build": {
|
"build": {
|
||||||
"dockerfile": "Dockerfile",
|
// "dockerfile": "Dockerfile",
|
||||||
"args": {
|
"args": {
|
||||||
// Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.17
|
// 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.
|
// Append -bullseye or -buster to pin to an OS version.
|
||||||
// Use -bullseye variants on local arm64/Apple Silicon.
|
// Use -bullseye variants on local arm64/Apple Silicon.
|
||||||
"VARIANT": "1.19-bullseye",
|
// "VARIANT": "1.20-bullseye",
|
||||||
// Options
|
// Options
|
||||||
"NODE_VERSION": "none"
|
"NODE_VERSION": "none"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
FROM dragonheim/golang:1.19 as builder
|
FROM dragonheim/golang:1.20 as builder
|
||||||
ARG SEMVER
|
ARG SEMVER=${SEMVER:-0.0.7}
|
||||||
|
|
||||||
WORKDIR /gagent
|
WORKDIR /gagent
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
|
@ -9,6 +9,8 @@ import (
|
||||||
|
|
||||||
autorestart "github.com/slayer/autorestart"
|
autorestart "github.com/slayer/autorestart"
|
||||||
|
|
||||||
|
env "github.com/caarlos0/env/v6"
|
||||||
|
|
||||||
fqdn "github.com/Showmax/go-fqdn"
|
fqdn "github.com/Showmax/go-fqdn"
|
||||||
|
|
||||||
gstructs "github.com/dragonheim/gagent/internal/gstructs"
|
gstructs "github.com/dragonheim/gagent/internal/gstructs"
|
||||||
|
@ -52,6 +54,12 @@ var (
|
||||||
* 10 Router not connected
|
* 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
|
var config gstructs.GagentConfig
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -112,9 +120,15 @@ func main() {
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// var err error
|
// var err error
|
||||||
|
|
||||||
autorestart.StartWatcher()
|
autorestart.StartWatcher()
|
||||||
|
|
||||||
|
cfg := environment
|
||||||
|
if err := env.Parse(&cfg); err != nil {
|
||||||
|
log.Printf("%+v\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("%+v\n", cfg)
|
||||||
|
|
||||||
filter := &logutils.LevelFilter{
|
filter := &logutils.LevelFilter{
|
||||||
Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"},
|
Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"},
|
||||||
MinLevel: logutils.LogLevel("DEBUG"),
|
MinLevel: logutils.LogLevel("DEBUG"),
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -5,6 +5,7 @@ go 1.18
|
||||||
require (
|
require (
|
||||||
github.com/Showmax/go-fqdn v1.0.0
|
github.com/Showmax/go-fqdn v1.0.0
|
||||||
github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a
|
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/hcl/v2 v2.15.0
|
||||||
github.com/hashicorp/logutils v1.0.0
|
github.com/hashicorp/logutils v1.0.0
|
||||||
github.com/jakehl/goid v1.1.0
|
github.com/jakehl/goid v1.1.0
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -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.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
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/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/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.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||||
|
|
Loading…
Add table
Reference in a new issue