From 44033c273aed02375cb8996deb1b19b002679183 Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 12 Sep 2024 18:53:59 -0700 Subject: [PATCH] Testing ForgeJo / Gitea / Github actions. --- .forgejo/workflows/build.yaml | 34 +++++++++++++++++++++++++++------- assets/examples/gagent.hcl | 2 +- cmd/gagent/main.go | 13 +++++-------- go.mod | 11 ++++++----- go.sum | 22 ++++++++++++---------- 5 files changed, 51 insertions(+), 31 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 6e23e77..c3ed466 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -1,13 +1,33 @@ -name: Build G'Agent +name: G'Agent Scan, Build, and Test on: [push] jobs: - trivy_scan: + scan: runs-on: docker container: image: dragonheim/golang:latest steps: - - run: ls -la - - run: go version - - run: go fmt - # - run: apk add --no-cache git zeromq-dev build-base - # - run: go build -o test cmd/gagent/main.go + - run: apk add --no-cache nodejs npm + - uses: actions/checkout@v4 + - run: curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin + - run: curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b /usr/local/bin + - run: /usr/local/bin/trivy fs --no-progress --severity CRITICAL --exit-code 1 . + - run: /usr/local/bin/gosec -quiet ./... + + build: + needs: scan + runs-on: docker + container: + image: dragonheim/golang:latest + steps: + - run: apk add --no-cache zeromq-dev build-base git + - run: apk add --no-cache nodejs npm + + - uses: actions/checkout@v4 + + - run: go build -o gagent cmd/gagent/main.go + - run: ./gagent --version + + - uses: actions/upload-artifact@v3 + with: + name: gagent + path: gagent \ No newline at end of file diff --git a/assets/examples/gagent.hcl b/assets/examples/gagent.hcl index b1fce4d..e45b94e 100644 --- a/assets/examples/gagent.hcl +++ b/assets/examples/gagent.hcl @@ -27,7 +27,7 @@ * * Required. */ -mode = "router" +mode = "client" /* * @TODO: Add authentication based on UUID diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 48ff061..aea381b 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,6 +1,7 @@ package main import ( + flag "flag" log "log" http "net/http" os "os" @@ -55,12 +56,6 @@ var environment struct { MonitorPort int `env:"MONITOR_PORT" envDefault:"0"` } -/* - * This is the application version number. It can be overridden at build time - * using the -ldflags "-X main.semVER=0.0.1" option. - * var semVER = "0.0.9" - */ - /* * This is the application configuration. It is populated from the configuration * file and then used throughout the application. @@ -134,6 +129,8 @@ func main() { * reads the environment variables. It also sets up the logging. */ func init() { + versioninfo.AddFlag(nil) + flag.Parse() cfg := environment env.Parse(&cfg) @@ -223,8 +220,8 @@ func init() { usage += "\n" usage += "Options:\n" - usage += " -h --help -- Show this help screen and exit\n" - usage += " --version -- Show version and exit\n" + usage += " -h, --help -- Show this help screen and exit\n" + usage += " -v, -version -- Show version and exit\n" usage += " --config= -- [default: /etc/gagent/gagent.hcl]\n" usage += " --agent= -- filename of the agent to be uploaded to the G'Agent network. Required in push mode\n" usage += "\n" diff --git a/go.mod b/go.mod index a12bdf5..873df12 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 github.com/pebbe/zmq4 v1.2.11 - github.com/prometheus/client_golang v1.20.2 + github.com/prometheus/client_golang v1.20.3 github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae github.com/stretchr/testify v1.9.0 github.com/zclconf/go-cty v1.15.0 @@ -30,12 +30,13 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/common v0.59.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect - golang.org/x/mod v0.20.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect + golang.org/x/mod v0.21.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/tools v0.24.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 703cde5..1d102e8 100644 --- a/go.sum +++ b/go.sum @@ -43,32 +43,34 @@ github.com/pebbe/zmq4 v1.2.11 h1:Ua5mgIaZeabUGnH7tqswkUcjkL7JYGai5e8v4hpEU9Q= github.com/pebbe/zmq4 v1.2.11/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= -github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4= +github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0= +github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae h1:hnJJroq/kooxO2jUKDc8KXxj8tilWvOlD0hzDDv05ss= github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae/go.mod h1:p+QQKBy7tS+myk+y3sgnAKx4gUtD/Q9Z6KEd77cLzWY= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ= github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= -golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=