From 643267caba4f899313f1dba9cba59848ee16912e Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 9 Sep 2021 13:38:51 -0700 Subject: [PATCH 01/80] fix: forgot to uncomment build commands. --- .drone.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 922d089..b10148b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -53,13 +53,13 @@ steps: - trivy fs --skip-update --exit-code 1 --severity CRITICAL,HIGH . # Build new container image. - # - docker buildx build --push --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER##v:0.0.0}" -t ${DRONE_REPO}:${DRONE_SEMVER##v} -f docker/Dockerfile . + - docker buildx build --push --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER}" -t ${DRONE_REPO}:latest -t ${DRONE_REPO}:${DRONE_SEMVER} -f docker/Dockerfile . # Perform image security check of lower level vulnerabilities. This will not break the build, we just want this information, just in case. - # - trivy image --skip-update --exit-code 0 --severity UNKNOWN,LOW,MEDIUM,HIGH ${DRONE_REPO}:${DRONE_SEMVER##v} + - trivy image --skip-update --exit-code 0 --severity UNKNOWN,LOW,MEDIUM,HIGH ${DRONE_REPO}:${DRONE_SEMVER} # Perform image security check of higher level vulnerabilities. This can break the build. - # - trivy image --skip-update --exit-code 1 --severity CRITICAL ${DRONE_REPO}:${DRONE_SEMVER##v} + - trivy image --skip-update --exit-code 1 --severity CRITICAL ${DRONE_REPO}:${DRONE_SEMVER} # name: Create Test Environment # image: dragonheim/terraform:latest From 0557021282215c11e30e35e090936ed10b9caa9c Mon Sep 17 00:00:00 2001 From: James Wells Date: Sat, 18 Sep 2021 20:20:26 -0700 Subject: [PATCH 02/80] fix: Upgrading Terraform and starting to extend. --- .drone.yml | 20 +++++++++++++++----- docker/Dockerfile | 2 +- tfenv/terraform.tf | 14 +++++++------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.drone.yml b/.drone.yml index b10148b..ad01bff 100644 --- a/.drone.yml +++ b/.drone.yml @@ -53,16 +53,26 @@ steps: - trivy fs --skip-update --exit-code 1 --severity CRITICAL,HIGH . # Build new container image. - - docker buildx build --push --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER}" -t ${DRONE_REPO}:latest -t ${DRONE_REPO}:${DRONE_SEMVER} -f docker/Dockerfile . + # - docker buildx build --push --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER}" -t "${DRONE_REPO}:latest" -t "${DRONE_REPO}:${DRONE_SEMVER}" -f docker/Dockerfile . + - docker buildx build --platform linux/amd64 --progress plain --build-arg SEMVER="dev" -t "${DRONE_REPO}:dev" -f docker/Dockerfile . # Perform image security check of lower level vulnerabilities. This will not break the build, we just want this information, just in case. - - trivy image --skip-update --exit-code 0 --severity UNKNOWN,LOW,MEDIUM,HIGH ${DRONE_REPO}:${DRONE_SEMVER} + - trivy image --skip-update --exit-code 0 --severity UNKNOWN,LOW,MEDIUM,HIGH "${DRONE_REPO}:dev" # Perform image security check of higher level vulnerabilities. This can break the build. - - trivy image --skip-update --exit-code 1 --severity CRITICAL ${DRONE_REPO}:${DRONE_SEMVER} + - trivy image --skip-update --exit-code 1 --severity CRITICAL "${DRONE_REPO}:dev" - # name: Create Test Environment - # image: dragonheim/terraform:latest + - name: Create Test Environment + image: dragonheim/terraform:latest + volumes: + - name: dockersock + path: /var/run/docker.sock + environment: + TRIVY_QUIET: true + commands: + - cd tfenv + - terraform init + - terraform plan - name: Notify Datadog That We Have Completed image: masci/drone-datadog diff --git a/docker/Dockerfile b/docker/Dockerfile index bc1d0ce..6eef53c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,7 +14,7 @@ RUN go build -o /gagent/bin/gagent -ldflags "-X main.semVER=${SEMVER}" gagent/ma RUN strip /gagent/bin/gagent FROM alpine:3.14 -ARG vernum +ARG SEMVER LABEL Name="G'Agent" LABEL Maintainer="jwells@dragonheim.net" LABEL License="MIT License" diff --git a/tfenv/terraform.tf b/tfenv/terraform.tf index 5547720..7b065bc 100644 --- a/tfenv/terraform.tf +++ b/tfenv/terraform.tf @@ -1,9 +1,9 @@ terraform { - required_version = ">= 1.0.0" - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 3.46.0" - } - } + required_version = ">= 1.0.7" + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.59.0" + } + } } From a7747040ce2d4bfd65bf9197a323d5c70b150f04 Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 21 Sep 2021 07:08:52 -0700 Subject: [PATCH 03/80] [CI SKIP] Refactored project layout per Mark Wolfe Blog : https://www.wolfe.id.au/2020/03/10/how-do-i-structure-my-go-project/ --- .drone.yml | 4 ++-- LICENSE | 19 ----------------- {docker => assets/docker}/Dockerfile | 6 +++--- {examples => assets/examples}/add-two.tcl | 0 {examples => assets/examples}/gagent.hcl | 0 {examples => assets/examples}/hello-earth.tcl | 0 gagent.png => assets/gagent.png | Bin {tfenv => assets/tfenv}/_provider.tf | 0 {tfenv => assets/tfenv}/cluster/subnets.tf | 2 +- {tfenv => assets/tfenv}/cluster/variables.tf | 0 {tfenv => assets/tfenv}/cluster/vpc.tf | 0 {tfenv => assets/tfenv}/main.tf | 0 {tfenv => assets/tfenv}/terraform.tf | 0 {gagent => cmd/gagent}/main.go | 0 CHANGELOG.md => docs/CHANGELOG.md | 0 LANGUAGE.md => docs/LANGUAGE.md | 0 docs/LICENSE.md | 9 ++++++++ VULNERABILITIES.md => docs/VULNERABILITIES.md | 0 {src => internal}/client/client.go | 0 {src => internal}/gstructs/gstructs.go | 0 {src => internal}/router/router.go | 0 {src => internal}/worker/worker.go | 0 {src => pkg}/picol/README.md | 0 {src => pkg}/picol/commands.go | 0 {src => pkg}/picol/examples/fib.tcl | 0 {src => pkg}/picol/examples/t2.tcl | 0 {src => pkg}/picol/examples/tst.tcl | 0 {src => pkg}/picol/parser.go | 0 {src => pkg}/picol/picol.go | 0 .../picol/picol_unused/main.go_unused | 0 src/picol/LICENSE | 20 ------------------ 31 files changed, 15 insertions(+), 45 deletions(-) delete mode 100644 LICENSE rename {docker => assets/docker}/Dockerfile (82%) rename {examples => assets/examples}/add-two.tcl (100%) rename {examples => assets/examples}/gagent.hcl (100%) rename {examples => assets/examples}/hello-earth.tcl (100%) rename gagent.png => assets/gagent.png (100%) rename {tfenv => assets/tfenv}/_provider.tf (100%) rename {tfenv => assets/tfenv}/cluster/subnets.tf (98%) rename {tfenv => assets/tfenv}/cluster/variables.tf (100%) rename {tfenv => assets/tfenv}/cluster/vpc.tf (100%) rename {tfenv => assets/tfenv}/main.tf (100%) rename {tfenv => assets/tfenv}/terraform.tf (100%) rename {gagent => cmd/gagent}/main.go (100%) rename CHANGELOG.md => docs/CHANGELOG.md (100%) rename LANGUAGE.md => docs/LANGUAGE.md (100%) create mode 100644 docs/LICENSE.md rename VULNERABILITIES.md => docs/VULNERABILITIES.md (100%) rename {src => internal}/client/client.go (100%) rename {src => internal}/gstructs/gstructs.go (100%) rename {src => internal}/router/router.go (100%) rename {src => internal}/worker/worker.go (100%) rename {src => pkg}/picol/README.md (100%) rename {src => pkg}/picol/commands.go (100%) rename {src => pkg}/picol/examples/fib.tcl (100%) rename {src => pkg}/picol/examples/t2.tcl (100%) rename {src => pkg}/picol/examples/tst.tcl (100%) rename {src => pkg}/picol/parser.go (100%) rename {src => pkg}/picol/picol.go (100%) rename {src => pkg}/picol/picol_unused/main.go_unused (100%) delete mode 100644 src/picol/LICENSE diff --git a/.drone.yml b/.drone.yml index ad01bff..d9ddccc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -54,7 +54,7 @@ steps: # Build new container image. # - docker buildx build --push --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER}" -t "${DRONE_REPO}:latest" -t "${DRONE_REPO}:${DRONE_SEMVER}" -f docker/Dockerfile . - - docker buildx build --platform linux/amd64 --progress plain --build-arg SEMVER="dev" -t "${DRONE_REPO}:dev" -f docker/Dockerfile . + - docker buildx build --platform linux/amd64 --progress plain --build-arg SEMVER="dev" -t "${DRONE_REPO}:dev" -f assets/docker/Dockerfile . # Perform image security check of lower level vulnerabilities. This will not break the build, we just want this information, just in case. - trivy image --skip-update --exit-code 0 --severity UNKNOWN,LOW,MEDIUM,HIGH "${DRONE_REPO}:dev" @@ -70,7 +70,7 @@ steps: environment: TRIVY_QUIET: true commands: - - cd tfenv + - cd assets/tfenv - terraform init - terraform plan diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 1da20a3..0000000 --- a/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -MIT License -Copyright (c) 2017-2021 James Wells - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/docker/Dockerfile b/assets/docker/Dockerfile similarity index 82% rename from docker/Dockerfile rename to assets/docker/Dockerfile index 6eef53c..38d3460 100644 --- a/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,5 +1,5 @@ # FROM golang:1.17-alpine3.14 as builder -FROM dragonheim/golang:1.17.0 as builder +FROM dragonheim/golang:1.17.1 as builder ARG SEMVER WORKDIR /gagent @@ -10,7 +10,7 @@ ARG GOOS=${GOOS:-linux} ARG CGO_ENABLED=1 RUN apk add --no-cache zeromq-dev build-base git -RUN go build -o /gagent/bin/gagent -ldflags "-X main.semVER=${SEMVER}" gagent/main.go +RUN go build -o /gagent/bin/gagent -ldflags "-X main.semVER=${SEMVER}" cmd/gagent/main.go RUN strip /gagent/bin/gagent FROM alpine:3.14 @@ -21,7 +21,7 @@ LABEL License="MIT License" LABEL version="${SEMVER}" RUN apk add --no-cache zeromq && mkdir -p -m 0700 /etc/gagent -COPY --from=builder /gagent/examples/gagent.hcl /etc/gagent/gagent.hcl +COPY --from=builder /gagent/assets/examples/gagent.hcl /etc/gagent/gagent.hcl COPY --from=builder /gagent/bin/gagent /usr/bin/ # Router Client Worker diff --git a/examples/add-two.tcl b/assets/examples/add-two.tcl similarity index 100% rename from examples/add-two.tcl rename to assets/examples/add-two.tcl diff --git a/examples/gagent.hcl b/assets/examples/gagent.hcl similarity index 100% rename from examples/gagent.hcl rename to assets/examples/gagent.hcl diff --git a/examples/hello-earth.tcl b/assets/examples/hello-earth.tcl similarity index 100% rename from examples/hello-earth.tcl rename to assets/examples/hello-earth.tcl diff --git a/gagent.png b/assets/gagent.png similarity index 100% rename from gagent.png rename to assets/gagent.png diff --git a/tfenv/_provider.tf b/assets/tfenv/_provider.tf similarity index 100% rename from tfenv/_provider.tf rename to assets/tfenv/_provider.tf diff --git a/tfenv/cluster/subnets.tf b/assets/tfenv/cluster/subnets.tf similarity index 98% rename from tfenv/cluster/subnets.tf rename to assets/tfenv/cluster/subnets.tf index 494dda1..0208f2e 100644 --- a/tfenv/cluster/subnets.tf +++ b/assets/tfenv/cluster/subnets.tf @@ -1,4 +1,4 @@ -# variable "vpc_id" {} +variable "vpc_id" {} data "aws_vpc" "selected" { id = var.vpc_id diff --git a/tfenv/cluster/variables.tf b/assets/tfenv/cluster/variables.tf similarity index 100% rename from tfenv/cluster/variables.tf rename to assets/tfenv/cluster/variables.tf diff --git a/tfenv/cluster/vpc.tf b/assets/tfenv/cluster/vpc.tf similarity index 100% rename from tfenv/cluster/vpc.tf rename to assets/tfenv/cluster/vpc.tf diff --git a/tfenv/main.tf b/assets/tfenv/main.tf similarity index 100% rename from tfenv/main.tf rename to assets/tfenv/main.tf diff --git a/tfenv/terraform.tf b/assets/tfenv/terraform.tf similarity index 100% rename from tfenv/terraform.tf rename to assets/tfenv/terraform.tf diff --git a/gagent/main.go b/cmd/gagent/main.go similarity index 100% rename from gagent/main.go rename to cmd/gagent/main.go diff --git a/CHANGELOG.md b/docs/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to docs/CHANGELOG.md diff --git a/LANGUAGE.md b/docs/LANGUAGE.md similarity index 100% rename from LANGUAGE.md rename to docs/LANGUAGE.md diff --git a/docs/LICENSE.md b/docs/LICENSE.md new file mode 100644 index 0000000..5d2e857 --- /dev/null +++ b/docs/LICENSE.md @@ -0,0 +1,9 @@ +# Released under MIT License + +Copyright (c) 2017-2021 [James Wells](mailto:jwells@dragonheim.net?subject=G%27Agent) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/VULNERABILITIES.md b/docs/VULNERABILITIES.md similarity index 100% rename from VULNERABILITIES.md rename to docs/VULNERABILITIES.md diff --git a/src/client/client.go b/internal/client/client.go similarity index 100% rename from src/client/client.go rename to internal/client/client.go diff --git a/src/gstructs/gstructs.go b/internal/gstructs/gstructs.go similarity index 100% rename from src/gstructs/gstructs.go rename to internal/gstructs/gstructs.go diff --git a/src/router/router.go b/internal/router/router.go similarity index 100% rename from src/router/router.go rename to internal/router/router.go diff --git a/src/worker/worker.go b/internal/worker/worker.go similarity index 100% rename from src/worker/worker.go rename to internal/worker/worker.go diff --git a/src/picol/README.md b/pkg/picol/README.md similarity index 100% rename from src/picol/README.md rename to pkg/picol/README.md diff --git a/src/picol/commands.go b/pkg/picol/commands.go similarity index 100% rename from src/picol/commands.go rename to pkg/picol/commands.go diff --git a/src/picol/examples/fib.tcl b/pkg/picol/examples/fib.tcl similarity index 100% rename from src/picol/examples/fib.tcl rename to pkg/picol/examples/fib.tcl diff --git a/src/picol/examples/t2.tcl b/pkg/picol/examples/t2.tcl similarity index 100% rename from src/picol/examples/t2.tcl rename to pkg/picol/examples/t2.tcl diff --git a/src/picol/examples/tst.tcl b/pkg/picol/examples/tst.tcl similarity index 100% rename from src/picol/examples/tst.tcl rename to pkg/picol/examples/tst.tcl diff --git a/src/picol/parser.go b/pkg/picol/parser.go similarity index 100% rename from src/picol/parser.go rename to pkg/picol/parser.go diff --git a/src/picol/picol.go b/pkg/picol/picol.go similarity index 100% rename from src/picol/picol.go rename to pkg/picol/picol.go diff --git a/src/picol/picol_unused/main.go_unused b/pkg/picol/picol_unused/main.go_unused similarity index 100% rename from src/picol/picol_unused/main.go_unused rename to pkg/picol/picol_unused/main.go_unused diff --git a/src/picol/LICENSE b/src/picol/LICENSE deleted file mode 100644 index 79304fb..0000000 --- a/src/picol/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Lain dono - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From e61e6d29942700adf4d3a49c4ec0488ad3ff050a Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 24 Sep 2021 10:37:32 -0700 Subject: [PATCH 04/80] fix: Forgot to update the include source locations. --- cmd/gagent/main.go | 10 +++++----- internal/client/client.go | 2 +- internal/router/router.go | 2 +- internal/worker/worker.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index b73c686..7fa6140 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -6,11 +6,11 @@ import ( "os" "time" - gs "git.dragonheim.net/dragonheim/gagent/src/gstructs" + gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" - gc "git.dragonheim.net/dragonheim/gagent/src/client" - gr "git.dragonheim.net/dragonheim/gagent/src/router" - gw "git.dragonheim.net/dragonheim/gagent/src/worker" + gc "git.dragonheim.net/dragonheim/gagent/internal/client" + gr "git.dragonheim.net/dragonheim/gagent/internal/router" + gw "git.dragonheim.net/dragonheim/gagent/internal/worker" docopt "github.com/aviddiviner/docopt-go" hclsimple "github.com/hashicorp/hcl/v2/hclsimple" @@ -21,7 +21,7 @@ import ( ) var ( - semVER = "0.0.2" + semVER = "0.0.2" ) var exitCodes = struct { diff --git a/internal/client/client.go b/internal/client/client.go index 71b067a..a248d6c 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -6,7 +6,7 @@ import ( "sync" "time" - gs "git.dragonheim.net/dragonheim/gagent/src/gstructs" + gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" zmq "github.com/pebbe/zmq4" ) diff --git a/internal/router/router.go b/internal/router/router.go index 454e88e..c0d2e1d 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -4,7 +4,7 @@ import ( "fmt" "log" - gs "git.dragonheim.net/dragonheim/gagent/src/gstructs" + gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" zmq "github.com/pebbe/zmq4" ) diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 86a84fc..23d0cad 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -4,7 +4,7 @@ import ( "fmt" "log" - gs "git.dragonheim.net/dragonheim/gagent/src/gstructs" + gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" // picol "git.dragonheim.net/dragonheim/gagent/src/picol" zmq "github.com/pebbe/zmq4" From f7cba2689ccfa1ef744b39d6c4143ab2758f7dde Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 4 Oct 2021 13:06:09 -0700 Subject: [PATCH 05/80] fix: converted from select to waitGroups. --- .drone.yml | 48 +++++++++++++++++++++++++++++++-------- .trivyignore | 4 ++-- cmd/gagent/main.go | 24 +++++++++++++------- go.mod | 6 ++--- go.sum | 12 +++++----- internal/client/client.go | 4 +++- internal/router/router.go | 4 +++- internal/worker/worker.go | 4 +++- 8 files changed, 75 insertions(+), 31 deletions(-) diff --git a/.drone.yml b/.drone.yml index d9ddccc..b3e8b41 100644 --- a/.drone.yml +++ b/.drone.yml @@ -24,9 +24,13 @@ steps: - title: "Begin Build: ${DRONE_REPO}" text: "Build ${DRONE_BUILD_NUMBER}(${DRONE_COMMIT_LINK})" alert_type: "info" + when: + ref: + include: + - refs/tags/** - name: Validate code base and dependencies - image: dragonheim/golang:1.17.0 + image: dragonheim/golang:1.17.1 volumes: - name: dockersock path: /var/run/docker.sock @@ -53,7 +57,6 @@ steps: - trivy fs --skip-update --exit-code 1 --severity CRITICAL,HIGH . # Build new container image. - # - docker buildx build --push --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER}" -t "${DRONE_REPO}:latest" -t "${DRONE_REPO}:${DRONE_SEMVER}" -f docker/Dockerfile . - docker buildx build --platform linux/amd64 --progress plain --build-arg SEMVER="dev" -t "${DRONE_REPO}:dev" -f assets/docker/Dockerfile . # Perform image security check of lower level vulnerabilities. This will not break the build, we just want this information, just in case. @@ -62,17 +65,44 @@ steps: # Perform image security check of higher level vulnerabilities. This can break the build. - trivy image --skip-update --exit-code 1 --severity CRITICAL "${DRONE_REPO}:dev" - - name: Create Test Environment - image: dragonheim/terraform:latest + # - name: Create Test Environment + # image: dragonheim/terraform:latest + # volumes: + # - name: dockersock + # path: /var/run/docker.sock + # environment: + # TRIVY_QUIET: true + # commands: + # - cd assets/tfenv + # - terraform init + # - terraform plan + + - name: Test application + image: "${DRONE_REPO}:dev" volumes: - name: dockersock path: /var/run/docker.sock - environment: - TRIVY_QUIET: true commands: - - cd assets/tfenv - - terraform init - - terraform plan + - echo "running" + + - name: Build and push container + image: dragonheim/golang:1.17.1 + volumes: + - name: dockersock + path: /var/run/docker.sock + when: + ref: + include: + - refs/tags/** + commands: + # Build new container image. + - docker buildx build --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER}" -t "${DRONE_REPO}:latest" -f docker/Dockerfile . + + # Perform image security check of higher level vulnerabilities. This can break the build. + - trivy image --skip-update --exit-code 1 --severity CRITICAL "${DRONE_REPO}:latest" + + # Push new build + - docker buildx build --push --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER}" -t "${DRONE_REPO}:latest" -t "${DRONE_REPO}:${DRONE_SEMVER}" -f docker/Dockerfile . - name: Notify Datadog That We Have Completed image: masci/drone-datadog diff --git a/.trivyignore b/.trivyignore index 6828a0e..e721974 100644 --- a/.trivyignore +++ b/.trivyignore @@ -1,3 +1,3 @@ # No impact in our project -CVE-2020-29652 -CVE-2020-9283 +# CVE-2020-29652 +# CVE-2020-9283 diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 7fa6140..7b3353f 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -4,6 +4,7 @@ import ( "io/ioutil" "log" "os" + "sync" "time" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" @@ -16,12 +17,14 @@ import ( hclsimple "github.com/hashicorp/hcl/v2/hclsimple" hclwrite "github.com/hashicorp/hcl/v2/hclwrite" logutils "github.com/hashicorp/logutils" - uuid "github.com/nu7hatch/gouuid" + + uuid "github.com/jakehl/goid" cty "github.com/zclconf/go-cty/cty" ) var ( semVER = "0.0.2" + wg sync.WaitGroup ) var exitCodes = struct { @@ -57,7 +60,8 @@ func main() { * This is used throughout the G'Agent system to uniquely identify this node. * It can be overridden in the configuration file by setting uuid */ - identity, _ := uuid.NewV5(uuid.NamespaceURL, []byte("gagent"+config.Name)) + // identity, _ := uuid.NewV5(uuid.NamespaceURL, []byte("gagent"+config.Name)) + identity := uuid.NewV4UUID() config.UUID = identity.String() /* @@ -181,7 +185,8 @@ func main() { os.Exit(exitCodes.m["AGENT_LOAD_FAILED"]) } for key := range config.Routers { - go gc.Main(config, key, string(agent)) + wg.Add(1) + go gc.Main(&wg, config, key, string(agent)) time.Sleep(10 * time.Second) } @@ -200,8 +205,9 @@ func main() { os.Exit(exitCodes.m["NO_WORKERS_DEFINED"]) } - go gr.Main(config) - select {} + wg.Add(1) + go gr.Main(&wg, config) + // select {} case "worker": /* @@ -218,11 +224,12 @@ func main() { } for key := range config.Routers { - go gw.Main(config, key) - time.Sleep(10 * time.Second) + wg.Add(1) + go gw.Main(&wg, config, key) + // time.Sleep(10 * time.Second) } - select {} + // select {} case "setup": log.Printf("[INFO] Running in setup mode\n") @@ -247,5 +254,6 @@ func main() { os.Exit(exitCodes.m["INVALID_MODE"]) } + wg.Wait() os.Exit(exitCodes.m["SUCCESS"]) } diff --git a/go.mod b/go.mod index eecdc1c..0792ecb 100644 --- a/go.mod +++ b/go.mod @@ -5,11 +5,11 @@ go 1.16 require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a - github.com/hashicorp/hcl/v2 v2.10.0 + github.com/hashicorp/hcl/v2 v2.10.1 github.com/hashicorp/logutils v1.0.0 + github.com/jakehl/goid v1.1.0 github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d - github.com/pebbe/zmq4 v1.2.6 + github.com/pebbe/zmq4 v1.2.7 github.com/zclconf/go-cty v1.8.3 golang.org/x/text v0.3.6 // indirect ) diff --git a/go.sum b/go.sum index 3500e15..8c3d0b9 100644 --- a/go.sum +++ b/go.sum @@ -17,10 +17,12 @@ github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/hashicorp/hcl/v2 v2.10.0 h1:1S1UnuhDGlv3gRFV4+0EdwB+znNP5HmcGbIqwnSCByg= -github.com/hashicorp/hcl/v2 v2.10.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +github.com/hashicorp/hcl/v2 v2.10.1 h1:h4Xx4fsrRE26ohAk/1iGF/JBqRQbyUqu5Lvj60U54ys= +github.com/hashicorp/hcl/v2 v2.10.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= +github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -31,10 +33,8 @@ github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LE github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= -github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= -github.com/pebbe/zmq4 v1.2.6 h1:zcTAfa/jYi2RxjTFIdLfnVrmxbAd9nSr02+CDMn8swg= -github.com/pebbe/zmq4 v1.2.6/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= +github.com/pebbe/zmq4 v1.2.7 h1:6EaX83hdFSRUEhgzSW1E/SPoTS3JeYZgYkBvwdcrA9A= +github.com/pebbe/zmq4 v1.2.7/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= diff --git a/internal/client/client.go b/internal/client/client.go index a248d6c..4557370 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -12,7 +12,8 @@ import ( ) // Main is the initiation function for a Client -func Main(config gs.GagentConfig, rid int, agent string) { +func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int, agent string) { + defer wg.Done() log.Printf("[INFO] Starting client\n") // Generate connect string for this router. @@ -51,4 +52,5 @@ func Main(config gs.GagentConfig, rid int, agent string) { // } // mu.Unlock() // } + } diff --git a/internal/router/router.go b/internal/router/router.go index c0d2e1d..fbf7377 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -3,6 +3,7 @@ package router import ( "fmt" "log" + "sync" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" @@ -15,7 +16,8 @@ const ( ) // Main is the initiation function for a Router -func Main(config gs.GagentConfig) { +func Main(wg *sync.WaitGroup, config gs.GagentConfig) { + defer wg.Done() log.Printf("[INFO] Starting router\n") clientSock, _ := zmq.NewSocket(zmq.ROUTER) diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 23d0cad..1110da4 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -3,6 +3,7 @@ package worker import ( "fmt" "log" + "sync" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" @@ -11,7 +12,8 @@ import ( ) // Main is the initiation function for a Worker -func Main(config gs.GagentConfig, rid int) { +func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int) { + defer wg.Done() log.Printf("[INFO] Starting worker\n") // Generate connect string for this router. From ae2cee7be42f6851903d00321b4a800ed32d1390 Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 5 Oct 2021 17:27:53 -0700 Subject: [PATCH 06/80] Very preliminary Dockerfile for devcontainer. --- .devcontainer/devcontainer.json | 4 ++-- .devcontainer/docker/Dockerfile | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/docker/Dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c5a1fa7..b36335d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,13 +1,13 @@ { "name": "GitHub Codespaces (Default)", "build": { - "dockerfile": "Dockerfile" + "dockerfile": "docker/Dockerfile" }, "settings": { "go.toolsManagement.checkForUpdates": "local", "go.useLanguageServer": true, "go.gopath": "/go", - "go.goroot": "/usr/local/go", + "go.goroot": "/usr/local/go/bin/go", "go.linting.enabled": true, "lldb.executable": "/usr/bin/lldb", "files.watcherExclude": { diff --git a/.devcontainer/docker/Dockerfile b/.devcontainer/docker/Dockerfile new file mode 100644 index 0000000..811494d --- /dev/null +++ b/.devcontainer/docker/Dockerfile @@ -0,0 +1 @@ +FROM dragonheim/golang:1.17.1 From 00cd60ebeca97a71c9599f8937a233af4feab11a Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 5 Oct 2021 19:38:07 -0700 Subject: [PATCH 07/80] devcontainer appears to be working now. --- .devcontainer/Dockerfile | 20 ++++++++++++++ .devcontainer/devcontainer.json | 48 +++++++++------------------------ .devcontainer/docker/Dockerfile | 1 - 3 files changed, 32 insertions(+), 37 deletions(-) create mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/docker/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..cd8e346 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,20 @@ +# 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.17" +FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} + +# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 +ARG NODE_VERSION="none" +RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends +RUN apt-get update && apt-get install -y --no-install-recommends libzmq3-dev libzmq5 + +# [Optional] Uncomment the next line to use go get to install anything else you need +# RUN go get -x + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b36335d..9ab51d0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,42 +1,18 @@ { "name": "GitHub Codespaces (Default)", + "extensions": [ + "GitHub.vscode-pull-request-github", + "golang.go", + "hashicorp.terraform", + "wholroyd.hcl", + "github.copilot", + "golang.Go" + ], "build": { - "dockerfile": "docker/Dockerfile" - }, - "settings": { - "go.toolsManagement.checkForUpdates": "local", - "go.useLanguageServer": true, - "go.gopath": "/go", - "go.goroot": "/usr/local/go/bin/go", - "go.linting.enabled": true, - "lldb.executable": "/usr/bin/lldb", - "files.watcherExclude": { - "**/target/**": true + "dockerfile": "Dockerfile", + "args": { + "VARIANT": "1.17", + "NODE_VERSION": "none" } }, - "remoteUser": "codespace", - "overrideCommand": false, - "mounts": ["source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"], - "runArgs": [ - "--cap-add=SYS_PTRACE", - "--security-opt", - "seccomp=unconfined", - "--privileged", - "--init" - ], - - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "GitHub.vscode-pull-request-github", - "golang.go", - "hashicorp.terraform", - "wholroyd.hcl", - "github.copilot" - ], - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - - // "oryx build" will automatically install your dependencies and attempt to build your project - // "postCreateCommand": "oryx build -p virtualenv_name=.venv --log-file /tmp/oryx-build.log --manifest-dir /tmp || echo 'Could not auto-build. Skipping.'" } diff --git a/.devcontainer/docker/Dockerfile b/.devcontainer/docker/Dockerfile deleted file mode 100644 index 811494d..0000000 --- a/.devcontainer/docker/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM dragonheim/golang:1.17.1 From f543276b8275e906d21faf0dff63320cddd0db02 Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 14 Oct 2021 10:08:39 -0700 Subject: [PATCH 08/80] Adding preliminary support for Prometheus metrics. --- .drone.yml | 6 +- .gitattributes | 8 +++ .trivyignore | 3 +- assets/docker/Dockerfile | 3 +- assets/tfenv/terraform.tf | 4 +- cmd/gagent/main.go | 22 ++++-- go.mod | 1 + go.sum | 124 +++++++++++++++++++++++++++++++++- internal/client/client.go | 15 ++-- internal/gstructs/gstructs.go | 1 + internal/router/router.go | 47 ++++++++++--- internal/worker/worker.go | 6 +- 12 files changed, 209 insertions(+), 31 deletions(-) create mode 100644 .gitattributes diff --git a/.drone.yml b/.drone.yml index b3e8b41..aef2c6b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,7 +30,7 @@ steps: - refs/tags/** - name: Validate code base and dependencies - image: dragonheim/golang:1.17.1 + image: dragonheim/golang:1.17 volumes: - name: dockersock path: /var/run/docker.sock @@ -66,7 +66,7 @@ steps: - trivy image --skip-update --exit-code 1 --severity CRITICAL "${DRONE_REPO}:dev" # - name: Create Test Environment - # image: dragonheim/terraform:latest + # image: dragonheim/terraform:1.0 # volumes: # - name: dockersock # path: /var/run/docker.sock @@ -86,7 +86,7 @@ steps: - echo "running" - name: Build and push container - image: dragonheim/golang:1.17.1 + image: dragonheim/golang:1.17 volumes: - name: dockersock path: /var/run/docker.sock diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..517b533 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +* text=auto eol=lf +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf +*.gif binary +*.jpeg binary +*.png binary +*.gz binary +*.jar binary diff --git a/.trivyignore b/.trivyignore index e721974..85eed00 100644 --- a/.trivyignore +++ b/.trivyignore @@ -1,3 +1,2 @@ # No impact in our project -# CVE-2020-29652 -# CVE-2020-9283 +CVE-2020-29652 diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index 38d3460..9639856 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,5 +1,4 @@ -# FROM golang:1.17-alpine3.14 as builder -FROM dragonheim/golang:1.17.1 as builder +FROM golang:1.17-alpine3.14 as builder ARG SEMVER WORKDIR /gagent diff --git a/assets/tfenv/terraform.tf b/assets/tfenv/terraform.tf index 7b065bc..fb2b736 100644 --- a/assets/tfenv/terraform.tf +++ b/assets/tfenv/terraform.tf @@ -1,9 +1,9 @@ terraform { - required_version = ">= 1.0.7" + required_version = ">= 1.0.9" required_providers { aws = { source = "hashicorp/aws" - version = "~> 3.59.0" + version = "~> 3.62.0" } } } diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 7b3353f..e03cdad 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,11 +1,13 @@ package main import ( - "io/ioutil" - "log" - "os" - "sync" - "time" + fmt "fmt" + ioutil "io/ioutil" + log "log" + http "net/http" + os "os" + sync "sync" + time "time" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" @@ -20,6 +22,8 @@ import ( uuid "github.com/jakehl/goid" cty "github.com/zclconf/go-cty/cty" + + promhttp "github.com/prometheus/client_golang/prometheus/promhttp" ) var ( @@ -157,6 +161,7 @@ func main() { config.Mode = "worker" } } + config.Version = semVER log.Printf("[DEBUG] Configuration is %v\n", config) switch config.Mode { @@ -184,6 +189,7 @@ func main() { log.Printf("[ERROR] Failed to load Agent file: %s", opts["--agent"]) os.Exit(exitCodes.m["AGENT_LOAD_FAILED"]) } + for key := range config.Routers { wg.Add(1) go gc.Main(&wg, config, key, string(agent)) @@ -205,6 +211,9 @@ func main() { os.Exit(exitCodes.m["NO_WORKERS_DEFINED"]) } + http.Handle("/metrics", promhttp.Handler()) + http.ListenAndServe(fmt.Sprintf(":%d", config.ClientPort), nil) + wg.Add(1) go gr.Main(&wg, config) // select {} @@ -223,6 +232,9 @@ func main() { os.Exit(exitCodes.m["NO_ROUTERS_DEFINED"]) } + http.Handle("/metrics", promhttp.Handler()) + http.ListenAndServe(fmt.Sprintf(":%d", config.ClientPort), nil) + for key := range config.Routers { wg.Add(1) go gw.Main(&wg, config, key) diff --git a/go.mod b/go.mod index 0792ecb..d4b6b59 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/jakehl/goid v1.1.0 github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pebbe/zmq4 v1.2.7 + github.com/prometheus/client_golang v1.11.0 github.com/zclconf/go-cty v1.8.3 golang.org/x/text v0.3.6 // indirect ) diff --git a/go.sum b/go.sum index 8c3d0b9..1912022 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,12 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= @@ -8,21 +14,60 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6 github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a h1:YJuVATwP+Gzk7nys0U/DKjKkoYp1n/sYm0yi5vX8W8M= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a/go.mod h1:pBRbUcGboHT5qBceq2Cg/WIcDbO78a8wPxTg8zmS3Hs= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +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/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/hashicorp/hcl/v2 v2.10.1 h1:h4Xx4fsrRE26ohAk/1iGF/JBqRQbyUqu5Lvj60U54ys= github.com/hashicorp/hcl/v2 v2.10.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -30,16 +75,52 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/pebbe/zmq4 v1.2.7 h1:6EaX83hdFSRUEhgzSW1E/SPoTS3JeYZgYkBvwdcrA9A= github.com/pebbe/zmq4 v1.2.7/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= @@ -48,22 +129,63 @@ github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUA github.com/zclconf/go-cty v1.8.3 h1:48gwZXrdSADU2UW9eZKHprxAI7APZGW9XmExpJpSjT0= github.com/zclconf/go-cty v1.8.3/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1 h1:7QnIQpGRHE5RnLKnESfDoxm2dTapTZua5a0kS0A+VXQ= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/client/client.go b/internal/client/client.go index 4557370..27b9af6 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -1,10 +1,11 @@ package client import ( - "fmt" - "log" - "sync" - "time" + fmt "fmt" + log "log" + http "net/http" + sync "sync" + time "time" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" @@ -52,5 +53,9 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int, agent string) { // } // mu.Unlock() // } - + +} + +func pushAgent(config gs.GagentConfig) { + http.Get(config.Routers[0].RouterAddr) } diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 232c534..91bfbbd 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -12,6 +12,7 @@ type GagentConfig struct { Clients []*ClientDetails `hcl:"client,block"` Routers []*RouterDetails `hcl:"router,block"` Workers []*WorkerDetails `hcl:"worker,block"` + Version string } // ClientDetails is details about known clients diff --git a/internal/router/router.go b/internal/router/router.go index fbf7377..e2be3e9 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -1,12 +1,15 @@ package router import ( - "fmt" - "log" - "sync" + fmt "fmt" + log "log" + http "net/http" + sync "sync" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + promhttp "github.com/prometheus/client_golang/prometheus/promhttp" + zmq "github.com/pebbe/zmq4" ) @@ -26,7 +29,10 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { workerSock, _ := zmq.NewSocket(zmq.DEALER) defer workerSock.Close() - clientSock.Bind(fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.ClientPort)) + http.Handle("/metrics", promhttp.Handler()) + http.ListenAndServe(fmt.Sprintf(":%d", config.ClientPort), nil) + + // clientSock.Bind(fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.ClientPort)) workerSock.Bind(fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort)) workers := make([]string, 0) @@ -36,7 +42,7 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { poller2 := zmq.NewPoller() poller2.Add(workerSock, zmq.POLLIN) - poller2.Add(clientSock, zmq.POLLIN) + // poller2.Add(clientSock, zmq.POLLIN) LOOP: for { @@ -65,9 +71,9 @@ LOOP: workers = append(workers, identity) // Forward message to client if it's not a READY - if msg[0] != WORKER_READY { - clientSock.SendMessage(msg) - } + // if msg[0] != WORKER_READY { + // clientSock.SendMessage(msg) + // } case clientSock: // Get client request, route to first available worker @@ -91,3 +97,28 @@ func unwrap(msg []string) (head string, tail []string) { } return } + +// func answerClient(w http.ResponseWriter, r *http.Request) { +// if r.URL.Path != "/" { +// http.NotFound(w, r) +// return +// } +// +// // Common code for all requests can go here... +// +// switch r.Method { +// case http.MethodGet: +// // Handle the GET request... +// +// case http.MethodPost: +// // Handle the POST request... +// +// case http.MethodOptions: +// w.Header().Set("Allow", "GET, POST, OPTIONS") +// w.WriteHeader(http.StatusNoContent) +// +// default: +// w.Header().Set("Allow", "GET, POST, OPTIONS") +// http.Error(w, "method not allowed", http.StatusMethodNotAllowed) +// } +// } diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 1110da4..e15fd69 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -1,9 +1,9 @@ package worker import ( - "fmt" - "log" - "sync" + fmt "fmt" + log "log" + sync "sync" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" From 16d40fd93a37e8fa53bd0aa165dbb94bdda406c8 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 15 Oct 2021 11:27:38 -0700 Subject: [PATCH 09/80] Converting client side connection over to use net/http instead of zmq. --- cmd/gagent/main.go | 26 +++---------- internal/client/client.go | 3 +- internal/gstructs/gstructs.go | 1 + internal/router/router.go | 70 +++++++++++++++++++---------------- internal/worker/worker.go | 5 +++ 5 files changed, 52 insertions(+), 53 deletions(-) diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index e03cdad..8ef995b 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,10 +1,8 @@ package main import ( - fmt "fmt" ioutil "io/ioutil" log "log" - http "net/http" os "os" sync "sync" time "time" @@ -22,8 +20,6 @@ import ( uuid "github.com/jakehl/goid" cty "github.com/zclconf/go-cty/cty" - - promhttp "github.com/prometheus/client_golang/prometheus/promhttp" ) var ( @@ -48,13 +44,13 @@ var exitCodes = struct { func main() { filter := &logutils.LevelFilter{ Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"}, - MinLevel: logutils.LogLevel("WARN"), + MinLevel: logutils.LogLevel("DEBUG"), Writer: os.Stderr, } log.SetOutput(filter) var config gs.GagentConfig - var configFile string = "/etc/gagent/gagent.hcl" + config.File = "/etc/gagent/gagent.hcl" config.Name, _ = os.Hostname() config.Mode = "setup" @@ -64,7 +60,6 @@ func main() { * This is used throughout the G'Agent system to uniquely identify this node. * It can be overridden in the configuration file by setting uuid */ - // identity, _ := uuid.NewV5(uuid.NamespaceURL, []byte("gagent"+config.Name)) identity := uuid.NewV4UUID() config.UUID = identity.String() @@ -127,6 +122,7 @@ func main() { usage += " --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 \n" + usage += "\n" /* * Consume the usage variable and the command line arguments to create a @@ -136,7 +132,7 @@ func main() { log.Printf("[DEBUG] Arguments are %v\n", opts) if opts["--config"] != nil { - configFile = opts["--config"].(string) + config.File = opts["--config"].(string) } /* @@ -145,9 +141,9 @@ func main() { if opts["setup"] == true { config.Mode = "setup" } else { - err := hclsimple.DecodeFile(configFile, nil, &config) + err := hclsimple.DecodeFile(config.File, nil, &config) if err != nil { - log.Printf("[ERROR] Failed to load configuration file: %s.\n", configFile) + log.Printf("[ERROR] Failed to load configuration file: %s.\n", config.File) log.Printf("[ERROR] %s\n", err) os.Exit(exitCodes.m["CONFIG_FILE_MISSING"]) } @@ -211,12 +207,8 @@ func main() { os.Exit(exitCodes.m["NO_WORKERS_DEFINED"]) } - http.Handle("/metrics", promhttp.Handler()) - http.ListenAndServe(fmt.Sprintf(":%d", config.ClientPort), nil) - wg.Add(1) go gr.Main(&wg, config) - // select {} case "worker": /* @@ -232,17 +224,11 @@ func main() { os.Exit(exitCodes.m["NO_ROUTERS_DEFINED"]) } - http.Handle("/metrics", promhttp.Handler()) - http.ListenAndServe(fmt.Sprintf(":%d", config.ClientPort), nil) - for key := range config.Routers { wg.Add(1) go gw.Main(&wg, config, key) - // time.Sleep(10 * time.Second) } - // select {} - case "setup": log.Printf("[INFO] Running in setup mode\n") f := hclwrite.NewEmptyFile() diff --git a/internal/client/client.go b/internal/client/client.go index 27b9af6..f99acb3 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -18,7 +18,7 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int, agent string) { log.Printf("[INFO] Starting client\n") // Generate connect string for this router. - var rport = int64(config.ClientPort) + var rport = config.ClientPort if config.Routers[rid].ClientPort != 0 { rport = config.Routers[rid].ClientPort } @@ -41,7 +41,6 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int, agent string) { mu.Unlock() }() - // time.Sleep(10 * time.Millisecond) time.Sleep(10 * time.Millisecond) // for { diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 91bfbbd..0db389b 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -13,6 +13,7 @@ type GagentConfig struct { Routers []*RouterDetails `hcl:"router,block"` Workers []*WorkerDetails `hcl:"worker,block"` Version string + File string } // ClientDetails is details about known clients diff --git a/internal/router/router.go b/internal/router/router.go index e2be3e9..a57cf25 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -21,6 +21,9 @@ const ( // Main is the initiation function for a Router func Main(wg *sync.WaitGroup, config gs.GagentConfig) { defer wg.Done() + http.Handle("/metrics", promhttp.Handler()) + http.HandleFunc("/hello", answerClient) + log.Printf("[INFO] Starting router\n") clientSock, _ := zmq.NewSocket(zmq.ROUTER) @@ -28,12 +31,14 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { workerSock, _ := zmq.NewSocket(zmq.DEALER) defer workerSock.Close() + workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort) + clientListener := fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort) - http.Handle("/metrics", promhttp.Handler()) - http.ListenAndServe(fmt.Sprintf(":%d", config.ClientPort), nil) + go func() { + http.ListenAndServe(clientListener, nil) + }() - // clientSock.Bind(fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.ClientPort)) - workerSock.Bind(fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort)) + workerSock.Bind(workerListener) workers := make([]string, 0) @@ -42,7 +47,6 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { poller2 := zmq.NewPoller() poller2.Add(workerSock, zmq.POLLIN) - // poller2.Add(clientSock, zmq.POLLIN) LOOP: for { @@ -59,11 +63,13 @@ LOOP: } for _, socket := range sockets { switch s := socket.Socket; s { - case workerSock: // Handle worker activity on backend + case workerSock: + // Handle worker activity on backend // Use worker identity for load-balancing msg, err := s.RecvMessage(0) if err != nil { - break LOOP // Interrupted + // Interrupted + break LOOP } var identity string identity, msg = unwrap(msg) @@ -98,27 +104,29 @@ func unwrap(msg []string) (head string, tail []string) { return } -// func answerClient(w http.ResponseWriter, r *http.Request) { -// if r.URL.Path != "/" { -// http.NotFound(w, r) -// return -// } -// -// // Common code for all requests can go here... -// -// switch r.Method { -// case http.MethodGet: -// // Handle the GET request... -// -// case http.MethodPost: -// // Handle the POST request... -// -// case http.MethodOptions: -// w.Header().Set("Allow", "GET, POST, OPTIONS") -// w.WriteHeader(http.StatusNoContent) -// -// default: -// w.Header().Set("Allow", "GET, POST, OPTIONS") -// http.Error(w, "method not allowed", http.StatusMethodNotAllowed) -// } -// } +func answerClient(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/" { + fmt.Fprintf(w, "%v\n", r) + // http.NotFound(w, r) + return + } + + // Common code for all requests can go here... + + switch r.Method { + case http.MethodGet: + fmt.Fprintf(w, "%v\n", r) + // Handle the GET request... + + case http.MethodPost: + // Handle the POST request... + + case http.MethodOptions: + w.Header().Set("Allow", "GET, POST, OPTIONS") + w.WriteHeader(http.StatusNoContent) + + default: + w.Header().Set("Allow", "GET, POST, OPTIONS") + http.Error(w, "method not allowed", http.StatusMethodNotAllowed) + } +} diff --git a/internal/worker/worker.go b/internal/worker/worker.go index e15fd69..eaee293 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -3,6 +3,7 @@ package worker import ( fmt "fmt" log "log" + http "net/http" sync "sync" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" @@ -26,6 +27,10 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int) { subscriber, _ := zmq.NewSocket(zmq.REP) defer subscriber.Close() + go func() { + http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort), nil) + }() + log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) subscriber.Connect(connectString) From 8a7842e6bc6a4d3bbe4f91a87b9f7b1e88edd862 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 18 Oct 2021 05:46:52 -0700 Subject: [PATCH 10/80] Extending prometheus support. --- cmd/gagent/main.go | 43 +++++++++++++++++++-------------------- internal/client/client.go | 8 +++++++- internal/router/router.go | 30 +++++++++++++++++---------- internal/worker/worker.go | 18 +++++++++++++--- 4 files changed, 62 insertions(+), 37 deletions(-) diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 8ef995b..103d483 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,8 +1,10 @@ package main import ( + "fmt" ioutil "io/ioutil" log "log" + http "net/http" os "os" sync "sync" time "time" @@ -13,18 +15,26 @@ import ( gr "git.dragonheim.net/dragonheim/gagent/internal/router" gw "git.dragonheim.net/dragonheim/gagent/internal/worker" + cty "github.com/zclconf/go-cty/cty" + docopt "github.com/aviddiviner/docopt-go" + hclsimple "github.com/hashicorp/hcl/v2/hclsimple" hclwrite "github.com/hashicorp/hcl/v2/hclwrite" + logutils "github.com/hashicorp/logutils" + promhttp "github.com/prometheus/client_golang/prometheus/promhttp" + uuid "github.com/jakehl/goid" - cty "github.com/zclconf/go-cty/cty" ) var ( semVER = "0.0.2" - wg sync.WaitGroup +) + +var ( + wg sync.WaitGroup ) var exitCodes = struct { @@ -49,6 +59,8 @@ func main() { } log.SetOutput(filter) + http.Handle("/metrics", promhttp.Handler()) + var config gs.GagentConfig config.File = "/etc/gagent/gagent.hcl" @@ -135,6 +147,13 @@ func main() { config.File = opts["--config"].(string) } + /* + * Start Prometheus metrics exporter + */ + go func() { + http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort), nil) + }() + /* * Let the command line mode override the configuration. */ @@ -162,13 +181,6 @@ func main() { switch config.Mode { case "client": - /* - * Client mode will send an agent file to a router for processing - * Clients do not process the agent files, only send them as - * requests to a router. If started without arguments, the client - * will contact the router and attempt to retrieve the results - * of it's most recent request. - */ log.Printf("[INFO] Running in client mode\n") if len(config.Routers) == 0 { @@ -193,13 +205,6 @@ func main() { } case "router": - /* - * The 'router' processes routing requests from the agent. The router does - * not handle any of the agent activities beyond processing the agent's - * list of tags and passing the agent and it's storage to either a member - * or client node. Tags are used by the agent to give hints as to where - * it should be routed. - */ log.Printf("[INFO] Running in router mode\n") if len(config.Workers) == 0 { @@ -211,12 +216,6 @@ func main() { go gr.Main(&wg, config) case "worker": - /* - * The 'worker' processes the agent code. The worker nodes do not know - * anything about the network structure. Instead they know only to which - * router(s) they are connected. The worker will execute the agent code and - * pass the agent and it's results to a router. - */ log.Printf("[INFO] Running in worker mode\n") if len(config.Routers) == 0 { diff --git a/internal/client/client.go b/internal/client/client.go index f99acb3..91debbc 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -12,7 +12,13 @@ import ( zmq "github.com/pebbe/zmq4" ) -// Main is the initiation function for a Client +/* + Client mode will send an agent file to a router for processing + Clients do not process the agent files, only send them as + requests to a router. If started without arguments, the client + will contact the router and attempt to retrieve the results + of it's most recent request. +*/ func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int, agent string) { defer wg.Done() log.Printf("[INFO] Starting client\n") diff --git a/internal/router/router.go b/internal/router/router.go index a57cf25..4fb0cdf 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -8,7 +8,8 @@ import ( gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" - promhttp "github.com/prometheus/client_golang/prometheus/promhttp" + prometheus "github.com/prometheus/client_golang/prometheus" + promauto "github.com/prometheus/client_golang/prometheus/promauto" zmq "github.com/pebbe/zmq4" ) @@ -18,10 +19,21 @@ const ( WORKER_READY = "\001" // Signals worker is ready ) -// Main is the initiation function for a Router +var ( + opsProcessed = promauto.NewCounter(prometheus.CounterOpts{ + Name: "client_requests_recieved", + }) +) + +/* + The 'router' processes routing requests from the agent. The router does + not handle any of the agent activities beyond processing the agent's + list of tags and passing the agent and it's storage to either a member + or client node. Tags are used by the agent to give hints as to where + it should be routed. +*/ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { defer wg.Done() - http.Handle("/metrics", promhttp.Handler()) http.HandleFunc("/hello", answerClient) log.Printf("[INFO] Starting router\n") @@ -31,13 +43,8 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { workerSock, _ := zmq.NewSocket(zmq.DEALER) defer workerSock.Close() + workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort) - clientListener := fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort) - - go func() { - http.ListenAndServe(clientListener, nil) - }() - workerSock.Bind(workerListener) workers := make([]string, 0) @@ -106,8 +113,8 @@ func unwrap(msg []string) (head string, tail []string) { func answerClient(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { - fmt.Fprintf(w, "%v\n", r) - // http.NotFound(w, r) + // fmt.Fprintf(w, "%v\n", r) + http.NotFound(w, r) return } @@ -115,6 +122,7 @@ func answerClient(w http.ResponseWriter, r *http.Request) { switch r.Method { case http.MethodGet: + opsProcessed.Inc() fmt.Fprintf(w, "%v\n", r) // Handle the GET request... diff --git a/internal/worker/worker.go b/internal/worker/worker.go index eaee293..d5e5152 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -9,26 +9,38 @@ import ( gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" // picol "git.dragonheim.net/dragonheim/gagent/src/picol" + + promhttp "github.com/prometheus/client_golang/prometheus/promhttp" + zmq "github.com/pebbe/zmq4" ) -// Main is the initiation function for a Worker +/* + The "worker" processes the agent code. The worker nodes do not know + anything about the network structure. Instead they know only to which + router(s) they are connected. The worker will execute the agent code and + pass the agent and it's results to a router. +*/ func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int) { defer wg.Done() + http.Handle("/metrics", promhttp.Handler()) + log.Printf("[INFO] Starting worker\n") // Generate connect string for this router. - var rport = int64(config.WorkerPort) + var rport = config.WorkerPort if config.Routers[rid].WorkerPort != 0 { rport = config.Routers[rid].WorkerPort } connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[rid].RouterAddr, rport) + // workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort) + clientListener := fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort) subscriber, _ := zmq.NewSocket(zmq.REP) defer subscriber.Close() go func() { - http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort), nil) + http.ListenAndServe(clientListener, nil) }() log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) From f47b6846dba4650547344f779c0f1b75a32fde60 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 18 Oct 2021 12:55:28 -0700 Subject: [PATCH 11/80] Removing unsued code --- internal/router/router.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/internal/router/router.go b/internal/router/router.go index 4fb0cdf..6ac0f7e 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -14,11 +14,6 @@ import ( zmq "github.com/pebbe/zmq4" ) -// @TODO -- This was documented in the example, and I am unclear what it does -const ( - WORKER_READY = "\001" // Signals worker is ready -) - var ( opsProcessed = promauto.NewCounter(prometheus.CounterOpts{ Name: "client_requests_recieved", @@ -83,11 +78,6 @@ LOOP: log.Printf("[DEBUG] Worker message received: %s", msg) workers = append(workers, identity) - // Forward message to client if it's not a READY - // if msg[0] != WORKER_READY { - // clientSock.SendMessage(msg) - // } - case clientSock: // Get client request, route to first available worker msg, err := s.RecvMessage(0) @@ -113,6 +103,7 @@ func unwrap(msg []string) (head string, tail []string) { func answerClient(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { + opsProcessed.Inc() // fmt.Fprintf(w, "%v\n", r) http.NotFound(w, r) return @@ -122,7 +113,6 @@ func answerClient(w http.ResponseWriter, r *http.Request) { switch r.Method { case http.MethodGet: - opsProcessed.Inc() fmt.Fprintf(w, "%v\n", r) // Handle the GET request... From 0d0695d195339bd780b22c745fb0c6a05ff295b5 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 25 Oct 2021 12:43:10 -0700 Subject: [PATCH 12/80] Added auto-restart and started playing with init() function --- cmd/gagent/main.go | 108 ++++++++++++++++++++++------------ go.mod | 1 + go.sum | 5 ++ internal/client/client.go | 57 ++++++++---------- internal/gstructs/gstructs.go | 7 +++ internal/worker/worker.go | 42 ++++++++----- 6 files changed, 134 insertions(+), 86 deletions(-) diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 103d483..e2972bc 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,13 +1,14 @@ package main import ( - "fmt" + fmt "fmt" ioutil "io/ioutil" log "log" http "net/http" os "os" sync "sync" - time "time" + + autorestart "github.com/slayer/autorestart" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" @@ -51,7 +52,12 @@ var exitCodes = struct { "AGENT_NOT_DEFINED": 8, }} +var config gs.GagentConfig + func main() { + autorestart.StartWatcher() + http.Handle("/metrics", promhttp.Handler()) + filter := &logutils.LevelFilter{ Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"}, MinLevel: logutils.LogLevel("DEBUG"), @@ -59,48 +65,46 @@ func main() { } log.SetOutput(filter) - http.Handle("/metrics", promhttp.Handler()) + var agent gs.Agent + // config.File = "/etc/gagent/gagent.hcl" - var config gs.GagentConfig - config.File = "/etc/gagent/gagent.hcl" - - config.Name, _ = os.Hostname() - config.Mode = "setup" + // config.Name, _ = os.Hostname() + // config.Mode = "setup" /* * Set a default UUID for this node. * This is used throughout the G'Agent system to uniquely identify this node. * It can be overridden in the configuration file by setting uuid */ - identity := uuid.NewV4UUID() - config.UUID = identity.String() + // identity := uuid.NewV4UUID() + // config.UUID = identity.String() /* * By default, we want to listen on all IP addresses. It can be overridden * in the configuration file by setting listenaddr */ - config.ListenAddr = "0.0.0.0" + // config.ListenAddr = "0.0.0.0" /* * By default, G'Agent client will use port 35571 to communicate with the * routers, but you can override it by setting the clientport in the * configuration file */ - config.ClientPort = 35571 + // config.ClientPort = 35571 /* * By default, G'Agent router will use port 35572 to communicate with * other routers, but you can override it by setting the routerport in * the configuration file */ - config.RouterPort = 35570 + // config.RouterPort = 35570 /* * By default, G'Agent worker will use port 35570 to communicate with the * routers, but you can override it by setting the workerport in the * configuration file */ - config.WorkerPort = 35572 + // config.WorkerPort = 35572 /* * Create a usage variable and then use that to declare the arguments and @@ -115,7 +119,7 @@ func main() { usage += "\n" usage += "Usage: \n" - usage += " gagent client [--config=] [--agent=] \n" + usage += " gagent client (pull|push) [--config=] [--agent=] \n" usage += " gagent router [--config=] \n" usage += " gagent worker [--config=] \n" usage += " gagent setup [--config=] \n" @@ -123,7 +127,8 @@ func main() { usage += "\n" usage += "Arguments: \n" - usage += " client -- Start as a G'Agent client \n" + usage += " client pull -- Start as a G'Agent client to pull agent results \n" + usage += " client push -- Start as a G'Agent client to push agent \n" usage += " router -- Start as a G'Agent router \n" usage += " worker -- Start as a G'Agent worker \n" usage += " setup -- Write initial configuration file \n" @@ -133,7 +138,7 @@ func main() { usage += " -h --help -- Show this help screen and exit \n" usage += " --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 \n" + usage += " --agent= -- filename of the agent to be uploaded to the G'Agent network. Required in push mode \n" usage += "\n" /* @@ -143,6 +148,7 @@ func main() { opts, _ := docopt.ParseArgs(usage, nil, semVER) log.Printf("[DEBUG] Arguments are %v\n", opts) + log.Printf("[DEBUG] Config is %v\n", config) if opts["--config"] != nil { config.File = opts["--config"].(string) } @@ -150,9 +156,7 @@ func main() { /* * Start Prometheus metrics exporter */ - go func() { - http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort), nil) - }() + go http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort), nil) /* * Let the command line mode override the configuration. @@ -162,12 +166,17 @@ func main() { } else { err := hclsimple.DecodeFile(config.File, nil, &config) if err != nil { - log.Printf("[ERROR] Failed to load configuration file: %s.\n", config.File) - log.Printf("[ERROR] %s\n", err) + log.Printf("[ERROR] Failed to load configuration file: %s.\n%s\n", config.File, err) os.Exit(exitCodes.m["CONFIG_FILE_MISSING"]) } if opts["client"] == true { config.Mode = "client" + if opts["pull"] == true { + config.CMode = false + } + if opts["push"] == true { + config.CMode = true + } } if opts["router"] == true { config.Mode = "router" @@ -192,17 +201,19 @@ func main() { log.Printf("[ERROR] Agent file not specified") os.Exit(exitCodes.m["AGENT_NOT_DEFINED"]) } - agent, err := ioutil.ReadFile(opts["--agent"].(string)) - if err != nil { - log.Printf("[ERROR] Failed to load Agent file: %s", opts["--agent"]) - os.Exit(exitCodes.m["AGENT_LOAD_FAILED"]) + + // var agent []byte + var err error + if config.CMode { + agent.ScriptCode, err = ioutil.ReadFile(opts["--agent"].(string)) + if err != nil { + log.Printf("[ERROR] Failed to load Agent file: %s", opts["--agent"]) + os.Exit(exitCodes.m["AGENT_LOAD_FAILED"]) + } } - for key := range config.Routers { - wg.Add(1) - go gc.Main(&wg, config, key, string(agent)) - time.Sleep(10 * time.Second) - } + wg.Add(1) + go gc.Main(&wg, config, string(agent.ScriptCode)) case "router": log.Printf("[INFO] Running in router mode\n") @@ -223,17 +234,15 @@ func main() { os.Exit(exitCodes.m["NO_ROUTERS_DEFINED"]) } - for key := range config.Routers { - wg.Add(1) - go gw.Main(&wg, config, key) - } + wg.Add(1) + go gw.Main(&wg, config) case "setup": log.Printf("[INFO] Running in setup mode\n") f := hclwrite.NewEmptyFile() rootBody := f.Body() rootBody.SetAttributeValue("name", cty.StringVal(config.Name)) - rootBody.SetAttributeValue("mode", cty.StringVal("client")) + rootBody.SetAttributeValue("mode", cty.StringVal(config.Mode)) rootBody.SetAttributeValue("uuid", cty.StringVal(config.UUID)) rootBody.AppendNewline() @@ -254,3 +263,30 @@ func main() { wg.Wait() os.Exit(exitCodes.m["SUCCESS"]) } + +func init() { + // Initialize the configuration + config.Mode = "setup" + config.Name, _ = os.Hostname() + config.UUID = uuid.NewV4UUID().String() + config.ListenAddr = "0.0.0.0" + config.ClientPort = 35571 + config.RouterPort = 35570 + config.WorkerPort = 35572 + config.Clients = make([]*gs.ClientDetails, 0) + config.Routers = make([]*gs.RouterDetails, 0) + config.Workers = make([]*gs.WorkerDetails, 0) + config.File = "/etc/gagent/gagent.hcl" + config.Version = semVER + + // Initialize the exit codes + // exitCodes.m = make(map[string]int) + exitCodes.m["SUCCESS"] = 0 + exitCodes.m["INVALID_MODE"] = 1 + exitCodes.m["CONFIG_FILE_MISSING"] = 2 + exitCodes.m["NO_ROUTERS_DEFINED"] = 3 + exitCodes.m["NO_WORKERS_DEFINED"] = 4 + exitCodes.m["AGENT_NOT_DEFINED"] = 5 + exitCodes.m["AGENT_LOAD_FAILED"] = 6 + +} diff --git a/go.mod b/go.mod index d4b6b59..2c2b5c6 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pebbe/zmq4 v1.2.7 github.com/prometheus/client_golang v1.11.0 + github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b github.com/zclconf/go-cty v1.8.3 golang.org/x/text v0.3.6 // indirect ) diff --git a/go.sum b/go.sum index 1912022..08e819e 100644 --- a/go.sum +++ b/go.sum @@ -91,6 +91,7 @@ github.com/pebbe/zmq4 v1.2.7/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +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 v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= @@ -115,11 +116,14 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b h1:3EujQY7LEbzy5paxa0S2OrsL6+vTwYiUU/R272YlwiQ= +github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b/go.mod h1:p+QQKBy7tS+myk+y3sgnAKx4gUtD/Q9Z6KEd77cLzWY= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= @@ -188,4 +192,5 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/client/client.go b/internal/client/client.go index 91debbc..2cfd256 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -3,7 +3,6 @@ package client import ( fmt "fmt" log "log" - http "net/http" sync "sync" time "time" @@ -19,48 +18,38 @@ import ( will contact the router and attempt to retrieve the results of it's most recent request. */ -func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int, agent string) { +func Main(wg *sync.WaitGroup, config gs.GagentConfig, agent string) { defer wg.Done() log.Printf("[INFO] Starting client\n") - // Generate connect string for this router. - var rport = config.ClientPort - if config.Routers[rid].ClientPort != 0 { - rport = config.Routers[rid].ClientPort - } - connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[rid].RouterAddr, rport) - log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) + for key := range config.Routers { + // Generate connect string for this router. + rport := config.ClientPort + if config.Routers[key].ClientPort != 0 { + rport = config.Routers[key].ClientPort + } + connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport) + wg.Add(1) + go sendAgent(wg, config.UUID, connectString, agent) + time.Sleep(10 * time.Millisecond) + } +} + +func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent string) { + log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) + defer wg.Done() var mu sync.Mutex + mu.Lock() sock, _ := zmq.NewSocket(zmq.REQ) defer sock.Close() - sock.SetIdentity(config.UUID) + sock.SetIdentity(uuid) sock.Connect(connectString) - go func() { - mu.Lock() - log.Printf("[DEBUG] Start sending agent...\n") - sock.SendMessage(agent) - log.Printf("[DEBUG] End sending agent...\n") - mu.Unlock() - }() - - time.Sleep(10 * time.Millisecond) - - // for { - // time.Sleep(10 * time.Millisecond) - // mu.Lock() - // msg, err := sock.RecvMessage(zmq.DONTWAIT) - // if err == nil { - // log.Println(msg[0], config.UUID) - // } - // mu.Unlock() - // } - -} - -func pushAgent(config gs.GagentConfig) { - http.Get(config.Routers[0].RouterAddr) + log.Printf("[DEBUG] Start sending agent...\n") + sock.SendMessage(agent) + log.Printf("[DEBUG] End sending agent...\n") + mu.Unlock() } diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 0db389b..9887a5b 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -14,6 +14,13 @@ type GagentConfig struct { Workers []*WorkerDetails `hcl:"worker,block"` Version string File string + CMode bool +} + +type Agent struct { + Client string + ScriptCode []byte + Hints []*string } // ClientDetails is details about known clients diff --git a/internal/worker/worker.go b/internal/worker/worker.go index d5e5152..793fafd 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -3,47 +3,57 @@ package worker import ( fmt "fmt" log "log" - http "net/http" sync "sync" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" // picol "git.dragonheim.net/dragonheim/gagent/src/picol" - promhttp "github.com/prometheus/client_golang/prometheus/promhttp" + prometheus "github.com/prometheus/client_golang/prometheus" + promauto "github.com/prometheus/client_golang/prometheus/promauto" zmq "github.com/pebbe/zmq4" ) +var ( + opsProcessed = promauto.NewCounter(prometheus.CounterOpts{ + Name: "agent_requests_collected", + }) +) + /* The "worker" processes the agent code. The worker nodes do not know anything about the network structure. Instead they know only to which router(s) they are connected. The worker will execute the agent code and pass the agent and it's results to a router. */ -func Main(wg *sync.WaitGroup, config gs.GagentConfig, rid int) { +func Main(wg *sync.WaitGroup, config gs.GagentConfig) { defer wg.Done() - http.Handle("/metrics", promhttp.Handler()) - log.Printf("[INFO] Starting worker\n") - // Generate connect string for this router. - var rport = config.WorkerPort - if config.Routers[rid].WorkerPort != 0 { - rport = config.Routers[rid].WorkerPort + for key := range config.Routers { + rport := config.WorkerPort + if config.Routers[key].WorkerPort != 0 { + rport = config.Routers[key].WorkerPort + } + + // Generate connect string for this router. + connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport) + + wg.Add(1) + go getAgent(wg, config.UUID, connectString) } - connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[rid].RouterAddr, rport) // workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort) - clientListener := fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort) + +} + +func getAgent(wg *sync.WaitGroup, uuid string, connectString string) { + log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) + defer wg.Done() subscriber, _ := zmq.NewSocket(zmq.REP) defer subscriber.Close() - go func() { - http.ListenAndServe(clientListener, nil) - }() - - log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) subscriber.Connect(connectString) msg, err := subscriber.Recv(0) From 5e69931ed71d999b461bbcde4131e63bc7e964a3 Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 26 Oct 2021 13:21:44 -0700 Subject: [PATCH 13/80] Adding support for a blockchain DB for agent history. --- cmd/gagent/main.go | 262 ++++++++++++++++++---------------- go.mod | 1 + go.sum | 2 + internal/client/client.go | 4 +- internal/gstructs/gstructs.go | 30 ++-- internal/router/router.go | 43 ++++-- internal/worker/worker.go | 4 +- 7 files changed, 199 insertions(+), 147 deletions(-) diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index e2972bc..9a6fb05 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,6 +1,7 @@ package main import ( + sha "crypto/sha256" fmt "fmt" ioutil "io/ioutil" log "log" @@ -8,6 +9,8 @@ import ( os "os" sync "sync" + fqdn "github.com/Showmax/go-fqdn" + autorestart "github.com/slayer/autorestart" gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" @@ -53,11 +56,9 @@ var exitCodes = struct { }} var config gs.GagentConfig +var agent gs.AgentDetails func main() { - autorestart.StartWatcher() - http.Handle("/metrics", promhttp.Handler()) - filter := &logutils.LevelFilter{ Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"}, MinLevel: logutils.LogLevel("DEBUG"), @@ -65,46 +66,153 @@ func main() { } log.SetOutput(filter) - var agent gs.Agent - // config.File = "/etc/gagent/gagent.hcl" + log.Printf("[DEBUG] Configuration is %v\n", config) - // config.Name, _ = os.Hostname() - // config.Mode = "setup" + switch config.Mode { + case "client": + log.Printf("[INFO] Running in client mode\n") + + if len(config.Routers) == 0 { + log.Printf("[ERROR] No routers defined.\n") + os.Exit(exitCodes.m["NO_ROUTERS_DEFINED"]) + } + + var err error + if config.CMode { + agent.ScriptCode, err = ioutil.ReadFile(config.File) + if err != nil { + log.Printf("[ERROR] No such file or directory: %s", config.File) + os.Exit(exitCodes.m["AGENT_LOAD_FAILED"]) + } + agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode)) + agent.Status = "loaded" + log.Printf("[DEBUG] SHA256 of Agent file: %s", agent.Shasum) + } + + wg.Add(1) + go gc.Main(&wg, config, string(agent.ScriptCode)) + + case "router": + log.Printf("[INFO] Running in router mode\n") + + if len(config.Workers) == 0 { + log.Printf("[ERROR] No workers defined.\n") + os.Exit(exitCodes.m["NO_WORKERS_DEFINED"]) + } + + wg.Add(1) + go gr.Main(&wg, config) + + case "worker": + log.Printf("[INFO] Running in worker mode\n") + + if len(config.Routers) == 0 { + log.Printf("[ERROR] No routers defined.\n") + os.Exit(exitCodes.m["NO_ROUTERS_DEFINED"]) + } + + wg.Add(1) + go gw.Main(&wg, config) + + case "setup": + log.Printf("[INFO] Running in setup mode\n") + f := hclwrite.NewEmptyFile() + rootBody := f.Body() + rootBody.SetAttributeValue("name", cty.StringVal(config.Name)) + rootBody.SetAttributeValue("mode", cty.StringVal(config.Mode)) + rootBody.SetAttributeValue("uuid", cty.StringVal(config.UUID)) + rootBody.AppendNewline() + + routerBlock1 := rootBody.AppendNewBlock("router", []string{config.Name}) + routerBody1 := routerBlock1.Body() + routerBody1.SetAttributeValue("routerid", cty.StringVal(config.UUID)) + routerBody1.SetAttributeValue("address", cty.StringVal("127.0.0.1")) + routerBody1.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort)) + rootBody.AppendNewline() + + log.Printf("\n%s", f.Bytes()) + os.Exit(exitCodes.m["SUCCESS"]) + + default: + log.Printf("[ERROR] Unknown operating mode, exiting.\n") + os.Exit(exitCodes.m["INVALID_MODE"]) + } + + wg.Wait() + os.Exit(exitCodes.m["SUCCESS"]) +} + +func init() { + var err error + + autorestart.StartWatcher() + + http.Handle("/metrics", promhttp.Handler()) + + /* + * Start Prometheus metrics exporter + */ + go http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort), nil) + + /* + * Initialize the exit codes + */ + exitCodes.m["SUCCESS"] = 0 + exitCodes.m["INVALID_MODE"] = 1 + exitCodes.m["CONFIG_FILE_MISSING"] = 2 + exitCodes.m["NO_ROUTERS_DEFINED"] = 3 + exitCodes.m["NO_WORKERS_DEFINED"] = 4 + exitCodes.m["AGENT_NOT_DEFINED"] = 5 + exitCodes.m["AGENT_LOAD_FAILED"] = 6 + + /* + * Initialize the configuration + */ + config.Version = semVER + + config.File = "/etc/gagent/gagent.hcl" + + config.Mode = "setup" + + config.Name, _ = fqdn.FqdnHostname() /* * Set a default UUID for this node. * This is used throughout the G'Agent system to uniquely identify this node. * It can be overridden in the configuration file by setting uuid */ - // identity := uuid.NewV4UUID() - // config.UUID = identity.String() + config.UUID = uuid.NewV4UUID().String() /* * By default, we want to listen on all IP addresses. It can be overridden * in the configuration file by setting listenaddr */ - // config.ListenAddr = "0.0.0.0" + config.ListenAddr = "0.0.0.0" /* * By default, G'Agent client will use port 35571 to communicate with the * routers, but you can override it by setting the clientport in the * configuration file */ - // config.ClientPort = 35571 + config.ClientPort = 35571 /* * By default, G'Agent router will use port 35572 to communicate with * other routers, but you can override it by setting the routerport in * the configuration file */ - // config.RouterPort = 35570 + config.RouterPort = 35570 /* * By default, G'Agent worker will use port 35570 to communicate with the * routers, but you can override it by setting the workerport in the * configuration file */ - // config.WorkerPort = 35572 + config.WorkerPort = 35572 + + config.Clients = make([]*gs.ClientDetails, 0) + config.Routers = make([]*gs.RouterDetails, 0) + config.Workers = make([]*gs.WorkerDetails, 0) /* * Create a usage variable and then use that to declare the arguments and @@ -148,15 +256,15 @@ func main() { opts, _ := docopt.ParseArgs(usage, nil, semVER) log.Printf("[DEBUG] Arguments are %v\n", opts) - log.Printf("[DEBUG] Config is %v\n", config) if opts["--config"] != nil { config.File = opts["--config"].(string) } - /* - * Start Prometheus metrics exporter - */ - go http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort), nil) + err = hclsimple.DecodeFile(config.File, nil, &config) + if err != nil && opts["setup"] == false { + log.Printf("[ERROR] Failed to load configuration file: %s.\n", config.File) + os.Exit(exitCodes.m["CONFIG_FILE_MISSING"]) + } /* * Let the command line mode override the configuration. @@ -164,20 +272,24 @@ func main() { if opts["setup"] == true { config.Mode = "setup" } else { - err := hclsimple.DecodeFile(config.File, nil, &config) - if err != nil { - log.Printf("[ERROR] Failed to load configuration file: %s.\n%s\n", config.File, err) - os.Exit(exitCodes.m["CONFIG_FILE_MISSING"]) - } if opts["client"] == true { config.Mode = "client" + if opts["--agent"] == nil { + log.Printf("[ERROR] Agent file not specified") + os.Exit(exitCodes.m["AGENT_NOT_DEFINED"]) + } else { + config.File = opts["--agent"].(string) + } + if opts["pull"] == true { config.CMode = false } + if opts["push"] == true { config.CMode = true } } + if opts["router"] == true { config.Mode = "router" } @@ -185,108 +297,6 @@ func main() { config.Mode = "worker" } } - config.Version = semVER - log.Printf("[DEBUG] Configuration is %v\n", config) - - switch config.Mode { - case "client": - log.Printf("[INFO] Running in client mode\n") - - if len(config.Routers) == 0 { - log.Printf("[ERROR] No routers defined.\n") - os.Exit(exitCodes.m["NO_ROUTERS_DEFINED"]) - } - - if opts["--agent"] == nil { - log.Printf("[ERROR] Agent file not specified") - os.Exit(exitCodes.m["AGENT_NOT_DEFINED"]) - } - - // var agent []byte - var err error - if config.CMode { - agent.ScriptCode, err = ioutil.ReadFile(opts["--agent"].(string)) - if err != nil { - log.Printf("[ERROR] Failed to load Agent file: %s", opts["--agent"]) - os.Exit(exitCodes.m["AGENT_LOAD_FAILED"]) - } - } - - wg.Add(1) - go gc.Main(&wg, config, string(agent.ScriptCode)) - - case "router": - log.Printf("[INFO] Running in router mode\n") - - if len(config.Workers) == 0 { - log.Printf("[ERROR] No workers defined.\n") - os.Exit(exitCodes.m["NO_WORKERS_DEFINED"]) - } - - wg.Add(1) - go gr.Main(&wg, config) - - case "worker": - log.Printf("[INFO] Running in worker mode\n") - - if len(config.Routers) == 0 { - log.Printf("[ERROR] No routers defined.\n") - os.Exit(exitCodes.m["NO_ROUTERS_DEFINED"]) - } - - wg.Add(1) - go gw.Main(&wg, config) - - case "setup": - log.Printf("[INFO] Running in setup mode\n") - f := hclwrite.NewEmptyFile() - rootBody := f.Body() - rootBody.SetAttributeValue("name", cty.StringVal(config.Name)) - rootBody.SetAttributeValue("mode", cty.StringVal(config.Mode)) - rootBody.SetAttributeValue("uuid", cty.StringVal(config.UUID)) - rootBody.AppendNewline() - - routerBlock1 := rootBody.AppendNewBlock("router", []string{config.Name}) - routerBody1 := routerBlock1.Body() - routerBody1.SetAttributeValue("routerid", cty.StringVal(config.UUID)) - routerBody1.SetAttributeValue("address", cty.StringVal("127.0.0.1")) - rootBody.AppendNewline() - - log.Printf("\n%s", f.Bytes()) - os.Exit(exitCodes.m["SUCCESS"]) - - default: - log.Printf("[ERROR] Unknown operating mode, exiting.\n") - os.Exit(exitCodes.m["INVALID_MODE"]) - } - - wg.Wait() - os.Exit(exitCodes.m["SUCCESS"]) -} - -func init() { - // Initialize the configuration - config.Mode = "setup" - config.Name, _ = os.Hostname() - config.UUID = uuid.NewV4UUID().String() - config.ListenAddr = "0.0.0.0" - config.ClientPort = 35571 - config.RouterPort = 35570 - config.WorkerPort = 35572 - config.Clients = make([]*gs.ClientDetails, 0) - config.Routers = make([]*gs.RouterDetails, 0) - config.Workers = make([]*gs.WorkerDetails, 0) - config.File = "/etc/gagent/gagent.hcl" - config.Version = semVER - - // Initialize the exit codes - // exitCodes.m = make(map[string]int) - exitCodes.m["SUCCESS"] = 0 - exitCodes.m["INVALID_MODE"] = 1 - exitCodes.m["CONFIG_FILE_MISSING"] = 2 - exitCodes.m["NO_ROUTERS_DEFINED"] = 3 - exitCodes.m["NO_WORKERS_DEFINED"] = 4 - exitCodes.m["AGENT_NOT_DEFINED"] = 5 - exitCodes.m["AGENT_LOAD_FAILED"] = 6 + log.Printf("[DEBUG] Config is %v\n", config) } diff --git a/go.mod b/go.mod index 2c2b5c6..0deade1 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module git.dragonheim.net/dragonheim/gagent go 1.16 require ( + github.com/Showmax/go-fqdn v1.0.0 github.com/agext/levenshtein v1.2.3 // indirect github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a github.com/hashicorp/hcl/v2 v2.10.1 diff --git a/go.sum b/go.sum index 08e819e..77f0996 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Showmax/go-fqdn v1.0.0 h1:0rG5IbmVliNT5O19Mfuvna9LL7zlHyRfsSvBPZmF9tM= +github.com/Showmax/go-fqdn v1.0.0/go.mod h1:SfrFBzmDCtCGrnHhoDjuvFnKsWjEQX/Q9ARZvOrJAko= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= diff --git a/internal/client/client.go b/internal/client/client.go index 2cfd256..34c416b 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -23,7 +23,9 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig, agent string) { log.Printf("[INFO] Starting client\n") for key := range config.Routers { - // Generate connect string for this router. + /* + * Generate connect string for this router. + */ rport := config.ClientPort if config.Routers[key].ClientPort != 0 { rport = config.Routers[key].ClientPort diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 9887a5b..50c2427 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -17,13 +17,9 @@ type GagentConfig struct { CMode bool } -type Agent struct { - Client string - ScriptCode []byte - Hints []*string -} - -// ClientDetails is details about known clients +/* + * ClientDetails are details about known clients + */ type ClientDetails struct { /* * Client name for display purposes in logs and @@ -40,7 +36,9 @@ type ClientDetails struct { ClientID string `hcl:"clientid,optional"` } -// RouterDetails is details about known routers +/* + * RouterDetails is details about known routers + */ type RouterDetails struct { /* * Router name for display purposes in logs and @@ -93,7 +91,9 @@ type RouterDetails struct { RouterTags []string `hcl:"tags,optional"` } -// WorkerDetails is details about known workers +/* + * WorkerDetails is details about known workers + */ type WorkerDetails struct { /* * Router name for display purposes in logs and @@ -117,3 +117,15 @@ type WorkerDetails struct { */ WorkerTags []string `hcl:"tags,optional"` } + +type BlockChainDB struct { + DBName string `hcl:"chain_id,optional"` + Agents []*AgentDetails `hcl:"agent,block"` +} +type AgentDetails struct { + ScriptCode []byte + Hints []*string + Client string `hcl:"client"` + Shasum string `hcl:"shasum"` + Status string `hcl:"status"` +} diff --git a/internal/router/router.go b/internal/router/router.go index 6ac0f7e..ae325e2 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -52,7 +52,9 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { LOOP: for { - // Poll frontend only if we have available workers + /* + * Poll frontend only if we have available workers + */ var sockets []zmq.Polled var err error if len(workers) > 0 { @@ -61,16 +63,23 @@ LOOP: sockets, err = poller1.Poll(-1) } if err != nil { - break // Interrupted + /* + * Interrupt + */ + break } for _, socket := range sockets { switch s := socket.Socket; s { case workerSock: - // Handle worker activity on backend - // Use worker identity for load-balancing + /* + * Handle worker activity on backend + * Use worker identity for load-balancing + */ msg, err := s.RecvMessage(0) if err != nil { - // Interrupted + /* + * Interrupt + */ break LOOP } var identity string @@ -79,7 +88,9 @@ LOOP: workers = append(workers, identity) case clientSock: - // Get client request, route to first available worker + /* + * Get client request, route to first available worker + */ msg, err := s.RecvMessage(0) log.Printf("[DEBUG] Client message received: %s", msg) if err == nil { @@ -109,20 +120,32 @@ func answerClient(w http.ResponseWriter, r *http.Request) { return } - // Common code for all requests can go here... - + /* + * Common code for all requests can go here... + */ switch r.Method { + /* + * Handle GET requests + */ case http.MethodGet: fmt.Fprintf(w, "%v\n", r) - // Handle the GET request... + /* + * Handle POST requests + */ case http.MethodPost: - // Handle the POST request... + fmt.Fprintf(w, "%v\n", r) + /* + * Handle PUT requests + */ case http.MethodOptions: w.Header().Set("Allow", "GET, POST, OPTIONS") w.WriteHeader(http.StatusNoContent) + /* + * Handle everything else + */ default: w.Header().Set("Allow", "GET, POST, OPTIONS") http.Error(w, "method not allowed", http.StatusMethodNotAllowed) diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 793fafd..9bc50d2 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -37,7 +37,9 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { rport = config.Routers[key].WorkerPort } - // Generate connect string for this router. + /* + * Generate connect string for this router. + */ connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport) wg.Add(1) From 7a2ca771f20a16c0d54fc345c8cca3d9224ccff6 Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 26 Oct 2021 15:28:53 -0700 Subject: [PATCH 14/80] Extending the setup mode. --- assets/examples/genesis.hcl | 11 +++++++++++ assets/examples/genesis.json | 12 ++++++++++++ cmd/gagent/main.go | 31 ++++++++++++++++++++----------- 3 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 assets/examples/genesis.hcl create mode 100644 assets/examples/genesis.json diff --git a/assets/examples/genesis.hcl b/assets/examples/genesis.hcl new file mode 100644 index 0000000..a727414 --- /dev/null +++ b/assets/examples/genesis.hcl @@ -0,0 +1,11 @@ +"genesis_time" = "2021-10-25:00:00.000000000Z" +"chain_id" = "gagent_ledger" + +"agent" = { + "client" = "7e9d13fe-5151-5876-66c0-20ca03e8fca4" + "shasum" = "a76f7c3c7bc0f94b4f8aa63c605f8534db5675bb05d761f4461127fcadbf32d4" + "status" = "complete" +} +"clients" = { + "client" = "7e9d13fe-5151-5876-66c0-20ca03e8fca4" +} diff --git a/assets/examples/genesis.json b/assets/examples/genesis.json new file mode 100644 index 0000000..927d69e --- /dev/null +++ b/assets/examples/genesis.json @@ -0,0 +1,12 @@ +{ + "genesis_time": "2021-10-25:00:00.000000000Z", + "chain_id": "gagent_ledger", + "agent": { + "client": "7e9d13fe-5151-5876-66c0-20ca03e8fca4", + "shasum": "a76f7c3c7bc0f94b4f8aa63c605f8534db5675bb05d761f4461127fcadbf32d4", + "status": "complete" + }, + "clients": { + "client": "7e9d13fe-5151-5876-66c0-20ca03e8fca4" + } +} \ No newline at end of file diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 9a6fb05..197988b 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -43,17 +43,7 @@ var ( var exitCodes = struct { m map[string]int -}{m: map[string]int{ - "SUCCESS": 0, - "CONFIG_FILE_MISSING": 1, - "SETUP_FAILED": 2, - "INVALID_MODE": 3, - "AGENT_LOAD_FAILED": 4, - "AGENT_MISSING_TAGS": 5, - "NO_ROUTERS_DEFINED": 6, - "NO_WORKERS_DEFINED": 7, - "AGENT_NOT_DEFINED": 8, -}} +}{m: map[string]int{}} var config gs.GagentConfig var agent gs.AgentDetails @@ -121,6 +111,15 @@ func main() { rootBody.SetAttributeValue("name", cty.StringVal(config.Name)) rootBody.SetAttributeValue("mode", cty.StringVal(config.Mode)) rootBody.SetAttributeValue("uuid", cty.StringVal(config.UUID)) + rootBody.SetAttributeValue("listenaddr", cty.StringVal("0.0.0.0")) + rootBody.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort)) + rootBody.SetAttributeValue("routerport", cty.NumberIntVal(config.RouterPort)) + rootBody.SetAttributeValue("workerport", cty.NumberIntVal(config.WorkerPort)) + rootBody.AppendNewline() + + clientBlock1 := rootBody.AppendNewBlock("client", []string{config.Name}) + clientBody1 := clientBlock1.Body() + clientBody1.SetAttributeValue("clientid", cty.StringVal(config.UUID)) rootBody.AppendNewline() routerBlock1 := rootBody.AppendNewBlock("router", []string{config.Name}) @@ -128,6 +127,13 @@ func main() { routerBody1.SetAttributeValue("routerid", cty.StringVal(config.UUID)) routerBody1.SetAttributeValue("address", cty.StringVal("127.0.0.1")) routerBody1.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort)) + routerBody1.SetAttributeValue("routerport", cty.NumberIntVal(config.RouterPort)) + routerBody1.SetAttributeValue("workerport", cty.NumberIntVal(config.WorkerPort)) + rootBody.AppendNewline() + + workerBlock1 := rootBody.AppendNewBlock("worker", []string{config.Name}) + workerBody1 := workerBlock1.Body() + workerBody1.SetAttributeValue("workerid", cty.StringVal(config.UUID)) rootBody.AppendNewline() log.Printf("\n%s", f.Bytes()) @@ -164,6 +170,8 @@ func init() { exitCodes.m["NO_WORKERS_DEFINED"] = 4 exitCodes.m["AGENT_NOT_DEFINED"] = 5 exitCodes.m["AGENT_LOAD_FAILED"] = 6 + exitCodes.m["AGENT_MISSING_TAGS"] = 7 + exitCodes.m["AGENT_NOT_DEFINED"] = 8 /* * Initialize the configuration @@ -293,6 +301,7 @@ func init() { if opts["router"] == true { config.Mode = "router" } + if opts["worker"] == true { config.Mode = "worker" } From 52f8d521cdf54b1f3a13f84c4744cd08fc2ea4ad Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 26 Oct 2021 16:12:46 -0700 Subject: [PATCH 15/80] Router listen port was not listening on the correct port. --- internal/gstructs/gstructs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 50c2427..58a38f9 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -73,7 +73,7 @@ type RouterDetails struct { * on for routers. If not defined, it will default * to 35570. */ - RouterPort int64 `hcl:"workerport,optional"` + RouterPort int64 `hcl:"routerport,optional"` /* * This is the is the port that the router listens From 8515707300897158b978f3db27d01303189a1a6f Mon Sep 17 00:00:00 2001 From: James Wells Date: Wed, 3 Nov 2021 15:09:02 -0700 Subject: [PATCH 16/80] Changed chain_id to chainid --- assets/examples/genesis.hcl | 2 +- assets/examples/genesis.json | 2 +- internal/gstructs/gstructs.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/examples/genesis.hcl b/assets/examples/genesis.hcl index a727414..2fe7d4c 100644 --- a/assets/examples/genesis.hcl +++ b/assets/examples/genesis.hcl @@ -1,5 +1,5 @@ "genesis_time" = "2021-10-25:00:00.000000000Z" -"chain_id" = "gagent_ledger" +"chainid" = "gagent_ledger" "agent" = { "client" = "7e9d13fe-5151-5876-66c0-20ca03e8fca4" diff --git a/assets/examples/genesis.json b/assets/examples/genesis.json index 927d69e..e92a2ff 100644 --- a/assets/examples/genesis.json +++ b/assets/examples/genesis.json @@ -1,6 +1,6 @@ { "genesis_time": "2021-10-25:00:00.000000000Z", - "chain_id": "gagent_ledger", + "chainid": "gagent_ledger", "agent": { "client": "7e9d13fe-5151-5876-66c0-20ca03e8fca4", "shasum": "a76f7c3c7bc0f94b4f8aa63c605f8534db5675bb05d761f4461127fcadbf32d4", diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 58a38f9..a73bc63 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -119,13 +119,13 @@ type WorkerDetails struct { } type BlockChainDB struct { - DBName string `hcl:"chain_id,optional"` + DBName string `hcl:"chainid,optional"` Agents []*AgentDetails `hcl:"agent,block"` } type AgentDetails struct { - ScriptCode []byte - Hints []*string Client string `hcl:"client"` Shasum string `hcl:"shasum"` Status string `hcl:"status"` + ScriptCode []byte + Hints []*string } From 7e5158483291c30c7fa27c9787ef57fac2b1b739 Mon Sep 17 00:00:00 2001 From: James Wells Date: Sat, 6 Nov 2021 19:57:49 -0700 Subject: [PATCH 17/80] Moved setup into a separate file. --- cmd/gagent/main.go | 51 ++++++++--------------------------------- internal/setup/setup.go | 49 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 42 deletions(-) create mode 100644 internal/setup/setup.go diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 197988b..42cd093 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -13,18 +13,16 @@ import ( autorestart "github.com/slayer/autorestart" - gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gstruct "git.dragonheim.net/dragonheim/gagent/internal/gstructs" gc "git.dragonheim.net/dragonheim/gagent/internal/client" gr "git.dragonheim.net/dragonheim/gagent/internal/router" + gs "git.dragonheim.net/dragonheim/gagent/internal/setup" gw "git.dragonheim.net/dragonheim/gagent/internal/worker" - cty "github.com/zclconf/go-cty/cty" - docopt "github.com/aviddiviner/docopt-go" hclsimple "github.com/hashicorp/hcl/v2/hclsimple" - hclwrite "github.com/hashicorp/hcl/v2/hclwrite" logutils "github.com/hashicorp/logutils" @@ -45,8 +43,8 @@ var exitCodes = struct { m map[string]int }{m: map[string]int{}} -var config gs.GagentConfig -var agent gs.AgentDetails +var config gstruct.GagentConfig +var agent gstruct.AgentDetails func main() { filter := &logutils.LevelFilter{ @@ -105,39 +103,8 @@ func main() { go gw.Main(&wg, config) case "setup": - log.Printf("[INFO] Running in setup mode\n") - f := hclwrite.NewEmptyFile() - rootBody := f.Body() - rootBody.SetAttributeValue("name", cty.StringVal(config.Name)) - rootBody.SetAttributeValue("mode", cty.StringVal(config.Mode)) - rootBody.SetAttributeValue("uuid", cty.StringVal(config.UUID)) - rootBody.SetAttributeValue("listenaddr", cty.StringVal("0.0.0.0")) - rootBody.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort)) - rootBody.SetAttributeValue("routerport", cty.NumberIntVal(config.RouterPort)) - rootBody.SetAttributeValue("workerport", cty.NumberIntVal(config.WorkerPort)) - rootBody.AppendNewline() - - clientBlock1 := rootBody.AppendNewBlock("client", []string{config.Name}) - clientBody1 := clientBlock1.Body() - clientBody1.SetAttributeValue("clientid", cty.StringVal(config.UUID)) - rootBody.AppendNewline() - - routerBlock1 := rootBody.AppendNewBlock("router", []string{config.Name}) - routerBody1 := routerBlock1.Body() - routerBody1.SetAttributeValue("routerid", cty.StringVal(config.UUID)) - routerBody1.SetAttributeValue("address", cty.StringVal("127.0.0.1")) - routerBody1.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort)) - routerBody1.SetAttributeValue("routerport", cty.NumberIntVal(config.RouterPort)) - routerBody1.SetAttributeValue("workerport", cty.NumberIntVal(config.WorkerPort)) - rootBody.AppendNewline() - - workerBlock1 := rootBody.AppendNewBlock("worker", []string{config.Name}) - workerBody1 := workerBlock1.Body() - workerBody1.SetAttributeValue("workerid", cty.StringVal(config.UUID)) - rootBody.AppendNewline() - - log.Printf("\n%s", f.Bytes()) - os.Exit(exitCodes.m["SUCCESS"]) + wg.Add(1) + go gs.Main(&wg, config) default: log.Printf("[ERROR] Unknown operating mode, exiting.\n") @@ -218,9 +185,9 @@ func init() { */ config.WorkerPort = 35572 - config.Clients = make([]*gs.ClientDetails, 0) - config.Routers = make([]*gs.RouterDetails, 0) - config.Workers = make([]*gs.WorkerDetails, 0) + config.Clients = make([]*gstruct.ClientDetails, 0) + config.Routers = make([]*gstruct.RouterDetails, 0) + config.Workers = make([]*gstruct.WorkerDetails, 0) /* * Create a usage variable and then use that to declare the arguments and diff --git a/internal/setup/setup.go b/internal/setup/setup.go new file mode 100644 index 0000000..015b117 --- /dev/null +++ b/internal/setup/setup.go @@ -0,0 +1,49 @@ +package setup + +import ( + log "log" + sync "sync" + + cty "github.com/zclconf/go-cty/cty" + + gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + + hclwrite "github.com/hashicorp/hcl/v2/hclwrite" +) + +func Main(wg *sync.WaitGroup, config gs.GagentConfig) { + log.Printf("[INFO] Running in setup mode\n") + defer wg.Done() + + f := hclwrite.NewEmptyFile() + rootBody := f.Body() + rootBody.SetAttributeValue("name", cty.StringVal(config.Name)) + rootBody.SetAttributeValue("mode", cty.StringVal(config.Mode)) + rootBody.SetAttributeValue("uuid", cty.StringVal(config.UUID)) + rootBody.SetAttributeValue("listenaddr", cty.StringVal("0.0.0.0")) + rootBody.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort)) + rootBody.SetAttributeValue("routerport", cty.NumberIntVal(config.RouterPort)) + rootBody.SetAttributeValue("workerport", cty.NumberIntVal(config.WorkerPort)) + rootBody.AppendNewline() + + clientBlock1 := rootBody.AppendNewBlock("client", []string{config.Name}) + clientBody1 := clientBlock1.Body() + clientBody1.SetAttributeValue("clientid", cty.StringVal(config.UUID)) + rootBody.AppendNewline() + + routerBlock1 := rootBody.AppendNewBlock("router", []string{config.Name}) + routerBody1 := routerBlock1.Body() + routerBody1.SetAttributeValue("routerid", cty.StringVal(config.UUID)) + routerBody1.SetAttributeValue("address", cty.StringVal("127.0.0.1")) + routerBody1.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort)) + routerBody1.SetAttributeValue("routerport", cty.NumberIntVal(config.RouterPort)) + routerBody1.SetAttributeValue("workerport", cty.NumberIntVal(config.WorkerPort)) + rootBody.AppendNewline() + + workerBlock1 := rootBody.AppendNewBlock("worker", []string{config.Name}) + workerBody1 := workerBlock1.Body() + workerBody1.SetAttributeValue("workerid", cty.StringVal(config.UUID)) + rootBody.AppendNewline() + + log.Printf("[DEBUG] Configuration file created;\n\n%s\n", f.Bytes()) +} From de41740bac9c803741e6025ab7afead37a35b630 Mon Sep 17 00:00:00 2001 From: James Wells Date: Sat, 6 Nov 2021 20:18:49 -0700 Subject: [PATCH 18/80] A bit more refactor to clean up the code. --- cmd/gagent/main.go | 30 +++++++++--------------------- internal/client/client.go | 28 +++++++++++++++++++++++----- internal/router/router.go | 9 ++++----- internal/setup/setup.go | 2 +- internal/worker/worker.go | 6 +++--- 5 files changed, 40 insertions(+), 35 deletions(-) diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 42cd093..bc1fd5f 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,9 +1,7 @@ package main import ( - sha "crypto/sha256" fmt "fmt" - ioutil "io/ioutil" log "log" http "net/http" os "os" @@ -13,7 +11,7 @@ import ( autorestart "github.com/slayer/autorestart" - gstruct "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" gc "git.dragonheim.net/dragonheim/gagent/internal/client" gr "git.dragonheim.net/dragonheim/gagent/internal/router" @@ -43,8 +41,8 @@ var exitCodes = struct { m map[string]int }{m: map[string]int{}} -var config gstruct.GagentConfig -var agent gstruct.AgentDetails +var config gstructs.GagentConfig +var agent gstructs.AgentDetails func main() { filter := &logutils.LevelFilter{ @@ -65,20 +63,8 @@ func main() { os.Exit(exitCodes.m["NO_ROUTERS_DEFINED"]) } - var err error - if config.CMode { - agent.ScriptCode, err = ioutil.ReadFile(config.File) - if err != nil { - log.Printf("[ERROR] No such file or directory: %s", config.File) - os.Exit(exitCodes.m["AGENT_LOAD_FAILED"]) - } - agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode)) - agent.Status = "loaded" - log.Printf("[DEBUG] SHA256 of Agent file: %s", agent.Shasum) - } - wg.Add(1) - go gc.Main(&wg, config, string(agent.ScriptCode)) + go gc.Main(&wg, config) case "router": log.Printf("[INFO] Running in router mode\n") @@ -103,6 +89,8 @@ func main() { go gw.Main(&wg, config) case "setup": + log.Printf("[INFO] Running in setup mode\n") + wg.Add(1) go gs.Main(&wg, config) @@ -185,9 +173,9 @@ func init() { */ config.WorkerPort = 35572 - config.Clients = make([]*gstruct.ClientDetails, 0) - config.Routers = make([]*gstruct.RouterDetails, 0) - config.Workers = make([]*gstruct.WorkerDetails, 0) + config.Clients = make([]*gstructs.ClientDetails, 0) + config.Routers = make([]*gstructs.RouterDetails, 0) + config.Workers = make([]*gstructs.WorkerDetails, 0) /* * Create a usage variable and then use that to declare the arguments and diff --git a/internal/client/client.go b/internal/client/client.go index 34c416b..c6c2435 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -1,12 +1,15 @@ package client import ( + sha "crypto/sha256" fmt "fmt" + ioutil "io/ioutil" log "log" + os "os" sync "sync" time "time" - gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" zmq "github.com/pebbe/zmq4" ) @@ -18,9 +21,23 @@ import ( will contact the router and attempt to retrieve the results of it's most recent request. */ -func Main(wg *sync.WaitGroup, config gs.GagentConfig, agent string) { - defer wg.Done() +func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting client\n") + defer wg.Done() + + var agent gstructs.AgentDetails + var err error + + if config.CMode { + agent.ScriptCode, err = ioutil.ReadFile(config.File) + if err != nil { + log.Printf("[ERROR] No such file or directory: %s", config.File) + os.Exit(6) + } + agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode)) + agent.Status = "loaded" + log.Printf("[DEBUG] SHA256 of Agent file: %s", agent.Shasum) + } for key := range config.Routers { /* @@ -33,14 +50,15 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig, agent string) { connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport) wg.Add(1) - go sendAgent(wg, config.UUID, connectString, agent) + go sendAgent(wg, config.UUID, connectString, agent.ScriptCode) time.Sleep(10 * time.Millisecond) } } -func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent string) { +func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent []byte) { log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) defer wg.Done() + var mu sync.Mutex mu.Lock() diff --git a/internal/router/router.go b/internal/router/router.go index ae325e2..bb337f3 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -6,7 +6,7 @@ import ( http "net/http" sync "sync" - gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" prometheus "github.com/prometheus/client_golang/prometheus" promauto "github.com/prometheus/client_golang/prometheus/promauto" @@ -27,12 +27,11 @@ var ( or client node. Tags are used by the agent to give hints as to where it should be routed. */ -func Main(wg *sync.WaitGroup, config gs.GagentConfig) { - defer wg.Done() - http.HandleFunc("/hello", answerClient) - +func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting router\n") + defer wg.Done() + http.HandleFunc("/hello", answerClient) clientSock, _ := zmq.NewSocket(zmq.ROUTER) defer clientSock.Close() diff --git a/internal/setup/setup.go b/internal/setup/setup.go index 015b117..8c3357d 100644 --- a/internal/setup/setup.go +++ b/internal/setup/setup.go @@ -12,7 +12,7 @@ import ( ) func Main(wg *sync.WaitGroup, config gs.GagentConfig) { - log.Printf("[INFO] Running in setup mode\n") + log.Printf("[INFO] setup mode\n") defer wg.Done() f := hclwrite.NewEmptyFile() diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 9bc50d2..6f0d585 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -5,7 +5,7 @@ import ( log "log" sync "sync" - gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" // picol "git.dragonheim.net/dragonheim/gagent/src/picol" @@ -27,9 +27,9 @@ var ( router(s) they are connected. The worker will execute the agent code and pass the agent and it's results to a router. */ -func Main(wg *sync.WaitGroup, config gs.GagentConfig) { - defer wg.Done() +func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting worker\n") + defer wg.Done() for key := range config.Routers { rport := config.WorkerPort From abba1972d140cfdfdf658ea2bf5e8b73a09f8565 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 8 Nov 2021 06:58:55 -0800 Subject: [PATCH 19/80] Converted TCL list style and added hint parser. --- README.md | 2 +- assets/examples/hello-earth.tcl | 2 +- cmd/gagent/main.go | 82 +++++++++++++++++---------------- internal/client/client.go | 46 +++++++++++++++--- internal/gstructs/gstructs.go | 29 ++++++------ internal/setup/setup.go | 2 +- 6 files changed, 100 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index f8f2141..f97ed54 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Imagine, for a moment, that you are on Mars and need to perform a data search in 1 : ################### 2 : ### Hello Earth ### 3 : ################### -4 : array set GHINT ["thermal measurements" "gravity measurements" "gravity fluctuations"] +4 : set GHINT [split "thermal measurements, gravity measurements, gravity fluctuations" ,] 5 : proc hello_earth {} { 6 : puts "Hello Earth, does localized tempurature variations alter specific gravity?" 7 : } diff --git a/assets/examples/hello-earth.tcl b/assets/examples/hello-earth.tcl index 845fb0e..5a2d120 100644 --- a/assets/examples/hello-earth.tcl +++ b/assets/examples/hello-earth.tcl @@ -1,7 +1,7 @@ ################### ### Hello Earth ### ################### -array set GHINT ["thermal measurements" "gravity measurements" "gravity fluctuations"] +set GHINT [split "thermal measurements, gravity measurements, gravity fluctuations" ,] proc hello_earth {} { puts "Hello Earth, does localized tempurature variations alter specific gravity?" } diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index bc1fd5f..3736ac9 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -30,28 +30,31 @@ import ( ) var ( - semVER = "0.0.2" + semVER = "0.0.3" ) var ( wg sync.WaitGroup ) -var exitCodes = struct { - m map[string]int -}{m: map[string]int{}} +/* + * Exit Codes + * 0 Success + * 1 Configuration file is missing or unreadable + * 2 Setup failed + * 3 Invalid mode of operation + * 4 Agent file is missing or unreadable + * 5 Agent is missing tags + * 6 No routers defined + * 7 No workers defined + * 8 Agent not defined + * 9 Agent hints / tags not defined + * 10 Router not connected + */ var config gstructs.GagentConfig -var agent gstructs.AgentDetails func main() { - filter := &logutils.LevelFilter{ - Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"}, - MinLevel: logutils.LogLevel("DEBUG"), - Writer: os.Stderr, - } - log.SetOutput(filter) - log.Printf("[DEBUG] Configuration is %v\n", config) switch config.Mode { @@ -60,7 +63,7 @@ func main() { if len(config.Routers) == 0 { log.Printf("[ERROR] No routers defined.\n") - os.Exit(exitCodes.m["NO_ROUTERS_DEFINED"]) + os.Exit(6) } wg.Add(1) @@ -71,7 +74,7 @@ func main() { if len(config.Workers) == 0 { log.Printf("[ERROR] No workers defined.\n") - os.Exit(exitCodes.m["NO_WORKERS_DEFINED"]) + os.Exit(7) } wg.Add(1) @@ -82,7 +85,7 @@ func main() { if len(config.Routers) == 0 { log.Printf("[ERROR] No routers defined.\n") - os.Exit(exitCodes.m["NO_ROUTERS_DEFINED"]) + os.Exit(6) } wg.Add(1) @@ -96,38 +99,27 @@ func main() { default: log.Printf("[ERROR] Unknown operating mode, exiting.\n") - os.Exit(exitCodes.m["INVALID_MODE"]) + os.Exit(3) } wg.Wait() - os.Exit(exitCodes.m["SUCCESS"]) + os.Exit(0) } func init() { - var err error + // var err error autorestart.StartWatcher() + filter := &logutils.LevelFilter{ + Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"}, + MinLevel: logutils.LogLevel("DEBUG"), + Writer: os.Stderr, + } + log.SetOutput(filter) + http.Handle("/metrics", promhttp.Handler()) - /* - * Start Prometheus metrics exporter - */ - go http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.ClientPort), nil) - - /* - * Initialize the exit codes - */ - exitCodes.m["SUCCESS"] = 0 - exitCodes.m["INVALID_MODE"] = 1 - exitCodes.m["CONFIG_FILE_MISSING"] = 2 - exitCodes.m["NO_ROUTERS_DEFINED"] = 3 - exitCodes.m["NO_WORKERS_DEFINED"] = 4 - exitCodes.m["AGENT_NOT_DEFINED"] = 5 - exitCodes.m["AGENT_LOAD_FAILED"] = 6 - exitCodes.m["AGENT_MISSING_TAGS"] = 7 - exitCodes.m["AGENT_NOT_DEFINED"] = 8 - /* * Initialize the configuration */ @@ -152,6 +144,12 @@ func init() { */ config.ListenAddr = "0.0.0.0" + /* + * By default, G'Agent will use port 9101 or monitoring via prometheus. + * It can be overridden in the configuration file by setting clientport + */ + config.MonitorPort = 9101 + /* * By default, G'Agent client will use port 35571 to communicate with the * routers, but you can override it by setting the clientport in the @@ -223,10 +221,10 @@ func init() { config.File = opts["--config"].(string) } - err = hclsimple.DecodeFile(config.File, nil, &config) + err := hclsimple.DecodeFile(config.File, nil, &config) if err != nil && opts["setup"] == false { log.Printf("[ERROR] Failed to load configuration file: %s.\n", config.File) - os.Exit(exitCodes.m["CONFIG_FILE_MISSING"]) + os.Exit(1) } /* @@ -239,7 +237,7 @@ func init() { config.Mode = "client" if opts["--agent"] == nil { log.Printf("[ERROR] Agent file not specified") - os.Exit(exitCodes.m["AGENT_NOT_DEFINED"]) + os.Exit(8) } else { config.File = opts["--agent"].(string) } @@ -263,4 +261,10 @@ func init() { } log.Printf("[DEBUG] Config is %v\n", config) + + /* + * Start Prometheus metrics exporter + */ + go http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.MonitorPort), nil) + } diff --git a/internal/client/client.go b/internal/client/client.go index c6c2435..d069837 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -6,6 +6,8 @@ import ( ioutil "io/ioutil" log "log" os "os" + regexp "regexp" + strings "strings" sync "sync" time "time" @@ -32,12 +34,14 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { agent.ScriptCode, err = ioutil.ReadFile(config.File) if err != nil { log.Printf("[ERROR] No such file or directory: %s", config.File) - os.Exit(6) + os.Exit(4) } agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode)) agent.Status = "loaded" - log.Printf("[DEBUG] SHA256 of Agent file: %s", agent.Shasum) + log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum) + log.Printf("[DEBUG] Agent file contents: \n%s\n", agent.ScriptCode) } + agent.Hints = getTagsFromHints(agent) for key := range config.Routers { /* @@ -51,12 +55,27 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { wg.Add(1) go sendAgent(wg, config.UUID, connectString, agent.ScriptCode) - time.Sleep(10 * time.Millisecond) } } +/* + * Parse Agent file for GHINT data to populate the G'Agent hints + */ +func getTagsFromHints(agent gstructs.AgentDetails) []string { + var tags []string + re := regexp.MustCompile(`\s*set\s+GHINT\s*\[\s*split\s*"(?P.+)"\s*\,\s*\]`) + res := re.FindStringSubmatch(string(agent.ScriptCode)) + if len(res) < 1 { + log.Printf("[ERROR] Agent is missing GHINT tags") + os.Exit(4) + } + tags = strings.Split(res[1], ",") + log.Printf("[DEBUG] G'Agent hints: %v\n", tags) + + return tags +} + func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent []byte) { - log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) defer wg.Done() var mu sync.Mutex @@ -66,10 +85,23 @@ func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent []by defer sock.Close() sock.SetIdentity(uuid) - sock.Connect(connectString) + + log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) + err := sock.Connect(connectString) + if err != nil { + log.Printf("[ERROR] Failed to connect to %s\n", connectString) + os.Exit(10) + } log.Printf("[DEBUG] Start sending agent...\n") - sock.SendMessage(agent) - log.Printf("[DEBUG] End sending agent...\n") + status, err := sock.SendMessage(agent) + if err != nil { + log.Printf("[ERROR] Failed to send agent to router\n") + // os.Exit(11) + return + } + log.Printf("[DEBUG] Agent send status: %d\n", status) mu.Unlock() + time.Sleep(10 * time.Second) + } diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index a73bc63..a626c34 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -2,19 +2,20 @@ package gstructs // GagentConfig is the primary construct used by all modes type GagentConfig struct { - Name string `hcl:"name,optional"` - Mode string `hcl:"mode,attr"` - UUID string `hcl:"uuid,optional"` - ListenAddr string `hcl:"listenaddr,optional"` - ClientPort int64 `hcl:"clientport,optional"` - RouterPort int64 `hcl:"routerport,optional"` - WorkerPort int64 `hcl:"workerport,optional"` - Clients []*ClientDetails `hcl:"client,block"` - Routers []*RouterDetails `hcl:"router,block"` - Workers []*WorkerDetails `hcl:"worker,block"` - Version string - File string - CMode bool + Name string `hcl:"name,optional"` + Mode string `hcl:"mode,attr"` + UUID string `hcl:"uuid,optional"` + MonitorPort int `hcl:"monitorport,optional"` + ListenAddr string `hcl:"listenaddr,optional"` + ClientPort int64 `hcl:"clientport,optional"` + RouterPort int64 `hcl:"routerport,optional"` + WorkerPort int64 `hcl:"workerport,optional"` + Clients []*ClientDetails `hcl:"client,block"` + Routers []*RouterDetails `hcl:"router,block"` + Workers []*WorkerDetails `hcl:"worker,block"` + Version string + File string + CMode bool } /* @@ -127,5 +128,5 @@ type AgentDetails struct { Shasum string `hcl:"shasum"` Status string `hcl:"status"` ScriptCode []byte - Hints []*string + Hints []string } diff --git a/internal/setup/setup.go b/internal/setup/setup.go index 8c3357d..f4af155 100644 --- a/internal/setup/setup.go +++ b/internal/setup/setup.go @@ -12,7 +12,7 @@ import ( ) func Main(wg *sync.WaitGroup, config gs.GagentConfig) { - log.Printf("[INFO] setup mode\n") + log.Printf("[INFO] Starting setup\n") defer wg.Done() f := hclwrite.NewEmptyFile() From 27045c94d601479a06e83263d68fd4ab80fe6cb4 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 8 Nov 2021 18:06:41 -0800 Subject: [PATCH 20/80] Populating AgentDetails and sending it, instead of just the script. --- internal/client/client.go | 14 ++++++++------ internal/gstructs/gstructs.go | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/internal/client/client.go b/internal/client/client.go index d069837..e0b2d20 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -36,12 +36,14 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[ERROR] No such file or directory: %s", config.File) os.Exit(4) } - agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode)) - agent.Status = "loaded" - log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum) - log.Printf("[DEBUG] Agent file contents: \n%s\n", agent.ScriptCode) + log.Printf("[DEBUG] Agent file contents: \n----- -----\n%s\n----- -----\n", agent.ScriptCode) } + agent.Client = config.UUID + agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode)) + log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum) + agent.Status = "loaded" agent.Hints = getTagsFromHints(agent) + agent.Answer = nil for key := range config.Routers { /* @@ -54,7 +56,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport) wg.Add(1) - go sendAgent(wg, config.UUID, connectString, agent.ScriptCode) + go sendAgent(wg, config.UUID, connectString, agent) } } @@ -75,7 +77,7 @@ func getTagsFromHints(agent gstructs.AgentDetails) []string { return tags } -func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent []byte) { +func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent gstructs.AgentDetails) { defer wg.Done() var mu sync.Mutex diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index a626c34..1445bdb 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -129,4 +129,5 @@ type AgentDetails struct { Status string `hcl:"status"` ScriptCode []byte Hints []string + Answer []byte } From 749bd6557e0811b007ed38e9976ea291e469b852 Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 9 Nov 2021 17:06:16 -0800 Subject: [PATCH 21/80] Updated to clear errors captured by gosec. --- go.mod | 4 ++-- go.sum | 8 ++++---- internal/client/client.go | 4 ++-- internal/router/router.go | 39 +++++++++++++++++++++++++++++---------- internal/worker/worker.go | 2 +- pkg/picol/commands.go | 22 +++++++++++----------- 6 files changed, 49 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index 0deade1..9e9e0fb 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,6 @@ require ( github.com/pebbe/zmq4 v1.2.7 github.com/prometheus/client_golang v1.11.0 github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b - github.com/zclconf/go-cty v1.8.3 - golang.org/x/text v0.3.6 // indirect + github.com/zclconf/go-cty v1.9.1 + golang.org/x/text v0.3.7 // indirect ) diff --git a/go.sum b/go.sum index 77f0996..07481cc 100644 --- a/go.sum +++ b/go.sum @@ -132,8 +132,8 @@ github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+ github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.8.3 h1:48gwZXrdSADU2UW9eZKHprxAI7APZGW9XmExpJpSjT0= -github.com/zclconf/go-cty v1.8.3/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.9.1 h1:viqrgQwFl5UpSxc046qblj78wZXVDFnSOufaOTER+cc= +github.com/zclconf/go-cty v1.9.1/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -170,8 +170,8 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/client/client.go b/internal/client/client.go index e0b2d20..38e4345 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -86,10 +86,10 @@ func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent gstr sock, _ := zmq.NewSocket(zmq.REQ) defer sock.Close() - sock.SetIdentity(uuid) + err := sock.SetIdentity(uuid) log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) - err := sock.Connect(connectString) + err = sock.Connect(connectString) if err != nil { log.Printf("[ERROR] Failed to connect to %s\n", connectString) os.Exit(10) diff --git a/internal/router/router.go b/internal/router/router.go index bb337f3..3c92cda 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -39,7 +39,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { defer workerSock.Close() workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort) - workerSock.Bind(workerListener) + _ = workerSock.Bind(workerListener) workers := make([]string, 0) @@ -49,6 +49,9 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { poller2 := zmq.NewPoller() poller2.Add(workerSock, zmq.POLLIN) + wg.Add(1) + go createClientListener(wg, config) + LOOP: for { /* @@ -87,20 +90,36 @@ LOOP: workers = append(workers, identity) case clientSock: - /* - * Get client request, route to first available worker - */ - msg, err := s.RecvMessage(0) - log.Printf("[DEBUG] Client message received: %s", msg) - if err == nil { - workerSock.SendMessage(workers[0], "", msg) - workers = workers[1:] - } + wg.Add(1) + go createClientListener(wg, config) } } } } +/* + * Create listener for client requests + */ +func createClientListener(wg *sync.WaitGroup, config gstructs.GagentConfig) { + defer wg.Done() + + clientSock, _ := zmq.NewSocket(zmq.ROUTER) + defer clientSock.Close() + + clientListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.ClientPort) + log.Printf("[DEBUG] Binding to: %s", clientListener) + _ = clientSock.Bind(clientListener) + + for { + msg, err := clientSock.RecvMessage(0) + if err != nil { + break + } + log.Printf("[DEBUG] Client message received: %s", msg) + } + +} + func unwrap(msg []string) (head string, tail []string) { head = msg[0] if len(msg) > 1 && msg[1] == "" { diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 6f0d585..fbc4ddc 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -56,7 +56,7 @@ func getAgent(wg *sync.WaitGroup, uuid string, connectString string) { subscriber, _ := zmq.NewSocket(zmq.REP) defer subscriber.Close() - subscriber.Connect(connectString) + _ = subscriber.Connect(connectString) msg, err := subscriber.Recv(0) if err != nil { diff --git a/pkg/picol/commands.go b/pkg/picol/commands.go index 1d4d25b..b87b496 100644 --- a/pkg/picol/commands.go +++ b/pkg/picol/commands.go @@ -211,16 +211,16 @@ func CommandPuts(i *Interp, argv []string, pd interface{}) (string, error) { func (i *Interp) RegisterCoreCommands() { name := [...]string{"+", "-", "*", "/", ">", ">=", "<", "<=", "==", "!="} for _, n := range name { - i.RegisterCommand(n, CommandMath, nil) + _ = i.RegisterCommand(n, CommandMath, nil) } - i.RegisterCommand("set", CommandSet, nil) - i.RegisterCommand("unset", CommandUnset, nil) - i.RegisterCommand("if", CommandIf, nil) - i.RegisterCommand("while", CommandWhile, nil) - i.RegisterCommand("break", CommandRetCodes, nil) - i.RegisterCommand("continue", CommandRetCodes, nil) - i.RegisterCommand("proc", CommandProc, nil) - i.RegisterCommand("return", CommandReturn, nil) - i.RegisterCommand("error", CommandError, nil) - i.RegisterCommand("puts", CommandPuts, nil) + _ = i.RegisterCommand("set", CommandSet, nil) + _ = i.RegisterCommand("unset", CommandUnset, nil) + _ = i.RegisterCommand("if", CommandIf, nil) + _ = i.RegisterCommand("while", CommandWhile, nil) + _ = i.RegisterCommand("break", CommandRetCodes, nil) + _ = i.RegisterCommand("continue", CommandRetCodes, nil) + _ = i.RegisterCommand("proc", CommandProc, nil) + _ = i.RegisterCommand("return", CommandReturn, nil) + _ = i.RegisterCommand("error", CommandError, nil) + _ = i.RegisterCommand("puts", CommandPuts, nil) } From 458214aaa95794c69c1983513fd0841799624368 Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 2 Dec 2021 05:44:53 -0800 Subject: [PATCH 22/80] Started moving to a chainDB for tracking history. --- cmd/gagent/main.go | 2 +- docs/VULNERABILITIES.md | 24 ++++++++++++++---------- internal/client/client.go | 6 +++--- internal/gstructs/gstructs.go | 5 +---- internal/router/router.go | 5 +++++ internal/setup/setup.go | 7 +++++++ 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 3736ac9..cc9fb17 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -30,7 +30,7 @@ import ( ) var ( - semVER = "0.0.3" + semVER = "0.0.4" ) var ( diff --git a/docs/VULNERABILITIES.md b/docs/VULNERABILITIES.md index 5cc6f61..38860e5 100644 --- a/docs/VULNERABILITIES.md +++ b/docs/VULNERABILITIES.md @@ -2,26 +2,30 @@ IGNORED: We are not using the SSH features of golang.org/x/crypto ``` -2021-08-30T07:10:13.085-0700 INFO Detected OS: unknown -2021-08-30T07:10:13.085-0700 INFO Number of PL dependency files: 1 -2021-08-30T07:10:13.085-0700 INFO Detecting gomod vulnerabilities... +2021-11-13T10:25:13.188-0800 INFO Need to update DB +2021-11-13T10:25:13.188-0800 INFO Downloading DB... +24.70 MiB / 24.70 MiB [----------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00% 6.04 MiB p/s 4s +2021-11-13T10:25:18.570-0800 INFO Detected OS: unknown +2021-11-13T10:25:18.570-0800 INFO Number of PL dependency files: 2 +2021-11-13T10:25:18.570-0800 INFO Detecting gobinary vulnerabilities... +2021-11-13T10:25:18.571-0800 INFO Detecting gomod vulnerabilities... + +bin/gagent +========== +Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0) + go.sum ====== -Total: 2 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 2, CRITICAL: 0) +Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0) +---------------------+------------------+----------+-----------------------------------+------------------------------------+---------------------------------------+ | LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE | +---------------------+------------------+----------+-----------------------------------+------------------------------------+---------------------------------------+ -| golang.org/x/crypto | CVE-2020-29652 | HIGH | 0.0.0-20190426145343-a29dc8fdc734 | v0.0.0-20201216223049-8b5274cf687f | golang: crypto/ssh: crafted | +| golang.org/x/crypto | CVE-2020-29652 | HIGH | 0.0.0-20200622213623-75b288015ac9 | v0.0.0-20201216223049-8b5274cf687f | golang: crypto/ssh: crafted | | | | | | | authentication request can | | | | | | | lead to nil pointer dereference | | | | | | | -->avd.aquasec.com/nvd/cve-2020-29652 | -+ +------------------+ + +------------------------------------+---------------------------------------+ -| | CVE-2020-9283 | | | v0.0.0-20200220183623-bac4c82f6975 | golang.org/x/crypto: Processing | -| | | | | | of crafted ssh-ed25519 | -| | | | | | public keys allows for panic | -| | | | | | -->avd.aquasec.com/nvd/cve-2020-9283 | +---------------------+------------------+----------+-----------------------------------+------------------------------------+---------------------------------------+ ``` --- diff --git a/internal/client/client.go b/internal/client/client.go index 38e4345..e31e2b4 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -39,7 +39,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[DEBUG] Agent file contents: \n----- -----\n%s\n----- -----\n", agent.ScriptCode) } agent.Client = config.UUID - agent.Shasum = fmt.Sprintf("%x", sha.Sum256(agent.ScriptCode)) + agent.Shasum = fmt.Sprintf("%s", sha.Sum256(agent.ScriptCode)) log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum) agent.Status = "loaded" agent.Hints = getTagsFromHints(agent) @@ -86,10 +86,10 @@ func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent gstr sock, _ := zmq.NewSocket(zmq.REQ) defer sock.Close() - err := sock.SetIdentity(uuid) + _ = sock.SetIdentity(uuid) log.Printf("[DEBUG] Attempting to connect to %s\n", connectString) - err = sock.Connect(connectString) + err := sock.Connect(connectString) if err != nil { log.Printf("[ERROR] Failed to connect to %s\n", connectString) os.Exit(10) diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 1445bdb..8a13593 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -10,6 +10,7 @@ type GagentConfig struct { ClientPort int64 `hcl:"clientport,optional"` RouterPort int64 `hcl:"routerport,optional"` WorkerPort int64 `hcl:"workerport,optional"` + ChainDBPath string `hcl:"chaindbpath,optional"` Clients []*ClientDetails `hcl:"client,block"` Routers []*RouterDetails `hcl:"router,block"` Workers []*WorkerDetails `hcl:"worker,block"` @@ -119,10 +120,6 @@ type WorkerDetails struct { WorkerTags []string `hcl:"tags,optional"` } -type BlockChainDB struct { - DBName string `hcl:"chainid,optional"` - Agents []*AgentDetails `hcl:"agent,block"` -} type AgentDetails struct { Client string `hcl:"client"` Shasum string `hcl:"shasum"` diff --git a/internal/router/router.go b/internal/router/router.go index 3c92cda..a74eeda 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -6,6 +6,7 @@ import ( http "net/http" sync "sync" + gcdb "git.dragonheim.net/dragonheim/gagent/internal/chaindb" gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" prometheus "github.com/prometheus/client_golang/prometheus" @@ -18,6 +19,8 @@ var ( opsProcessed = promauto.NewCounter(prometheus.CounterOpts{ Name: "client_requests_recieved", }) + + db gcdb.GagentDb ) /* @@ -38,6 +41,8 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { workerSock, _ := zmq.NewSocket(zmq.DEALER) defer workerSock.Close() + db.Init() + workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort) _ = workerSock.Bind(workerListener) diff --git a/internal/setup/setup.go b/internal/setup/setup.go index f4af155..2c90261 100644 --- a/internal/setup/setup.go +++ b/internal/setup/setup.go @@ -28,6 +28,13 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { clientBlock1 := rootBody.AppendNewBlock("client", []string{config.Name}) clientBody1 := clientBlock1.Body() + // clientBody1.AppendUnstructuredTokens( + // hclwrite.TokensForTraversal(hcl.Traversal{ + // hcl.TraverseRoot{ + // Name: hcl.CommentGenerator("comment"), + // }, + // }, + // )) clientBody1.SetAttributeValue("clientid", cty.StringVal(config.UUID)) rootBody.AppendNewline() From 66970dcd254f3d7dc3ef5f6d6df422cbfda8c4e8 Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 2 Dec 2021 05:45:33 -0800 Subject: [PATCH 23/80] Forgot to add the chaindb directory --- internal/chaindb/chaindb.go | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 internal/chaindb/chaindb.go diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go new file mode 100644 index 0000000..84da93d --- /dev/null +++ b/internal/chaindb/chaindb.go @@ -0,0 +1,67 @@ +package chaindb + +import ( + sha "crypto/sha256" + fmt "fmt" + log "log" + time "time" + + gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + + hclsimple "github.com/hashicorp/hcl/v2/hclsimple" + // hclwrite "github.com/hashicorp/hcl/v2/hclwrite" +) + +type GagentDb struct { + chainRow []*gagentDbRow `hcl:"timestamp,block"` +} + +type gagentDbRow struct { + timestamp time.Time `hcl:"timestamp"` + DBName string `hcl:"chainid,optional"` + Agent gstructs.AgentDetails `hcl:"agent,block"` + dbCurrHash [32]byte `hcl:"currhash"` + dbPrevHash [32]byte `hcl:"prevhash"` +} + +/* + * Initialize the database + */ +func (db *GagentDb) Init() { + db.chainRow = make([]*gagentDbRow, 0) +} + +/* + * Load the database from disk + */ +func (db *GagentDb) Load() error { + err := hclsimple.DecodeFile("chaindb.hcl", nil, &db) + log.Printf("[DEBUG] DB values: %v\n", db) + return err +} + +/* + * Add a new row to the chaindb + */ +func (db *GagentDb) AddRow(row *gagentDbRow) error { + row.timestamp = time.Now() + db.chainRow = append(db.chainRow, row) + + return nil +} + +/* + * Set current hash of the database + */ +func (db *GagentDb) SetCurrHash() { + db.chainRow[len(db.chainRow)-1].dbCurrHash = [32]byte{} + foo := sha.Sum256([]byte(fmt.Sprintf("%v", db))) + db.chainRow[len(db.chainRow)-1].dbCurrHash = foo +} + +/* + * Set previous hash of the database + */ +func (db *GagentDb) SetPrevHash() { + db.chainRow[len(db.chainRow)-1].dbPrevHash = db.chainRow[len(db.chainRow)-1].dbCurrHash +} From 1a0455152af2cbcf85b2dd12716d94d37ee8cfa6 Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 23 Dec 2021 13:35:36 -0800 Subject: [PATCH 24/80] A few minor updates and attempts to clear up some lint / gosec warnings. --- docs/LICENSE.md => LICENSE.md | 0 assets/docker/Dockerfile | 4 +- assets/tfenv/terraform.tf | 4 +- go.mod | 26 ++- go.sum | 345 ++++++++++++++++++++++++++++++++-- internal/client/client.go | 1 + internal/router/router.go | 3 +- internal/setup/setup.go | 3 + internal/worker/worker.go | 1 + pkg/picol/commands.go | 54 +++++- 10 files changed, 407 insertions(+), 34 deletions(-) rename docs/LICENSE.md => LICENSE.md (100%) diff --git a/docs/LICENSE.md b/LICENSE.md similarity index 100% rename from docs/LICENSE.md rename to LICENSE.md diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index 9639856..cb8b245 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17-alpine3.14 as builder +FROM dragonheim/golang:1.17 as builder ARG SEMVER WORKDIR /gagent @@ -12,7 +12,7 @@ RUN apk add --no-cache zeromq-dev build-base git RUN go build -o /gagent/bin/gagent -ldflags "-X main.semVER=${SEMVER}" cmd/gagent/main.go RUN strip /gagent/bin/gagent -FROM alpine:3.14 +FROM alpine:3.15 ARG SEMVER LABEL Name="G'Agent" LABEL Maintainer="jwells@dragonheim.net" diff --git a/assets/tfenv/terraform.tf b/assets/tfenv/terraform.tf index fb2b736..2fafd04 100644 --- a/assets/tfenv/terraform.tf +++ b/assets/tfenv/terraform.tf @@ -1,9 +1,9 @@ terraform { - required_version = ">= 1.0.9" + required_version = ">= 1.0.11" required_providers { aws = { source = "hashicorp/aws" - version = "~> 3.62.0" + version = "~> 3.70.0" } } } diff --git a/go.mod b/go.mod index 9e9e0fb..0eeb032 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,32 @@ module git.dragonheim.net/dragonheim/gagent -go 1.16 +go 1.17 require ( github.com/Showmax/go-fqdn v1.0.0 - github.com/agext/levenshtein v1.2.3 // indirect github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a - github.com/hashicorp/hcl/v2 v2.10.1 + github.com/hashicorp/hcl/v2 v2.11.1 github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 - github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pebbe/zmq4 v1.2.7 github.com/prometheus/client_golang v1.11.0 github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b - github.com/zclconf/go-cty v1.9.1 - golang.org/x/text v0.3.7 // indirect + github.com/zclconf/go-cty v1.10.0 +) + +require ( + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.6 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/procfs v0.7.3 // indirect + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/protobuf v1.27.1 // indirect ) diff --git a/go.sum b/go.sum index 07481cc..329dfd6 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,38 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Showmax/go-fqdn v1.0.0 h1:0rG5IbmVliNT5O19Mfuvna9LL7zlHyRfsSvBPZmF9tM= github.com/Showmax/go-fqdn v1.0.0/go.mod h1:SfrFBzmDCtCGrnHhoDjuvFnKsWjEQX/Q9ARZvOrJAko= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= @@ -20,11 +54,25 @@ 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/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +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= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -35,38 +83,79 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/hashicorp/hcl/v2 v2.10.1 h1:h4Xx4fsrRE26ohAk/1iGF/JBqRQbyUqu5Lvj60U54ys= -github.com/hashicorp/hcl/v2 v2.10.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc= +github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -102,17 +191,21 @@ github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -130,69 +223,295 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.9.1 h1:viqrgQwFl5UpSxc046qblj78wZXVDFnSOufaOTER+cc= -github.com/zclconf/go-cty v1.9.1/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= +github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211205182925-97ca703d548d h1:FjkYO/PPp4Wi0EAUOVLxePm7qVW4r4ctbWpURyuOD0E= +golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1 h1:7QnIQpGRHE5RnLKnESfDoxm2dTapTZua5a0kS0A+VXQ= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/internal/client/client.go b/internal/client/client.go index e31e2b4..e869453 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -22,6 +22,7 @@ import ( requests to a router. If started without arguments, the client will contact the router and attempt to retrieve the results of it's most recent request. + Main is the entrypoint for the client process */ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting client\n") diff --git a/internal/router/router.go b/internal/router/router.go index a74eeda..c8621f7 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -17,7 +17,7 @@ import ( var ( opsProcessed = promauto.NewCounter(prometheus.CounterOpts{ - Name: "client_requests_recieved", + Name: "client_requests_received", }) db gcdb.GagentDb @@ -29,6 +29,7 @@ var ( list of tags and passing the agent and it's storage to either a member or client node. Tags are used by the agent to give hints as to where it should be routed. + Main is the entrypoint for the router */ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting router\n") diff --git a/internal/setup/setup.go b/internal/setup/setup.go index 2c90261..767f8f1 100644 --- a/internal/setup/setup.go +++ b/internal/setup/setup.go @@ -11,6 +11,9 @@ import ( hclwrite "github.com/hashicorp/hcl/v2/hclwrite" ) +/* + Main is the entrypoint for the setup process +*/ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { log.Printf("[INFO] Starting setup\n") defer wg.Done() diff --git a/internal/worker/worker.go b/internal/worker/worker.go index fbc4ddc..8cebdb8 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -26,6 +26,7 @@ var ( anything about the network structure. Instead they know only to which router(s) they are connected. The worker will execute the agent code and pass the agent and it's results to a router. + Main is the entrypoint for the worker process */ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting worker\n") diff --git a/pkg/picol/commands.go b/pkg/picol/commands.go index b87b496..991e710 100644 --- a/pkg/picol/commands.go +++ b/pkg/picol/commands.go @@ -4,16 +4,50 @@ import ( "fmt" "strconv" "strings" + "testing" ) -func ArityErr(i *Interp, name string, argv []string) error { +func arityErr(i *Interp, name string, argv []string) error { return fmt.Errorf("wrong number of args for %s %s", name, argv) } +/* + needleInHaystack returns true if the string is in a slice +*/ +func needleInHaystack(needle string, haystack []string) bool { + for _, haystackMember := range haystack { + if haystackMember == needle { + return true + } + } + return false +} + +/* + TestneedleInHaystack tests the return value of needleInHaystack +*/ +func TestneedleInHaystack(t *testing.T) { + var haystack = []string{"a", "b", "c"} + var needle = "a" + if !needleInHaystack(needle, haystack) { + t.Errorf("%s not in %s", needle, haystack) + } + + needle = "j" + if needleInHaystack(needle, haystack) { + t.Errorf("%s in %s", needle, haystack) + } + + needle = "ab" + if needleInHaystack(needle, haystack) { + t.Errorf("%s in %s", needle, haystack) + } +} + // CommandMath is the math command for TCL func CommandMath(i *Interp, argv []string, pd interface{}) (string, error) { if len(argv) != 3 { - return "", ArityErr(i, argv[0], argv) + return "", arityErr(i, argv[0], argv) } a, _ := strconv.Atoi(argv[1]) b, _ := strconv.Atoi(argv[2]) @@ -60,7 +94,7 @@ func CommandMath(i *Interp, argv []string, pd interface{}) (string, error) { // CommandSet is the set command for TCL func CommandSet(i *Interp, argv []string, pd interface{}) (string, error) { if len(argv) != 3 { - return "", ArityErr(i, argv[0], argv) + return "", arityErr(i, argv[0], argv) } i.SetVar(argv[1], argv[2]) return argv[2], nil @@ -69,7 +103,7 @@ func CommandSet(i *Interp, argv []string, pd interface{}) (string, error) { // CommandUnset is the unset command for TCL func CommandUnset(i *Interp, argv []string, pd interface{}) (string, error) { if len(argv) != 2 { - return "", ArityErr(i, argv[0], argv) + return "", arityErr(i, argv[0], argv) } i.UnsetVar(argv[1]) return "", nil @@ -78,7 +112,7 @@ func CommandUnset(i *Interp, argv []string, pd interface{}) (string, error) { // CommandIf is the if command for TCL func CommandIf(i *Interp, argv []string, pd interface{}) (string, error) { if len(argv) != 3 && len(argv) != 5 { - return "", ArityErr(i, argv[0], argv) + return "", arityErr(i, argv[0], argv) } result, err := i.Eval(argv[1]) @@ -98,7 +132,7 @@ func CommandIf(i *Interp, argv []string, pd interface{}) (string, error) { // CommandWhile is the while command for TCL func CommandWhile(i *Interp, argv []string, pd interface{}) (string, error) { if len(argv) != 3 { - return "", ArityErr(i, argv[0], argv) + return "", arityErr(i, argv[0], argv) } for { @@ -125,7 +159,7 @@ func CommandWhile(i *Interp, argv []string, pd interface{}) (string, error) { // CommandRetCodes is a function to get the return codes for TCL func CommandRetCodes(i *Interp, argv []string, pd interface{}) (string, error) { if len(argv) != 1 { - return "", ArityErr(i, argv[0], argv) + return "", arityErr(i, argv[0], argv) } switch argv[0] { case "break": @@ -173,7 +207,7 @@ func CommandCallProc(i *Interp, argv []string, pd interface{}) (string, error) { // CommandProc is a function to register proc commands for TCL func CommandProc(i *Interp, argv []string, pd interface{}) (string, error) { if len(argv) != 4 { - return "", ArityErr(i, argv[0], argv) + return "", arityErr(i, argv[0], argv) } return "", i.RegisterCommand(argv[1], CommandCallProc, []string{argv[2], argv[3]}) } @@ -181,7 +215,7 @@ func CommandProc(i *Interp, argv []string, pd interface{}) (string, error) { // CommandReturn is a function to register return codes for commands for TCL func CommandReturn(i *Interp, argv []string, pd interface{}) (string, error) { if len(argv) != 1 && len(argv) != 2 { - return "", ArityErr(i, argv[0], argv) + return "", arityErr(i, argv[0], argv) } var r string if len(argv) == 2 { @@ -193,7 +227,7 @@ func CommandReturn(i *Interp, argv []string, pd interface{}) (string, error) { // CommandError is a function to return error codes for commands for TCL func CommandError(i *Interp, argv []string, pd interface{}) (string, error) { if len(argv) != 1 && len(argv) != 2 { - return "", ArityErr(i, argv[0], argv) + return "", arityErr(i, argv[0], argv) } return "", fmt.Errorf(argv[1]) } From af5407f2e65cde66b67e6501c0287c9eb02eb29d Mon Sep 17 00:00:00 2001 From: James Wells Date: Wed, 16 Mar 2022 16:11:38 -0700 Subject: [PATCH 25/80] Updating for new Terraform, AWS, and Go versions. --- assets/tfenv/terraform.tf | 4 ++-- go.mod | 10 +++++----- go.sum | 21 +++++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/assets/tfenv/terraform.tf b/assets/tfenv/terraform.tf index 2fafd04..bb7904b 100644 --- a/assets/tfenv/terraform.tf +++ b/assets/tfenv/terraform.tf @@ -1,9 +1,9 @@ terraform { - required_version = ">= 1.0.11" + required_version = ">= 1.1.7" required_providers { aws = { source = "hashicorp/aws" - version = "~> 3.70.0" + version = "~> 4.5.0" } } } diff --git a/go.mod b/go.mod index 0eeb032..ee34893 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module git.dragonheim.net/dragonheim/gagent -go 1.17 +go 1.18 require ( github.com/Showmax/go-fqdn v1.0.0 @@ -8,8 +8,8 @@ require ( github.com/hashicorp/hcl/v2 v2.11.1 github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 - github.com/pebbe/zmq4 v1.2.7 - github.com/prometheus/client_golang v1.11.0 + github.com/pebbe/zmq4 v1.2.8 + github.com/prometheus/client_golang v1.12.1 github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b github.com/zclconf/go-cty v1.10.0 ) @@ -20,13 +20,13 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.6 // indirect + github.com/google/go-cmp v0.5.7 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86 // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/protobuf v1.27.1 // indirect ) diff --git a/go.sum b/go.sum index 329dfd6..2da003f 100644 --- a/go.sum +++ b/go.sum @@ -44,7 +44,6 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= -github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= @@ -123,8 +122,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -151,6 +150,7 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= @@ -175,10 +175,11 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/pebbe/zmq4 v1.2.7 h1:6EaX83hdFSRUEhgzSW1E/SPoTS3JeYZgYkBvwdcrA9A= -github.com/pebbe/zmq4 v1.2.7/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= +github.com/pebbe/zmq4 v1.2.8 h1:sBO89w+czJZfpZaVu2suYdh2IBXCxPKiL/pX7r6gZog= +github.com/pebbe/zmq4 v1.2.8/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -187,8 +188,9 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -354,10 +356,9 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211205182925-97ca703d548d h1:FjkYO/PPp4Wi0EAUOVLxePm7qVW4r4ctbWpURyuOD0E= -golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86 h1:A9i04dxx7Cribqbs8jf3FQLogkL/CV2YN7hj9KWJCkc= +golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 06147db215e2f4698e10e609a3b268a2d02d5726 Mon Sep 17 00:00:00 2001 From: James Wells Date: Wed, 16 Mar 2022 16:33:56 -0700 Subject: [PATCH 26/80] Updating security scan with new Golang and updated modules. --- .trivyignore | 2 +- docs/VULNERABILITIES.md | 39 ++++++++++++++++----------------------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/.trivyignore b/.trivyignore index 85eed00..7622450 100644 --- a/.trivyignore +++ b/.trivyignore @@ -1,2 +1,2 @@ # No impact in our project -CVE-2020-29652 +CVE-2021-3121 \ No newline at end of file diff --git a/docs/VULNERABILITIES.md b/docs/VULNERABILITIES.md index 38860e5..75540ae 100644 --- a/docs/VULNERABILITIES.md +++ b/docs/VULNERABILITIES.md @@ -1,32 +1,25 @@ ### [Source Code Scan](#source) -IGNORED: We are not using the SSH features of golang.org/x/crypto +IGNORED: We are not using the protocol buffers provided by gogo/protobuf ``` -2021-11-13T10:25:13.188-0800 INFO Need to update DB -2021-11-13T10:25:13.188-0800 INFO Downloading DB... -24.70 MiB / 24.70 MiB [----------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00% 6.04 MiB p/s 4s -2021-11-13T10:25:18.570-0800 INFO Detected OS: unknown -2021-11-13T10:25:18.570-0800 INFO Number of PL dependency files: 2 -2021-11-13T10:25:18.570-0800 INFO Detecting gobinary vulnerabilities... -2021-11-13T10:25:18.571-0800 INFO Detecting gomod vulnerabilities... +2022-03-16T16:27:43.221-0700 INFO Need to update DB +2022-03-16T16:27:43.221-0700 INFO Downloading DB... +26.43 MiB / 26.43 MiB [---------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00% 5.71 MiB p/s 5s +2022-03-16T16:27:49.073-0700 INFO Number of language-specific files: 1 +2022-03-16T16:27:49.073-0700 INFO Detecting gomod vulnerabilities... -bin/gagent -========== -Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0) - - -go.sum -====== +go.sum (gomod) +============== Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0) -+---------------------+------------------+----------+-----------------------------------+------------------------------------+---------------------------------------+ -| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE | -+---------------------+------------------+----------+-----------------------------------+------------------------------------+---------------------------------------+ -| golang.org/x/crypto | CVE-2020-29652 | HIGH | 0.0.0-20200622213623-75b288015ac9 | v0.0.0-20201216223049-8b5274cf687f | golang: crypto/ssh: crafted | -| | | | | | authentication request can | -| | | | | | lead to nil pointer dereference | -| | | | | | -->avd.aquasec.com/nvd/cve-2020-29652 | -+---------------------+------------------+----------+-----------------------------------+------------------------------------+---------------------------------------+ ++--------------------------+------------------+----------+-------------------+---------------+--------------------------------------+ +| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE | ++--------------------------+------------------+----------+-------------------+---------------+--------------------------------------+ +| github.com/gogo/protobuf | CVE-2021-3121 | HIGH | 1.1.1 | 1.3.2 | gogo/protobuf: | +| | | | | | plugin/unmarshal/unmarshal.go | +| | | | | | lacks certain index validation | +| | | | | | -->avd.aquasec.com/nvd/cve-2021-3121 | ++--------------------------+------------------+----------+-------------------+---------------+--------------------------------------+ ``` --- ### [Image Scan](#image) From 31c6551cce908103eea73e0d784f7f8e1db990bf Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 24 Mar 2022 11:31:52 -0700 Subject: [PATCH 27/80] Updated devcontainer. --- .devcontainer/devcontainer.json | 69 +++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9ab51d0..7895f39 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,18 +1,55 @@ +// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/go { - "name": "GitHub Codespaces (Default)", - "extensions": [ - "GitHub.vscode-pull-request-github", - "golang.go", - "hashicorp.terraform", - "wholroyd.hcl", - "github.copilot", - "golang.Go" - ], - "build": { - "dockerfile": "Dockerfile", - "args": { - "VARIANT": "1.17", - "NODE_VERSION": "none" - } - }, + "name": "Go", + "build": { + "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.18-bullseye", + // Options + "NODE_VERSION": "none" + } + }, + "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], + + // Set *default* container specific settings.json values on container create. + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go", + "go.goroot": "/usr/local/go" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "golang.Go", + "GitHub.copilot", + "GitHub.vscode-pull-request-github", + "wholroyd.hcl", + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [9000], + + // Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference. + "portsAttributes": { + "9000": { + "label": "Hello Remote World", + "onAutoForward": "notify" + } + }, + + // Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'. + // "otherPortsAttributes": { + // "onAutoForward": "silent" + // }, + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "go version", + + // Uncomment to connect as a non-root user. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" } From 8fea3b252707d989c902e44b8ff79a80611805df Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 14 Apr 2022 18:01:20 +0000 Subject: [PATCH 28/80] Updated example for Prometheus, updated Go modules, and tweaked the devcontainer. --- .devcontainer/Dockerfile | 7 +++---- .devcontainer/devcontainer.json | 17 +++++++++++++---- assets/examples/gagent.hcl | 17 +++++++++++++---- cmd/gagent/main.go | 18 +++++++++++------- go.mod | 6 +++--- go.sum | 19 ++++++++++++++----- 6 files changed, 57 insertions(+), 27 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index cd8e346..191b2a9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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.17" +ARG VARIANT="1.18" FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 @@ -9,9 +9,8 @@ ARG NODE_VERSION="none" RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi # [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends -RUN apt-get update && apt-get install -y --no-install-recommends libzmq3-dev libzmq5 +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends libzmq3-dev libzmq5 # [Optional] Uncomment the next line to use go get to install anything else you need # RUN go get -x diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7895f39..b687359 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -33,13 +33,22 @@ // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [9000], + "forwardPorts": [9101, 35570, 35571, 35572], // Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference. "portsAttributes": { - "9000": { - "label": "Hello Remote World", - "onAutoForward": "notify" - } + "9101": { + "label": "Prometheus", + }, + "35570": { + "label": "Router To Router", + }, + "35571": { + "label": "Worker To Router", + }, + "35572": { + "label": "Client To Router", + }, }, // Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'. diff --git a/assets/examples/gagent.hcl b/assets/examples/gagent.hcl index baff785..bf201e4 100644 --- a/assets/examples/gagent.hcl +++ b/assets/examples/gagent.hcl @@ -48,12 +48,21 @@ mode = "router" // listenaddr = 0.0.0.0 /* - * This is the port to the router will listen for on - * for clients. It defaults to 35570. + * This is the port to G'Agent will listen for on + * for Prometheus queries. It defaults to 9101. + * Monitoring will be disabled if this is set to 0. * * Optional. */ -// clientport = 35571 +// monitorport = 9101 + +/* + * This is the port to the router will listen for on + * for clients. It defaults to 35572. + * + * Optional. + */ +// clientport = 35572 /* * This is the port to the router will listen for on @@ -69,7 +78,7 @@ mode = "router" * * Optional. */ -// workerport = 35572 +// workerport = 35571 /* * @TODO diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index cc9fb17..f36d3f3 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -151,25 +151,25 @@ func init() { config.MonitorPort = 9101 /* - * By default, G'Agent client will use port 35571 to communicate with the + * By default, G'Agent client will use port 35572 to communicate with the * routers, but you can override it by setting the clientport in the * configuration file */ - config.ClientPort = 35571 + config.ClientPort = 35572 /* - * By default, G'Agent router will use port 35572 to communicate with + * By default, G'Agent router will use port 35570 to communicate with * other routers, but you can override it by setting the routerport in * the configuration file */ config.RouterPort = 35570 /* - * By default, G'Agent worker will use port 35570 to communicate with the + * By default, G'Agent worker will use port 35571 to communicate with the * routers, but you can override it by setting the workerport in the * configuration file */ - config.WorkerPort = 35572 + config.WorkerPort = 35571 config.Clients = make([]*gstructs.ClientDetails, 0) config.Routers = make([]*gstructs.RouterDetails, 0) @@ -265,6 +265,10 @@ func init() { /* * Start Prometheus metrics exporter */ - go http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.MonitorPort), nil) - + if config.MonitorPort != 0 { + go func() { + log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) + log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.MonitorPort), nil)) + }() + } } diff --git a/go.mod b/go.mod index ee34893..def8e70 100644 --- a/go.mod +++ b/go.mod @@ -24,9 +24,9 @@ require ( github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/common v0.33.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect - golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86 // indirect + golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect golang.org/x/text v0.3.7 // indirect - google.golang.org/protobuf v1.27.1 // indirect + google.golang.org/protobuf v1.28.0 // indirect ) diff --git a/go.sum b/go.sum index 2da003f..7ca9a39 100644 --- a/go.sum +++ b/go.sum @@ -75,9 +75,11 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= @@ -199,8 +201,9 @@ github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6T github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.33.0 h1:rHgav/0a6+uYgGdNt3jwz8FNSesO/Hsang3O0T9A5SE= +github.com/prometheus/common v0.33.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= @@ -305,12 +308,15 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -356,10 +362,13 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86 h1:A9i04dxx7Cribqbs8jf3FQLogkL/CV2YN7hj9KWJCkc= -golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -492,8 +501,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From d5ac24bb263729898769415dd1183f42777f9ea6 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 15 Apr 2022 15:43:33 +0000 Subject: [PATCH 29/80] Updating the source host for maintenance and added Trivy to the development container. --- .devcontainer/Dockerfile | 2 ++ README.md | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 191b2a9..f2ad597 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,6 +4,8 @@ ARG VARIANT="1.18" FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} +COPY --from=aquasec/trivy:0.25.4 /usr/local/bin/trivy /usr/bin/trivy + # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 ARG NODE_VERSION="none" RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi diff --git a/README.md b/README.md index f97ed54..ce86be2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # G'Agent -[![Maintained Status](https://img.shields.io/maintenance/yes/2021?style=plastic)](https://git.dragonheim.net/dragonheim/gagent) -[![License](https://img.shields.io/badge/License-MIT-limegreen.svg)](https://git.dragonheim.net/dragonheim/gagent/src/branch/main/LICENSE) +[![Maintained Status](https://img.shields.io/maintenance/yes/2021?style=plastic)](https://github.com/dragonheim/gagent) +[![License](https://img.shields.io/badge/License-MIT-limegreen.svg)](https://github.com/dragonheim/gagent/src/branch/main/LICENSE) [![Build Status](https://drone.dragonheim.net/api/badges/dragonheim/gagent/status.svg)](https://drone.dragonheim.net/dragonheim/gagent) [![Go Report Card](https://goreportcard.com/badge/git.dragonheim.net/dragonheim/gagent)](https://goreportcard.com/report/git.dragonheim.net/dragonheim/gagent) From 42623f63c61d7e7e68f062af8f37d5f71792177e Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 9 Jun 2022 12:57:12 -0700 Subject: [PATCH 30/80] Upgraded Go and some of the vendor modules. --- .devcontainer/devcontainer.json | 12 ++-- cmd/gagent/main.go | 10 ++- go.mod | 13 ++++ go.sum | 92 ++++++++++++++++++++++++- internal/consulservice/consulservice.go | 60 ++++++++++++++++ 5 files changed, 178 insertions(+), 9 deletions(-) create mode 100644 internal/consulservice/consulservice.go diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b687359..90d13ec 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,6 +29,8 @@ "GitHub.copilot", "GitHub.vscode-pull-request-github", "wholroyd.hcl", + "GitHub.vscode-pull-request-github", + "hashicorp.terraform" ], // Use 'forwardPorts' to make a list of ports inside the container available locally. @@ -38,17 +40,17 @@ // Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference. "portsAttributes": { "9101": { - "label": "Prometheus", + "label": "Prometheus" }, "35570": { - "label": "Router To Router", + "label": "Router To Router" }, "35571": { - "label": "Worker To Router", + "label": "Worker To Router" }, "35572": { - "label": "Client To Router", - }, + "label": "Client To Router" + } }, // Use 'otherPortsAttributes' to configure any ports that aren't configured using 'portsAttributes'. diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index f36d3f3..3274233 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -7,10 +7,10 @@ import ( os "os" sync "sync" - fqdn "github.com/Showmax/go-fqdn" - autorestart "github.com/slayer/autorestart" + fqdn "github.com/Showmax/go-fqdn" + gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" gc "git.dragonheim.net/dragonheim/gagent/internal/client" @@ -30,7 +30,7 @@ import ( ) var ( - semVER = "0.0.4" + semVER = "0.0.5" ) var ( @@ -77,6 +77,8 @@ func main() { os.Exit(7) } + // cs.Client.ConsulRegister("gagent-router", config.RouterPort) + wg.Add(1) go gr.Main(&wg, config) @@ -88,6 +90,8 @@ func main() { os.Exit(6) } + // cs.Client.ConsulRegister("gagent-worker", config.WorkerPort) + wg.Add(1) go gw.Main(&wg, config) diff --git a/go.mod b/go.mod index def8e70..18e9d5e 100644 --- a/go.mod +++ b/go.mod @@ -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/hashicorp/consul/api v1.12.0 github.com/hashicorp/hcl/v2 v2.11.1 github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 @@ -17,12 +18,24 @@ require ( require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/fatih/color v1.9.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.7 // indirect + github.com/hashicorp/go-cleanhttp v0.5.1 // indirect + github.com/hashicorp/go-hclog v0.12.0 // indirect + github.com/hashicorp/go-immutable-radix v1.0.0 // indirect + github.com/hashicorp/go-rootcerts v1.0.2 // indirect + github.com/hashicorp/golang-lru v0.5.1 // indirect + github.com/hashicorp/serf v0.9.6 // indirect + github.com/mattn/go-colorable v0.1.6 // indirect + github.com/mattn/go-isatty v0.0.12 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.33.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect diff --git a/go.sum b/go.sum index 7ca9a39..e29827e 100644 --- a/go.sum +++ b/go.sum @@ -47,12 +47,18 @@ github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:o github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a h1:YJuVATwP+Gzk7nys0U/DKjKkoYp1n/sYm0yi5vX8W8M= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a/go.mod h1:pBRbUcGboHT5qBceq2Cg/WIcDbO78a8wPxTg8zmS3Hs= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 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/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= 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= @@ -69,6 +75,9 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= +github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -114,6 +123,7 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -139,12 +149,43 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/hashicorp/consul/api v1.12.0 h1:k3y1FYv6nuKyNTqj6w9gXOx5r5CfLj/k/euUeBXj1OY= +github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= +github.com/hashicorp/consul/sdk v0.8.0 h1:OJtKBtEjboEZvG6AOUdh4Z1Zbyu0WcxQ0qatRrZHTVU= +github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-hclog v0.12.0 h1:d4QkX8FRTYaKaCZBoXYY8zJX2BXjWxurN/GA2tkrmZM= +github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= +github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= +github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc= github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= +github.com/hashicorp/memberlist v0.3.0 h1:8+567mCcFDnS5ADl7lrpxPMWiFCElyUEeW0gtj34fMA= +github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= +github.com/hashicorp/serf v0.9.6 h1:uuEX1kLR6aoda1TBttmJQKDLZE1Ob7KN0NPdE7EtCDc= +github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= @@ -161,18 +202,40 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -180,13 +243,18 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pebbe/zmq4 v1.2.8 h1:sBO89w+czJZfpZaVu2suYdh2IBXCxPKiL/pX7r6gZog= github.com/pebbe/zmq4 v1.2.8/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= @@ -211,6 +279,9 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -220,6 +291,7 @@ github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b h1:3EujQY7LEbzy github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b/go.mod h1:p+QQKBy7tS+myk+y3sgnAKx4gUtD/Q9Z6KEd77cLzWY= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -246,6 +318,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -293,6 +366,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -307,8 +381,11 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -326,10 +403,13 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -339,12 +419,18 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -360,6 +446,8 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -394,6 +482,7 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -512,6 +601,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/internal/consulservice/consulservice.go b/internal/consulservice/consulservice.go new file mode 100644 index 0000000..f2ba438 --- /dev/null +++ b/internal/consulservice/consulservice.go @@ -0,0 +1,60 @@ +package consulservice + +import ( + "fmt" + + consul "github.com/hashicorp/consul/api" +) + +//Client provides an interface for getting data out of Consul +type Client interface { + // Get a Service from consul + Service(string, string) ([]string, error) + // Register a service with local agent + Register(string, int) error + // Deregister a service with local agent + DeRegister(string) error +} + +type client struct { + consul *consul.Client +} + +//NewConsul returns a Client interface for given consul address +func NewConsulClient(addr string) (Client, error) { + config := consul.DefaultConfig() + config.Address = addr + c, err := consul.NewClient(config) + if err != nil { + return nil, err + } + return &client{consul: c}, nil +} + +// Register a service with consul local agent +func (c *client) Register(name string, port int) error { + reg := &consul.AgentServiceRegistration{ + ID: name, + Name: name, + Port: port, + } + return c.consul.Agent().ServiceRegister(reg) +} + +// DeRegister a service with consul local agent +func (c *client) DeRegister(id string) error { + return c.consul.Agent().ServiceDeregister(id) +} + +// Service return a service +func (c *client) Service(service, tag string) ([]*consul.ServiceEntry, *consul.QueryMeta, error) { + passingOnly := true + addrs, meta, err := c.consul.Health().Service(service, tag, passingOnly, nil) + if len(addrs) == 0 && err == nil { + return nil, fmt.Errorf("service ( %s ) was not found", service) + } + if err != nil { + return nil, err + } + return addrs, meta, nil +} From 134f33cd6a011cb44bc18d1253bb892b9133f27b Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 14 Jul 2022 13:27:46 -0700 Subject: [PATCH 31/80] Minor cleanup and and got the client sending agents again. --- assets/docker/Dockerfile | 8 +-- assets/examples/genesis.json | 3 +- cmd/gagent/main.go | 19 +++---- internal/client/client.go | 6 ++- internal/consulservice/consulservice.go | 7 +-- internal/gstructs/gstructs.go | 67 ++++++++++--------------- internal/worker/worker.go | 4 +- 7 files changed, 50 insertions(+), 64 deletions(-) diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index cb8b245..e0c7adc 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM dragonheim/golang:1.17 as builder +FROM dragonheim/golang:1.18 as builder ARG SEMVER WORKDIR /gagent @@ -12,7 +12,7 @@ RUN apk add --no-cache zeromq-dev build-base git RUN go build -o /gagent/bin/gagent -ldflags "-X main.semVER=${SEMVER}" cmd/gagent/main.go RUN strip /gagent/bin/gagent -FROM alpine:3.15 +FROM alpine:3.16 ARG SEMVER LABEL Name="G'Agent" LABEL Maintainer="jwells@dragonheim.net" @@ -23,8 +23,8 @@ RUN apk add --no-cache zeromq && mkdir -p -m 0700 /etc/gagent COPY --from=builder /gagent/assets/examples/gagent.hcl /etc/gagent/gagent.hcl COPY --from=builder /gagent/bin/gagent /usr/bin/ -# Router Client Worker -EXPOSE 35570/tcp 35571/tcp 35572/tcp +# Router Client Worker Prometheus +EXPOSE 35570/tcp 35572/tcp 35571/tcp 9101/tcp VOLUME /etc/gagent CMD ["/usr/bin/gagent"] diff --git a/assets/examples/genesis.json b/assets/examples/genesis.json index e92a2ff..797ef6b 100644 --- a/assets/examples/genesis.json +++ b/assets/examples/genesis.json @@ -9,4 +9,5 @@ "clients": { "client": "7e9d13fe-5151-5876-66c0-20ca03e8fca4" } -} \ No newline at end of file +} + diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 3274233..02e7608 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -143,35 +143,28 @@ func init() { config.UUID = uuid.NewV4UUID().String() /* - * By default, we want to listen on all IP addresses. It can be overridden - * in the configuration file by setting listenaddr + * By default, we want to listen on all IP addresses. */ config.ListenAddr = "0.0.0.0" /* - * By default, G'Agent will use port 9101 or monitoring via prometheus. - * It can be overridden in the configuration file by setting clientport + * G'Agent will use this port for monitoring via prometheus., If set + * is set to 0, G'Agent will not listen for prometheus metrics. */ config.MonitorPort = 9101 /* - * By default, G'Agent client will use port 35572 to communicate with the - * routers, but you can override it by setting the clientport in the - * configuration file + * G'Agent client will use this port to communicate with the routers. */ config.ClientPort = 35572 /* - * By default, G'Agent router will use port 35570 to communicate with - * other routers, but you can override it by setting the routerport in - * the configuration file + * G'Agent router will use this port to communicate with other routers. */ config.RouterPort = 35570 /* - * By default, G'Agent worker will use port 35571 to communicate with the - * routers, but you can override it by setting the workerport in the - * configuration file + * G'Agent worker will use this port to communicate with the routers. */ config.WorkerPort = 35571 diff --git a/internal/client/client.go b/internal/client/client.go index e869453..07a8b2d 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -2,6 +2,7 @@ package client import ( sha "crypto/sha256" + hex "encoding/hex" fmt "fmt" ioutil "io/ioutil" log "log" @@ -40,9 +41,10 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[DEBUG] Agent file contents: \n----- -----\n%s\n----- -----\n", agent.ScriptCode) } agent.Client = config.UUID - agent.Shasum = fmt.Sprintf("%s", sha.Sum256(agent.ScriptCode)) + tmpsum := sha.Sum256([]byte(agent.ScriptCode)) + agent.Shasum = fmt.Sprintf("%v", hex.EncodeToString(tmpsum[:])) log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum) - agent.Status = "loaded" + agent.Status = 1 agent.Hints = getTagsFromHints(agent) agent.Answer = nil diff --git a/internal/consulservice/consulservice.go b/internal/consulservice/consulservice.go index f2ba438..32ef70d 100644 --- a/internal/consulservice/consulservice.go +++ b/internal/consulservice/consulservice.go @@ -28,7 +28,8 @@ func NewConsulClient(addr string) (Client, error) { if err != nil { return nil, err } - return &client{consul: c}, nil + return &client{c}, nil + //return &client{consul: c}, nil } // Register a service with consul local agent @@ -51,10 +52,10 @@ func (c *client) Service(service, tag string) ([]*consul.ServiceEntry, *consul.Q passingOnly := true addrs, meta, err := c.consul.Health().Service(service, tag, passingOnly, nil) if len(addrs) == 0 && err == nil { - return nil, fmt.Errorf("service ( %s ) was not found", service) + return nil, nil, fmt.Errorf("service ( %s ) was not found", service) } if err != nil { - return nil, err + return nil, nil, err } return addrs, meta, nil } diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 8a13593..342ec70 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -24,16 +24,14 @@ type GagentConfig struct { */ type ClientDetails struct { /* - * Client name for display purposes in logs and - * diagnostics. + * Client name for display purposes in logs and diagnostics. */ ClientName string `hcl:",label"` /* - * UUID String for the client node. This is used by - * the router to determine which MQ client to send - * the agent's results to. This attempts to keep the - * clients unique globally. + * UUID String for the client node. This is used by the router to + * determine which MQ client to send the agent's results to. This + * attempts to keep the clients unique globally. */ ClientID string `hcl:"clientid,optional"` } @@ -43,52 +41,44 @@ type ClientDetails struct { */ type RouterDetails struct { /* - * Router name for display purposes in logs and - * diagnostics + * Router name for display purposes in logs and diagnostics. */ RouterName string `hcl:",label"` /* - * UUID String for the router node. This is used by - * the clients, routers, and workers to determine - * which MQ router to send the agent's requests to. - * This attempts to keep the routers unique globally. + * UUID String for the router node. This is used by the clients, + * routers, and workers to determine which MQ router to send the + * agent's requests to. This attempts to keep the routers unique + * globally. */ RouterID string `hcl:"routerid,attr"` /* - * This is the IP address or hostname the router - * will listen on. The router will start up a 0MQ - * service that clients and workers will connect to. + * This is the IP address or hostname the router will listen on. The + * router will start up a 0MQ service that clients and workers will + * connect to. */ RouterAddr string `hcl:"address,attr"` /* - * This is the is the port that the router listens - * on for clients. If not defined, it will default - * to 35571. + * G'Agent client will use this port to communicate with the routers. */ ClientPort int64 `hcl:"clientport,optional"` /* - * This is the is the port that the router listens - * on for routers. If not defined, it will default - * to 35570. + * G'Agent router will use this port to communicate with other routers. */ RouterPort int64 `hcl:"routerport,optional"` /* - * This is the is the port that the router listens - * on for clients. If not defined, it will default - * to 35572. + * G'Agent worker will use this port to communicate with the routers. */ WorkerPort int64 `hcl:"workerport,optional"` /* - * These tags will be passed to the router upon - * connection. The router will then use these - * tags to help determine which worker / client - * to send the client's requests and results to. + * These tags will be passed to the router upon connection. The router + * will then use these tags to help determine which worker / client to + * send the client's requests and results to. */ RouterTags []string `hcl:"tags,optional"` } @@ -98,33 +88,30 @@ type RouterDetails struct { */ type WorkerDetails struct { /* - * Router name for display purposes in logs and - * diagnostics + * Router name for display purposes in logs and diagnostics. */ WorkerName string `hcl:",label"` /* - * UUID String for the worker node. This is used - * by the router to determine which MQ client to - * send agents to. This attempts to keep the - * workers unique globally. + * UUID String for the worker node. This is used by the router to + * determine which MQ client to send agents to. This attempts to keep + * the workers unique globally. */ WorkerID string `hcl:"workerid,attr"` /* - * These tags will be passed to the router upon - * connection. The router will then use these - * tags to help determine which worker / client - * to send the agent and it's results to. + * These tags will be passed to the router upon connection. The router + * will then use these tags to help determine which worker / client to + * send the agent and it's results to. */ WorkerTags []string `hcl:"tags,optional"` } type AgentDetails struct { Client string `hcl:"client"` + Status int64 `hcl:"status"` Shasum string `hcl:"shasum"` - Status string `hcl:"status"` - ScriptCode []byte Hints []string + ScriptCode []byte Answer []byte } diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 8cebdb8..89766e4 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -57,7 +57,9 @@ func getAgent(wg *sync.WaitGroup, uuid string, connectString string) { subscriber, _ := zmq.NewSocket(zmq.REP) defer subscriber.Close() - _ = subscriber.Connect(connectString) + // _ = subscriber.Connect(connectString) + foo := subscriber.Connect(connectString) + log.Printf("[DEBUG] Connected to %s\n", foo) msg, err := subscriber.Recv(0) if err != nil { From 89f1dce976e3cc1375d58763f86e54691d831a6a Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 15 Jul 2022 06:38:21 -0700 Subject: [PATCH 32/80] Restoring connector for worker. --- internal/worker/worker.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 89766e4..8cebdb8 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -57,9 +57,7 @@ func getAgent(wg *sync.WaitGroup, uuid string, connectString string) { subscriber, _ := zmq.NewSocket(zmq.REP) defer subscriber.Close() - // _ = subscriber.Connect(connectString) - foo := subscriber.Connect(connectString) - log.Printf("[DEBUG] Connected to %s\n", foo) + _ = subscriber.Connect(connectString) msg, err := subscriber.Recv(0) if err != nil { From c677d30cf54a0811aeedc2c8083d96af3075b065 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 5 Aug 2022 06:44:11 -0700 Subject: [PATCH 33/80] Removing consul service as it is not ready for inclusion yet. --- internal/consulservice/consulservice.go | 61 ------------------------- 1 file changed, 61 deletions(-) delete mode 100644 internal/consulservice/consulservice.go diff --git a/internal/consulservice/consulservice.go b/internal/consulservice/consulservice.go deleted file mode 100644 index 32ef70d..0000000 --- a/internal/consulservice/consulservice.go +++ /dev/null @@ -1,61 +0,0 @@ -package consulservice - -import ( - "fmt" - - consul "github.com/hashicorp/consul/api" -) - -//Client provides an interface for getting data out of Consul -type Client interface { - // Get a Service from consul - Service(string, string) ([]string, error) - // Register a service with local agent - Register(string, int) error - // Deregister a service with local agent - DeRegister(string) error -} - -type client struct { - consul *consul.Client -} - -//NewConsul returns a Client interface for given consul address -func NewConsulClient(addr string) (Client, error) { - config := consul.DefaultConfig() - config.Address = addr - c, err := consul.NewClient(config) - if err != nil { - return nil, err - } - return &client{c}, nil - //return &client{consul: c}, nil -} - -// Register a service with consul local agent -func (c *client) Register(name string, port int) error { - reg := &consul.AgentServiceRegistration{ - ID: name, - Name: name, - Port: port, - } - return c.consul.Agent().ServiceRegister(reg) -} - -// DeRegister a service with consul local agent -func (c *client) DeRegister(id string) error { - return c.consul.Agent().ServiceDeregister(id) -} - -// Service return a service -func (c *client) Service(service, tag string) ([]*consul.ServiceEntry, *consul.QueryMeta, error) { - passingOnly := true - addrs, meta, err := c.consul.Health().Service(service, tag, passingOnly, nil) - if len(addrs) == 0 && err == nil { - return nil, nil, fmt.Errorf("service ( %s ) was not found", service) - } - if err != nil { - return nil, nil, err - } - return addrs, meta, nil -} From 316ea1afa66eb954c47babb429a694dbe4cd0ed2 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 21 Nov 2022 14:28:30 -0800 Subject: [PATCH 34/80] Updating versions. --- .devcontainer/Dockerfile | 5 +++-- .devcontainer/devcontainer.json | 2 +- .drone.yml | 4 ++-- assets/docker/Dockerfile | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index f2ad597..895debe 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,10 +1,11 @@ # 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.18" +ARG VARIANT="1.19" FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} -COPY --from=aquasec/trivy:0.25.4 /usr/local/bin/trivy /usr/bin/trivy +COPY --from=aquasec/trivy:0.32.1 /usr/local/bin/trivy /usr/bin/trivy +COPY --from=securego/gosec:2.13.1 /bin/gosec /usr/bin/gosec # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 ARG NODE_VERSION="none" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 90d13ec..583bcfd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,7 @@ // 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.18-bullseye", + "VARIANT": "1.19-bullseye", // Options "NODE_VERSION": "none" } diff --git a/.drone.yml b/.drone.yml index aef2c6b..07dbb89 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,7 +30,7 @@ steps: - refs/tags/** - name: Validate code base and dependencies - image: dragonheim/golang:1.17 + image: dragonheim/golang:latest volumes: - name: dockersock path: /var/run/docker.sock @@ -86,7 +86,7 @@ steps: - echo "running" - name: Build and push container - image: dragonheim/golang:1.17 + image: dragonheim/golang:latest volumes: - name: dockersock path: /var/run/docker.sock diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index e0c7adc..7ec7c03 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM dragonheim/golang:1.18 as builder +FROM dragonheim/golang:1.19 as builder ARG SEMVER WORKDIR /gagent From 77c9399942ca8d0bf523cc4b628a28ef7fadff7b Mon Sep 17 00:00:00 2001 From: James Wells Date: Wed, 11 Jan 2023 18:49:48 -0800 Subject: [PATCH 35/80] fix: changed import source. --- .trivyignore | 6 +- README.md | 4 +- assets/docker/Dockerfile | 2 +- cmd/gagent/main.go | 12 +-- docs/CHANGELOG.md | 4 +- docs/LANGUAGE.md | 2 +- go.mod | 22 ++--- go.sum | 120 ++------------------------ internal/chaindb/chaindb.go | 2 +- internal/client/client.go | 14 +-- internal/router/router.go | 16 ++-- internal/setup/setup.go | 4 +- internal/worker/worker.go | 14 +-- pkg/picol/picol_unused/main.go_unused | 2 +- 14 files changed, 54 insertions(+), 170 deletions(-) diff --git a/.trivyignore b/.trivyignore index 7622450..eed8887 100644 --- a/.trivyignore +++ b/.trivyignore @@ -1,2 +1,6 @@ # No impact in our project -CVE-2021-3121 \ No newline at end of file +# CVE-2021-3121 +# GHSA-c3h9-896r-86jm + +CVE-2022-32149 +# GHSA-69ch-w2m2-3vjp diff --git a/README.md b/README.md index ce86be2..008a767 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![License](https://img.shields.io/badge/License-MIT-limegreen.svg)](https://github.com/dragonheim/gagent/src/branch/main/LICENSE) [![Build Status](https://drone.dragonheim.net/api/badges/dragonheim/gagent/status.svg)](https://drone.dragonheim.net/dragonheim/gagent) -[![Go Report Card](https://goreportcard.com/badge/git.dragonheim.net/dragonheim/gagent)](https://goreportcard.com/report/git.dragonheim.net/dragonheim/gagent) +[![Go Report Card](https://goreportcard.com/badge/github.com/dragonheim/gagent)](https://goreportcard.com/report/github.com/dragonheim/gagent) [![Docker Pulls](https://img.shields.io/docker/pulls/dragonheim/gagent)](https://hub.docker.com/r/dragonheim/gagent/tags?page=1&ordering=last_updated) A Golang based mobile agent system loosely inspired by the [Agent Tcl / D'Agents](http://www.cs.dartmouth.edu/~dfk/agents/) system created by Robert S. Gray of Dartmouth college. @@ -34,4 +34,4 @@ Line 8 executes the hello_earth procedure defined above. ## History -More information about Agent TCL / D'Agents can be found in the original [documentation](http://www.cs.dartmouth.edu/~dfk/agents/pub/agents/doc.5.1.ps.gz), and in the project's [wiki](https://git.dragonheim.net/dragonheim/gagent/wiki/_pages). +More information about Agent TCL / D'Agents can be found in the original [documentation](http://www.cs.dartmouth.edu/~dfk/agents/pub/agents/doc.5.1.ps.gz), and in the project's [wiki](https://github.com/dragonheim/gagent/wiki/_pages). diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index 7ec7c03..9f7d8b5 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -12,7 +12,7 @@ RUN apk add --no-cache zeromq-dev build-base git RUN go build -o /gagent/bin/gagent -ldflags "-X main.semVER=${SEMVER}" cmd/gagent/main.go RUN strip /gagent/bin/gagent -FROM alpine:3.16 +FROM alpine:3.17 ARG SEMVER LABEL Name="G'Agent" LABEL Maintainer="jwells@dragonheim.net" diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 02e7608..4eb56ce 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -11,12 +11,12 @@ import ( fqdn "github.com/Showmax/go-fqdn" - gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gstructs "github.com/dragonheim/gagent/internal/gstructs" - gc "git.dragonheim.net/dragonheim/gagent/internal/client" - gr "git.dragonheim.net/dragonheim/gagent/internal/router" - gs "git.dragonheim.net/dragonheim/gagent/internal/setup" - gw "git.dragonheim.net/dragonheim/gagent/internal/worker" + gc "github.com/dragonheim/gagent/internal/client" + gr "github.com/dragonheim/gagent/internal/router" + gs "github.com/dragonheim/gagent/internal/setup" + gw "github.com/dragonheim/gagent/internal/worker" docopt "github.com/aviddiviner/docopt-go" @@ -30,7 +30,7 @@ import ( ) var ( - semVER = "0.0.5" + semVER = "0.0.6" ) var ( diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c4b3c4a..6392d8a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,4 +1,4 @@ -### [0.0.0](https://git.dragonheim.net/dragonheim/gagent/commit/5863999) (20210425) +### [0.0.0](https://github.com/dragonheim/gagent/commit/5863999) (20210425) --- #### Features -* [Initial Commit](https://git.dragonheim.net/dragonheim/gagent/commit/5863999) -- James Wells +* [Initial Commit](https://github.com/dragonheim/gagent/commit/5863999) -- James Wells diff --git a/docs/LANGUAGE.md b/docs/LANGUAGE.md index 3a11172..a7ac947 100644 --- a/docs/LANGUAGE.md +++ b/docs/LANGUAGE.md @@ -6,7 +6,7 @@ Document the G'Agent TCL language extension. We are using [Lain Dono](mailto:lain.dono@gmail.com)'s [Picol](https://github.com/lain-dono/picol.go) package though we will be modifying it specific to support a subset of the [Agent Tcl / D'Agents](http://www.cs.dartmouth.edu/~dfk/agents/pub/agents/doc.5.1.ps.gz) language extensions and modern versions of Go. - The language extensions can be found in the [LANGUAGE.md](https://git.dragonheim.net/dragonheim/gagent/src/branch/main/LANGUAGE.md) file. + The language extensions can be found in the [LANGUAGE.md](https://github.com/dragonheim/gagent/src/branch/main/LANGUAGE.md) file. ## AgentTCL Language Extension diff --git a/go.mod b/go.mod index 18e9d5e..336a090 100644 --- a/go.mod +++ b/go.mod @@ -1,41 +1,29 @@ -module git.dragonheim.net/dragonheim/gagent +module github.com/dragonheim/gagent go 1.18 require ( github.com/Showmax/go-fqdn v1.0.0 github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a - github.com/hashicorp/consul/api v1.12.0 - github.com/hashicorp/hcl/v2 v2.11.1 + github.com/hashicorp/hcl/v2 v2.15.0 github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 github.com/pebbe/zmq4 v1.2.8 github.com/prometheus/client_golang v1.12.1 - github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b - github.com/zclconf/go-cty v1.10.0 + github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae + github.com/zclconf/go-cty v1.12.1 ) require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/fatih/color v1.9.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.7 // indirect - github.com/hashicorp/go-cleanhttp v0.5.1 // indirect - github.com/hashicorp/go-hclog v0.12.0 // indirect - github.com/hashicorp/go-immutable-radix v1.0.0 // indirect - github.com/hashicorp/go-rootcerts v1.0.2 // indirect - github.com/hashicorp/golang-lru v0.5.1 // indirect - github.com/hashicorp/serf v0.9.6 // indirect - github.com/mattn/go-colorable v0.1.6 // indirect - github.com/mattn/go-isatty v0.0.12 // indirect + github.com/kr/pretty v0.2.0 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/mitchellh/mapstructure v1.1.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.33.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect diff --git a/go.sum b/go.sum index e29827e..9eee2db 100644 --- a/go.sum +++ b/go.sum @@ -35,7 +35,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Showmax/go-fqdn v1.0.0 h1:0rG5IbmVliNT5O19Mfuvna9LL7zlHyRfsSvBPZmF9tM= github.com/Showmax/go-fqdn v1.0.0/go.mod h1:SfrFBzmDCtCGrnHhoDjuvFnKsWjEQX/Q9ARZvOrJAko= -github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -43,22 +42,14 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= -github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a h1:YJuVATwP+Gzk7nys0U/DKjKkoYp1n/sYm0yi5vX8W8M= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a/go.mod h1:pBRbUcGboHT5qBceq2Cg/WIcDbO78a8wPxTg8zmS3Hs= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 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/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= 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= @@ -75,9 +66,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= -github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -91,7 +79,6 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -104,7 +91,6 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -123,7 +109,6 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -149,43 +134,12 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/hashicorp/consul/api v1.12.0 h1:k3y1FYv6nuKyNTqj6w9gXOx5r5CfLj/k/euUeBXj1OY= -github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= -github.com/hashicorp/consul/sdk v0.8.0 h1:OJtKBtEjboEZvG6AOUdh4Z1Zbyu0WcxQ0qatRrZHTVU= -github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= -github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-hclog v0.12.0 h1:d4QkX8FRTYaKaCZBoXYY8zJX2BXjWxurN/GA2tkrmZM= -github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= -github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc= -github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= +github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= -github.com/hashicorp/memberlist v0.3.0 h1:8+567mCcFDnS5ADl7lrpxPMWiFCElyUEeW0gtj34fMA= -github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/serf v0.9.6 h1:uuEX1kLR6aoda1TBttmJQKDLZE1Ob7KN0NPdE7EtCDc= -github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= @@ -209,33 +163,10 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= -github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -243,18 +174,13 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pebbe/zmq4 v1.2.8 h1:sBO89w+czJZfpZaVu2suYdh2IBXCxPKiL/pX7r6gZog= github.com/pebbe/zmq4 v1.2.8/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= @@ -279,35 +205,23 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b h1:3EujQY7LEbzy5paxa0S2OrsL6+vTwYiUU/R272YlwiQ= -github.com/slayer/autorestart v0.0.0-20170706172704-7bc8d250279b/go.mod h1:p+QQKBy7tS+myk+y3sgnAKx4gUtD/Q9Z6KEd77cLzWY= -github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +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.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= -github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= -github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= +github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -315,10 +229,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -352,7 +264,6 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -366,7 +277,6 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -381,11 +291,8 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -403,34 +310,24 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -446,8 +343,6 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -462,7 +357,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -482,7 +376,6 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -601,7 +494,6 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go index 84da93d..7998a14 100644 --- a/internal/chaindb/chaindb.go +++ b/internal/chaindb/chaindb.go @@ -6,7 +6,7 @@ import ( log "log" time "time" - gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gstructs "github.com/dragonheim/gagent/internal/gstructs" hclsimple "github.com/hashicorp/hcl/v2/hclsimple" // hclwrite "github.com/hashicorp/hcl/v2/hclwrite" diff --git a/internal/client/client.go b/internal/client/client.go index 07a8b2d..3ed08a2 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -12,18 +12,18 @@ import ( sync "sync" time "time" - gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gstructs "github.com/dragonheim/gagent/internal/gstructs" zmq "github.com/pebbe/zmq4" ) /* - Client mode will send an agent file to a router for processing - Clients do not process the agent files, only send them as - requests to a router. If started without arguments, the client - will contact the router and attempt to retrieve the results - of it's most recent request. - Main is the entrypoint for the client process +Client mode will send an agent file to a router for processing +Clients do not process the agent files, only send them as +requests to a router. If started without arguments, the client +will contact the router and attempt to retrieve the results +of it's most recent request. +Main is the entrypoint for the client process */ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting client\n") diff --git a/internal/router/router.go b/internal/router/router.go index c8621f7..9fbda89 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -6,8 +6,8 @@ import ( http "net/http" sync "sync" - gcdb "git.dragonheim.net/dragonheim/gagent/internal/chaindb" - gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gcdb "github.com/dragonheim/gagent/internal/chaindb" + gstructs "github.com/dragonheim/gagent/internal/gstructs" prometheus "github.com/prometheus/client_golang/prometheus" promauto "github.com/prometheus/client_golang/prometheus/promauto" @@ -24,12 +24,12 @@ var ( ) /* - The 'router' processes routing requests from the agent. The router does - not handle any of the agent activities beyond processing the agent's - list of tags and passing the agent and it's storage to either a member - or client node. Tags are used by the agent to give hints as to where - it should be routed. - Main is the entrypoint for the router +The 'router' processes routing requests from the agent. The router does +not handle any of the agent activities beyond processing the agent's +list of tags and passing the agent and it's storage to either a member +or client node. Tags are used by the agent to give hints as to where +it should be routed. +Main is the entrypoint for the router */ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting router\n") diff --git a/internal/setup/setup.go b/internal/setup/setup.go index 767f8f1..983de6b 100644 --- a/internal/setup/setup.go +++ b/internal/setup/setup.go @@ -6,13 +6,13 @@ import ( cty "github.com/zclconf/go-cty/cty" - gs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gs "github.com/dragonheim/gagent/internal/gstructs" hclwrite "github.com/hashicorp/hcl/v2/hclwrite" ) /* - Main is the entrypoint for the setup process +Main is the entrypoint for the setup process */ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { log.Printf("[INFO] Starting setup\n") diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 8cebdb8..71929f0 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -5,9 +5,9 @@ import ( log "log" sync "sync" - gstructs "git.dragonheim.net/dragonheim/gagent/internal/gstructs" + gstructs "github.com/dragonheim/gagent/internal/gstructs" - // picol "git.dragonheim.net/dragonheim/gagent/src/picol" + // picol "github.com/dragonheim/gagent/src/picol" prometheus "github.com/prometheus/client_golang/prometheus" promauto "github.com/prometheus/client_golang/prometheus/promauto" @@ -22,11 +22,11 @@ var ( ) /* - The "worker" processes the agent code. The worker nodes do not know - anything about the network structure. Instead they know only to which - router(s) they are connected. The worker will execute the agent code and - pass the agent and it's results to a router. - Main is the entrypoint for the worker process +The "worker" processes the agent code. The worker nodes do not know +anything about the network structure. Instead they know only to which +router(s) they are connected. The worker will execute the agent code and +pass the agent and it's results to a router. +Main is the entrypoint for the worker process */ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting worker\n") diff --git a/pkg/picol/picol_unused/main.go_unused b/pkg/picol/picol_unused/main.go_unused index 588e31b..6860fdb 100644 --- a/pkg/picol/picol_unused/main.go_unused +++ b/pkg/picol/picol_unused/main.go_unused @@ -7,7 +7,7 @@ import ( "io/ioutil" "os" - picol "git.dragonheim.net/dragonheim/gagent/src/picol" + picol "github.com/dragonheim/gagent/src/picol" ) var fname = flag.String("f", "", "file name") From 4a9d4ceca875fdcaa953282d0e08a62063a10d81 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 10 Feb 2023 07:23:35 -0800 Subject: [PATCH 36/80] Added support for environmental config values Updated Go version to 1.20.0 --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 4 ++-- assets/docker/Dockerfile | 4 ++-- cmd/gagent/main.go | 16 +++++++++++++++- go.mod | 1 + go.sum | 2 ++ 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 895debe..6c78e3e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 583bcfd..2b009a7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" } diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index 9f7d8b5..5bb9731 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -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 . . diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 4eb56ce..0890664 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -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"), diff --git a/go.mod b/go.mod index 336a090..2eb63d0 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 9eee2db..48bf405 100644 --- a/go.sum +++ b/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.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= From 28dd864350997102c9bbff1d7014627d16336be2 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 27 Feb 2023 18:29:09 -0800 Subject: [PATCH 37/80] feat: minor documentation update. --- .trivyignore | 4 ---- cmd/gagent/main.go | 26 ++++++++++++++------------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.trivyignore b/.trivyignore index eed8887..95310e2 100644 --- a/.trivyignore +++ b/.trivyignore @@ -1,6 +1,2 @@ # No impact in our project -# CVE-2021-3121 -# GHSA-c3h9-896r-86jm - CVE-2022-32149 -# GHSA-69ch-w2m2-3vjp diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 0890664..379d78a 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -31,14 +31,6 @@ import ( uuid "github.com/jakehl/goid" ) -var ( - semVER = "0.0.6" -) - -var ( - wg sync.WaitGroup -) - /* * Exit Codes * 0 Success @@ -60,8 +52,19 @@ var environment struct { UUID string `env:"GAGENT_UUID" envDefault:""` } +// 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.6" + +// This is the application configuration. It is populated from the configuration +// file and then used throughout the application. var config gstructs.GagentConfig +// We use a WaitGroup to wait for all goroutines to finish before exiting. +var wg sync.WaitGroup + +// This is the main function, and it assumes that the configuration file has +// already been read and parsed by the init() function. func main() { log.Printf("[DEBUG] Configuration is %v\n", config) @@ -85,8 +88,6 @@ func main() { os.Exit(7) } - // cs.Client.ConsulRegister("gagent-router", config.RouterPort) - wg.Add(1) go gr.Main(&wg, config) @@ -98,8 +99,6 @@ func main() { os.Exit(6) } - // cs.Client.ConsulRegister("gagent-worker", config.WorkerPort) - wg.Add(1) go gw.Main(&wg, config) @@ -118,6 +117,9 @@ func main() { os.Exit(0) } +// This is the init() function. It is called before the main() function, and +// it reads the configuration file, parses the command line arguments, and +// reads the environment variables. It also sets up the logging. func init() { // var err error autorestart.StartWatcher() From b1759291b4ba09f4f06b534756661047f2c27122 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 6 Mar 2023 14:59:28 -0800 Subject: [PATCH 38/80] feat: minor cleanup. --- README.md | 2 +- assets/tfenv/terraform.tf | 4 ++-- cmd/gagent/main.go | 38 +++++++++++++++++++------------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 008a767..f5102c5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # G'Agent -[![Maintained Status](https://img.shields.io/maintenance/yes/2021?style=plastic)](https://github.com/dragonheim/gagent) +[![Maintained Status](https://img.shields.io/maintenance/yes/2023?style=plastic)](https://github.com/dragonheim/gagent) [![License](https://img.shields.io/badge/License-MIT-limegreen.svg)](https://github.com/dragonheim/gagent/src/branch/main/LICENSE) [![Build Status](https://drone.dragonheim.net/api/badges/dragonheim/gagent/status.svg)](https://drone.dragonheim.net/dragonheim/gagent) diff --git a/assets/tfenv/terraform.tf b/assets/tfenv/terraform.tf index bb7904b..4bb9e5c 100644 --- a/assets/tfenv/terraform.tf +++ b/assets/tfenv/terraform.tf @@ -1,9 +1,9 @@ terraform { - required_version = ">= 1.1.7" + required_version = ">= 1.3.1" required_providers { aws = { source = "hashicorp/aws" - version = "~> 4.5.0" + version = "~> 4.56.0" } } } diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 379d78a..0b118da 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -194,33 +194,33 @@ func init() { * and available arguments / options. Documentation is available at; * http://docopt.org/ */ - usage := "G'Agents \n" + usage := "G'Agents\n" usage += "\n" - usage += " Go based mobile agent system, loosely inspired by the Agent Tcl / D'Agents \n" - usage += " system created by Robert S. Gray of Dartmouth college. \n" + usage += " Go based mobile agent system, loosely inspired by the Agent Tcl / D'Agents\n" + usage += " system created by Robert S. Gray of Dartmouth college.\n" usage += "\n" - usage += "Usage: \n" - usage += " gagent client (pull|push) [--config=] [--agent=] \n" - usage += " gagent router [--config=] \n" - usage += " gagent worker [--config=] \n" - usage += " gagent setup [--config=] \n" - usage += " gagent --version \n" + usage += "Usage:\n" + usage += " gagent client (pull|push) [--config=] [--agent=]\n" + usage += " gagent router [--config=]\n" + usage += " gagent worker [--config=]\n" + usage += " gagent setup [--config=]\n" + usage += " gagent --version\n" usage += "\n" - usage += "Arguments: \n" - usage += " client pull -- Start as a G'Agent client to pull agent results \n" - usage += " client push -- Start as a G'Agent client to push agent \n" - usage += " router -- Start as a G'Agent router \n" - usage += " worker -- Start as a G'Agent worker \n" - usage += " setup -- Write initial configuration file \n" + usage += "Arguments:\n" + usage += " client pull -- Start as a G'Agent client to pull agent results\n" + usage += " client push -- Start as a G'Agent client to push agent\n" + usage += " router -- Start as a G'Agent router\n" + usage += " worker -- Start as a G'Agent worker\n" + usage += " setup -- Write initial configuration file\n" usage += "\n" usage += "Options:\n" - usage += " -h --help -- Show this help screen and exit \n" - usage += " --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 += " -h --help -- Show this help screen and exit\n" + usage += " --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" /* From 42417afc229ca91bde442466aa4faf3d7d637c19 Mon Sep 17 00:00:00 2001 From: James Wells Date: Wed, 15 Mar 2023 06:12:32 -0700 Subject: [PATCH 39/80] updated dependencies and cleaned up the Readme. --- .trivyignore | 2 - README.md | 7 +- go.mod | 29 +-- go.sum | 503 ++++----------------------------------------------- 4 files changed, 51 insertions(+), 490 deletions(-) diff --git a/.trivyignore b/.trivyignore index 95310e2..e69de29 100644 --- a/.trivyignore +++ b/.trivyignore @@ -1,2 +0,0 @@ -# No impact in our project -CVE-2022-32149 diff --git a/README.md b/README.md index f5102c5..c4a8d13 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,14 @@ A Golang based mobile agent system loosely inspired by the [Agent Tcl / D'Agents](http://www.cs.dartmouth.edu/~dfk/agents/) system created by Robert S. Gray of Dartmouth college. +## Sumary +G'Agent streamlines interplanetary data searches using TCL scripts, allowing efficient communication despite time delays between Earth and Mars. + ## Purpose -As we move close and closer to a true space-age, we need to start thinking about solutions for various space-age issues such as the bi-directional time delay between the surface of Mars and the surface of Earth. At present it takes between 6 and 44 minutes for single round-trip, making most online data services unuseable. G'Agent is a potential solution for data services given the time delay. +As we move closer and closer to a true space age, we need to start thinking about solutions for various space-age issues, such as the bi-directional time delay between the surface of Mars and the surface of Earth. At present, it takes between 6 and 44 minutes for a single round-trip, making most online data services unusable. G'Agent is a potential solution for data services given the time delay. -Imagine, for a moment, that you are on Mars and need to perform a data search in a specific domain space. You would have to explain it to someone on Earth, and hope they understand enough of the domain space to know where to search and understand you well enough to perform the actual search and then send you the results. With G'Agent, instead you would write a basic script (TCL), hereafter called an agent, providing various hints about the domain space and the search as TCL code. Your client would then send it on to a server, hereafter called a router, on Earth. The router may or may not know anything about the domain space of your search, so the router will use the hints that you provide to attempt to route the agent to known workers or other routers closer to the desired domain space. Eventually your agent will reach a router whose workers can handle your search. The workers, will take the agent, run the script portion and collect the response(s), returning the reponse(s) to the router(s) for return to your client. +Imagine, for a moment, that you are on Mars and need to perform a data search in a specific domain space. You would have to explain it to someone on Earth, and hope they understand enough of the domain space to know where to search and understand you well enough to perform the actual search and then send you the results. With G'Agent, instead, you would write a basic script (TCL), hereafter called an agent, providing various hints about the domain space and the search as TCL code. Your client would then send it to a server, hereafter called a router, on Earth. The router may or may not know anything about the domain space of your search, so the router will use the hints that you provide to attempt to route the agent to known workers or other routers closer to the desired domain space. Eventually, your agent will reach a router whose workers can handle your search. The workers will take the agent, run the script portion, and collect the response(s), returning the response(s) to the router(s) for return to your client. ## Example Agent ```tcl 1 : ################### diff --git a/go.mod b/go.mod index 2eb63d0..dcddcfd 100644 --- a/go.mod +++ b/go.mod @@ -6,29 +6,30 @@ 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/hcl/v2 v2.16.2 github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 - github.com/pebbe/zmq4 v1.2.8 - github.com/prometheus/client_golang v1.12.1 + github.com/pebbe/zmq4 v1.2.9 + github.com/prometheus/client_golang v1.14.0 github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae - github.com/zclconf/go-cty v1.12.1 + github.com/zclconf/go-cty v1.13.0 ) require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.7 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/kr/pretty v0.2.0 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.33.0 // indirect - github.com/prometheus/procfs v0.7.3 // indirect - golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect - golang.org/x/text v0.3.7 // indirect - google.golang.org/protobuf v1.28.0 // indirect + github.com/prometheus/client_model v0.3.0 // indirect + github.com/prometheus/common v0.42.0 // indirect + github.com/prometheus/procfs v0.9.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect + google.golang.org/protobuf v1.29.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 48bf405..e1c8dd3 100644 --- a/go.sum +++ b/go.sum @@ -1,511 +1,70 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Showmax/go-fqdn v1.0.0 h1:0rG5IbmVliNT5O19Mfuvna9LL7zlHyRfsSvBPZmF9tM= github.com/Showmax/go-fqdn v1.0.0/go.mod h1:SfrFBzmDCtCGrnHhoDjuvFnKsWjEQX/Q9ARZvOrJAko= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a h1:YJuVATwP+Gzk7nys0U/DKjKkoYp1n/sYm0yi5vX8W8M= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a/go.mod h1:pBRbUcGboHT5qBceq2Cg/WIcDbO78a8wPxTg8zmS3Hs= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -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= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= -github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/hcl/v2 v2.16.2 h1:mpkHZh/Tv+xet3sy3F9Ld4FyI2tUpWe9x3XtPx9f1a0= +github.com/hashicorp/hcl/v2 v2.16.2/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/pebbe/zmq4 v1.2.8 h1:sBO89w+czJZfpZaVu2suYdh2IBXCxPKiL/pX7r6gZog= -github.com/pebbe/zmq4 v1.2.8/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pebbe/zmq4 v1.2.9 h1:JlHcdgq6zpppNR1tH0wXJq0XK03pRUc4lBlHTD7aj/4= +github.com/pebbe/zmq4 v1.2.9/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 v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.33.0 h1:rHgav/0a6+uYgGdNt3jwz8FNSesO/Hsang3O0T9A5SE= -github.com/prometheus/common v0.33.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= +github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= +github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= +github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= 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.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= -github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0= +github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM= +google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 0de851e0e580d98fedf0262278adf89cac9b705a Mon Sep 17 00:00:00 2001 From: James Wells Date: Wed, 15 Mar 2023 06:19:57 -0700 Subject: [PATCH 40/80] Updated copyright dates. --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 5d2e857..24c7248 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # Released under MIT License -Copyright (c) 2017-2021 [James Wells](mailto:jwells@dragonheim.net?subject=G%27Agent) +Copyright (c) 2017-2023 [James Wells](mailto:jwells@dragonheim.net?subject=G%27Agent) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: From b95d3950c5de6097f042f15d50684bb2681bd3a1 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 20 Mar 2023 07:20:46 -0700 Subject: [PATCH 41/80] cleanup: Started cleaning up the commenting format. --- .devcontainer/Dockerfile | 4 ++-- assets/docker/Dockerfile | 2 +- cmd/gagent/main.go | 31 +++++++++++++++--------- docs/VULNERABILITIES.md | 45 +++++++++++++++++++---------------- internal/chaindb/chaindb.go | 5 ++-- internal/client/client.go | 15 ++++++------ internal/gstructs/gstructs.go | 4 +++- internal/router/router.go | 18 +++++++------- internal/setup/setup.go | 20 +++++++++------- internal/worker/worker.go | 20 +++++++++------- 10 files changed, 94 insertions(+), 70 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6c78e3e..2b04db0 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,8 +4,8 @@ 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 -COPY --from=securego/gosec:2.13.1 /bin/gosec /usr/bin/gosec +COPY --from=aquasec/trivy:0.38.3 /usr/local/bin/trivy /usr/bin/trivy +COPY --from=securego/gosec:2.15.0 /bin/gosec /usr/bin/gosec # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 ARG NODE_VERSION="none" diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index 5bb9731..1f6c1ba 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM dragonheim/golang:1.20 as builder +FROM nikatjef/golang:1.20 as builder ARG SEMVER=${SEMVER:-0.0.7} WORKDIR /gagent diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 0b118da..495e630 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -52,19 +52,27 @@ var environment struct { UUID string `env:"GAGENT_UUID" envDefault:""` } -// This is the application version number. It can be overridden at build time -// using the -ldflags "-X main.semVER=0.0.1" option. +/* + * 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.6" -// This is the application configuration. It is populated from the configuration -// file and then used throughout the application. +/* + * This is the application configuration. It is populated from the configuration + * file and then used throughout the application. + */ var config gstructs.GagentConfig -// We use a WaitGroup to wait for all goroutines to finish before exiting. +/* + * We use a WaitGroup to wait for all goroutines to finish before exiting. + */ var wg sync.WaitGroup -// This is the main function, and it assumes that the configuration file has -// already been read and parsed by the init() function. +/* + * This is the main function, and it assumes that the configuration file has + * already been read and parsed by the init() function. + */ func main() { log.Printf("[DEBUG] Configuration is %v\n", config) @@ -117,11 +125,12 @@ func main() { os.Exit(0) } -// This is the init() function. It is called before the main() function, and -// it reads the configuration file, parses the command line arguments, and -// reads the environment variables. It also sets up the logging. +/* + * This is the init() function. It is called before the main() function, and + * it reads the configuration file, parses the command line arguments, and + * reads the environment variables. It also sets up the logging. + */ func init() { - // var err error autorestart.StartWatcher() cfg := environment diff --git a/docs/VULNERABILITIES.md b/docs/VULNERABILITIES.md index 75540ae..f715c01 100644 --- a/docs/VULNERABILITIES.md +++ b/docs/VULNERABILITIES.md @@ -1,27 +1,32 @@ ### [Source Code Scan](#source) - -IGNORED: We are not using the protocol buffers provided by gogo/protobuf ``` -2022-03-16T16:27:43.221-0700 INFO Need to update DB -2022-03-16T16:27:43.221-0700 INFO Downloading DB... -26.43 MiB / 26.43 MiB [---------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00% 5.71 MiB p/s 5s -2022-03-16T16:27:49.073-0700 INFO Number of language-specific files: 1 -2022-03-16T16:27:49.073-0700 INFO Detecting gomod vulnerabilities... +2023-03-15T06:59:15.989-0700 INFO Need to update DB +2023-03-15T06:59:15.989-0700 INFO DB Repository: ghcr.io/aquasecurity/trivy-db +2023-03-15T06:59:15.989-0700 INFO Downloading DB... +36.01 MiB / 36.01 MiB [-----------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00% 7.93 MiB p/s 4.7s +2023-03-15T06:59:21.791-0700 INFO Vulnerability scanning is enabled +2023-03-15T06:59:21.791-0700 INFO Secret scanning is enabled +2023-03-15T06:59:21.791-0700 INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning +2023-03-15T06:59:21.791-0700 INFO Please see also https://aquasecurity.github.io/trivy/v0.37/docs/secret/scanning/#recommendation for faster secret detection +2023-03-15T06:59:25.698-0700 INFO Number of language-specific files: 1 +2023-03-15T06:59:25.699-0700 INFO Detecting gomod vulnerabilities... -go.sum (gomod) -============== -Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0) - -+--------------------------+------------------+----------+-------------------+---------------+--------------------------------------+ -| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE | -+--------------------------+------------------+----------+-------------------+---------------+--------------------------------------+ -| github.com/gogo/protobuf | CVE-2021-3121 | HIGH | 1.1.1 | 1.3.2 | gogo/protobuf: | -| | | | | | plugin/unmarshal/unmarshal.go | -| | | | | | lacks certain index validation | -| | | | | | -->avd.aquasec.com/nvd/cve-2021-3121 | -+--------------------------+------------------+----------+-------------------+---------------+--------------------------------------+ +Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0) ``` + --- ### [Image Scan](#image) +``` +2023-03-15T07:05:44.377-0700 INFO Vulnerability scanning is enabled +2023-03-15T07:05:44.377-0700 INFO Secret scanning is enabled +2023-03-15T07:05:44.377-0700 INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning +2023-03-15T07:05:44.377-0700 INFO Please see also https://aquasecurity.github.io/trivy/v0.37/docs/secret/scanning/#recommendation for faster secret detection +2023-03-15T07:05:44.731-0700 INFO Detected OS: alpine +2023-03-15T07:05:44.731-0700 INFO Detecting Alpine vulnerabilities... +2023-03-15T07:05:44.732-0700 INFO Number of language-specific files: 1 +2023-03-15T07:05:44.732-0700 INFO Detecting gobinary vulnerabilities... -NONE \ No newline at end of file +dragonheim/gagent:0.0.7 (alpine 3.17.2) + +Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0) +``` \ No newline at end of file diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go index 7998a14..54c1712 100644 --- a/internal/chaindb/chaindb.go +++ b/internal/chaindb/chaindb.go @@ -9,8 +9,9 @@ import ( gstructs "github.com/dragonheim/gagent/internal/gstructs" hclsimple "github.com/hashicorp/hcl/v2/hclsimple" - // hclwrite "github.com/hashicorp/hcl/v2/hclwrite" -) + /* + * hclwrite "github.com/hashicorp/hcl/v2/hclwrite" + */) type GagentDb struct { chainRow []*gagentDbRow `hcl:"timestamp,block"` diff --git a/internal/client/client.go b/internal/client/client.go index 3ed08a2..413eb93 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -18,13 +18,13 @@ import ( ) /* -Client mode will send an agent file to a router for processing -Clients do not process the agent files, only send them as -requests to a router. If started without arguments, the client -will contact the router and attempt to retrieve the results -of it's most recent request. -Main is the entrypoint for the client process -*/ + * Client mode will send an agent file to a router for processing + * Clients do not process the agent files, only send them as + * requests to a router. If started without arguments, the client + * will contact the router and attempt to retrieve the results + * of it's most recent request. + * Main is the entrypoint for the client process + */ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting client\n") defer wg.Done() @@ -102,7 +102,6 @@ func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent gstr status, err := sock.SendMessage(agent) if err != nil { log.Printf("[ERROR] Failed to send agent to router\n") - // os.Exit(11) return } log.Printf("[DEBUG] Agent send status: %d\n", status) diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 342ec70..82faf20 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -1,6 +1,8 @@ package gstructs -// GagentConfig is the primary construct used by all modes +/* + * GagentConfig is the primary construct used by all modes + */ type GagentConfig struct { Name string `hcl:"name,optional"` Mode string `hcl:"mode,attr"` diff --git a/internal/router/router.go b/internal/router/router.go index 9fbda89..8f19480 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -24,13 +24,13 @@ var ( ) /* -The 'router' processes routing requests from the agent. The router does -not handle any of the agent activities beyond processing the agent's -list of tags and passing the agent and it's storage to either a member -or client node. Tags are used by the agent to give hints as to where -it should be routed. -Main is the entrypoint for the router -*/ + * The 'router' processes routing requests from the agent. The router does + * not handle any of the agent activities beyond processing the agent's + * list of tags and passing the agent and it's storage to either a member + * or client node. Tags are used by the agent to give hints as to where + * it should be routed. + * Main is the entrypoint for the router + */ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting router\n") defer wg.Done() @@ -139,7 +139,9 @@ func unwrap(msg []string) (head string, tail []string) { func answerClient(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { opsProcessed.Inc() - // fmt.Fprintf(w, "%v\n", r) + /* + * fmt.Fprintf(w, "%v\n", r) + */ http.NotFound(w, r) return } diff --git a/internal/setup/setup.go b/internal/setup/setup.go index 983de6b..4350dc1 100644 --- a/internal/setup/setup.go +++ b/internal/setup/setup.go @@ -12,8 +12,8 @@ import ( ) /* -Main is the entrypoint for the setup process -*/ + * Main is the entrypoint for the setup process + */ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { log.Printf("[INFO] Starting setup\n") defer wg.Done() @@ -31,13 +31,15 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { clientBlock1 := rootBody.AppendNewBlock("client", []string{config.Name}) clientBody1 := clientBlock1.Body() - // clientBody1.AppendUnstructuredTokens( - // hclwrite.TokensForTraversal(hcl.Traversal{ - // hcl.TraverseRoot{ - // Name: hcl.CommentGenerator("comment"), - // }, - // }, - // )) + /* + * clientBody1.AppendUnstructuredTokens( + * hclwrite.TokensForTraversal(hcl.Traversal{ + * hcl.TraverseRoot{ + * Name: hcl.CommentGenerator("comment"), + * }, + * }, + * )) + */ clientBody1.SetAttributeValue("clientid", cty.StringVal(config.UUID)) rootBody.AppendNewline() diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 71929f0..8cb4d12 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -7,7 +7,9 @@ import ( gstructs "github.com/dragonheim/gagent/internal/gstructs" - // picol "github.com/dragonheim/gagent/src/picol" + /* + * picol "github.com/dragonheim/gagent/src/picol" + */ prometheus "github.com/prometheus/client_golang/prometheus" promauto "github.com/prometheus/client_golang/prometheus/promauto" @@ -22,12 +24,12 @@ var ( ) /* -The "worker" processes the agent code. The worker nodes do not know -anything about the network structure. Instead they know only to which -router(s) they are connected. The worker will execute the agent code and -pass the agent and it's results to a router. -Main is the entrypoint for the worker process -*/ + * The "worker" processes the agent code. The worker nodes do not know + * anything about the network structure. Instead they know only to which + * router(s) they are connected. The worker will execute the agent code and + * pass the agent and it's results to a router. + * Main is the entrypoint for the worker process + */ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting worker\n") defer wg.Done() @@ -46,7 +48,9 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { wg.Add(1) go getAgent(wg, config.UUID, connectString) } - // workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort) + /* + * workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort) + */ } From 8640d421327ec5c1686bb38962672ea83dccd8eb Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 20 Mar 2023 16:00:15 -0700 Subject: [PATCH 42/80] refactor: cleaning up some old issues and stndardizing. --- cmd/gagent/main.go | 4 +- internal/gstructs/gstructs.go | 2 +- internal/worker/worker.go | 6 +- pkg/picol/commands.go | 131 +++++++++++++--------- pkg/picol/picol.go | 154 +++++++++++++++++--------- pkg/picol/picol_unused/main.go_unused | 6 +- 6 files changed, 190 insertions(+), 113 deletions(-) diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 495e630..b8a584d 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,10 +1,10 @@ package main import ( - fmt "fmt" log "log" http "net/http" os "os" + strconv "strconv" sync "sync" autorestart "github.com/slayer/autorestart" @@ -290,7 +290,7 @@ func init() { if config.MonitorPort != 0 { go func() { log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) - log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.MonitorPort), nil)) + log.Fatal(http.ListenAndServe(string(config.ListenAddr)+strconv.FormatInt(config.MonitorPort, 10), nil)) }() } } diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 82faf20..4f6a066 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -7,8 +7,8 @@ type GagentConfig struct { Name string `hcl:"name,optional"` Mode string `hcl:"mode,attr"` UUID string `hcl:"uuid,optional"` - MonitorPort int `hcl:"monitorport,optional"` ListenAddr string `hcl:"listenaddr,optional"` + MonitorPort int64 `hcl:"monitorport,optional"` ClientPort int64 `hcl:"clientport,optional"` RouterPort int64 `hcl:"routerport,optional"` WorkerPort int64 `hcl:"workerport,optional"` diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 8cb4d12..b13a53c 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -1,8 +1,8 @@ package worker import ( - fmt "fmt" log "log" + strconv "strconv" sync "sync" gstructs "github.com/dragonheim/gagent/internal/gstructs" @@ -43,13 +43,13 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { /* * Generate connect string for this router. */ - connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport) + connectString := "tcp://" + config.Routers[key].RouterAddr + ":" + strconv.FormatInt(rport, 10) wg.Add(1) go getAgent(wg, config.UUID, connectString) } /* - * workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort) + * workerListener := "tcp://" + config.ListenAddr + ":" + strconv.FormatInt(config.WorkerPort, 10) */ } diff --git a/pkg/picol/commands.go b/pkg/picol/commands.go index 991e710..0729f96 100644 --- a/pkg/picol/commands.go +++ b/pkg/picol/commands.go @@ -7,13 +7,18 @@ import ( "testing" ) -func arityErr(i *Interp, name string, argv []string) error { +/* + * incorrectArgCountError returns an error message indicating the incorrect + * number of arguments provided for a given function. It takes an interpreter + * instance 'i', the function name 'name', and a slice of argument values 'argv'. + */ +func incorrectArgCountError(i *Interpreter, name string, argv []string) error { return fmt.Errorf("wrong number of args for %s %s", name, argv) } /* - needleInHaystack returns true if the string is in a slice -*/ + * needleInHaystack returns true if the string is in a slice + */ func needleInHaystack(needle string, haystack []string) bool { for _, haystackMember := range haystack { if haystackMember == needle { @@ -24,9 +29,9 @@ func needleInHaystack(needle string, haystack []string) bool { } /* - TestneedleInHaystack tests the return value of needleInHaystack -*/ -func TestneedleInHaystack(t *testing.T) { + * Test_needleInHaystack tests the return value of needleInHaystack + */ +func Test_needleInHaystack(t *testing.T) { var haystack = []string{"a", "b", "c"} var needle = "a" if !needleInHaystack(needle, haystack) { @@ -44,10 +49,12 @@ func TestneedleInHaystack(t *testing.T) { } } -// CommandMath is the math command for TCL -func CommandMath(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandMath is the math command for TCL + */ +func CommandMath(i *Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 3 { - return "", arityErr(i, argv[0], argv) + return "", incorrectArgCountError(i, argv[0], argv) } a, _ := strconv.Atoi(argv[1]) b, _ := strconv.Atoi(argv[2]) @@ -91,28 +98,34 @@ func CommandMath(i *Interp, argv []string, pd interface{}) (string, error) { return fmt.Sprintf("%d", c), nil } -// CommandSet is the set command for TCL -func CommandSet(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandSet is the set command for TCL + */ +func CommandSet(i *Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 3 { - return "", arityErr(i, argv[0], argv) + return "", incorrectArgCountError(i, argv[0], argv) } - i.SetVar(argv[1], argv[2]) + i.SetVariable(argv[1], argv[2]) return argv[2], nil } -// CommandUnset is the unset command for TCL -func CommandUnset(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandUnset is the unset command for TCL + */ +func CommandUnset(i *Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 2 { - return "", arityErr(i, argv[0], argv) + return "", incorrectArgCountError(i, argv[0], argv) } - i.UnsetVar(argv[1]) + i.UnsetVariable(argv[1]) return "", nil } -// CommandIf is the if command for TCL -func CommandIf(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandIf is the if command for TCL + */ +func CommandIf(i *Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 3 && len(argv) != 5 { - return "", arityErr(i, argv[0], argv) + return "", incorrectArgCountError(i, argv[0], argv) } result, err := i.Eval(argv[1]) @@ -129,10 +142,12 @@ func CommandIf(i *Interp, argv []string, pd interface{}) (string, error) { return result, nil } -// CommandWhile is the while command for TCL -func CommandWhile(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandWhile is the while command for TCL + */ +func CommandWhile(i *Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 3 { - return "", arityErr(i, argv[0], argv) + return "", incorrectArgCountError(i, argv[0], argv) } for { @@ -143,9 +158,11 @@ func CommandWhile(i *Interp, argv []string, pd interface{}) (string, error) { if r, _ := strconv.Atoi(result); r != 0 { result, err := i.Eval(argv[2]) switch err { - case errContinue, nil: - //pass - case errBreak: + case ErrContinue, nil: + /* + * pass + */ + case ErrBreak: return result, nil default: return result, err @@ -156,22 +173,26 @@ func CommandWhile(i *Interp, argv []string, pd interface{}) (string, error) { } } -// CommandRetCodes is a function to get the return codes for TCL -func CommandRetCodes(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandRetCodes is a function to get the return codes for TCL + */ +func CommandRetCodes(i *Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 1 { - return "", arityErr(i, argv[0], argv) + return "", incorrectArgCountError(i, argv[0], argv) } switch argv[0] { case "break": - return "", errBreak + return "", ErrBreak case "continue": - return "", errContinue + return "", ErrContinue } return "", nil } -// CommandCallProc is a function to call proc commands for TCL -func CommandCallProc(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandCallProc is a function to call proc commands for TCL + */ +func CommandCallProc(i *Interpreter, argv []string, pd interface{}) (string, error) { var x []string if pd, ok := pd.([]string); ok { @@ -180,7 +201,7 @@ func CommandCallProc(i *Interp, argv []string, pd interface{}) (string, error) { return "", nil } - i.callframe = &CallFrame{vars: make(map[string]Var), parent: i.callframe} + i.callframe = &CallFrame{vars: make(map[string]Variable), parent: i.callframe} defer func() { i.callframe = i.callframe.parent }() // remove the called proc callframe arity := 0 @@ -189,7 +210,7 @@ func CommandCallProc(i *Interp, argv []string, pd interface{}) (string, error) { continue } arity++ - i.SetVar(arg, argv[arity]) + i.SetVariable(arg, argv[arity]) } if arity != len(argv)-1 { @@ -198,42 +219,50 @@ func CommandCallProc(i *Interp, argv []string, pd interface{}) (string, error) { body := x[1] result, err := i.Eval(body) - if err == errReturn { + if err == ErrReturn { err = nil } return result, err } -// CommandProc is a function to register proc commands for TCL -func CommandProc(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandProc is a function to register proc commands for TCL + */ +func CommandProc(i *Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 4 { - return "", arityErr(i, argv[0], argv) + return "", incorrectArgCountError(i, argv[0], argv) } return "", i.RegisterCommand(argv[1], CommandCallProc, []string{argv[2], argv[3]}) } -// CommandReturn is a function to register return codes for commands for TCL -func CommandReturn(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandReturn is a function to register return codes for commands for TCL + */ +func CommandReturn(i *Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 1 && len(argv) != 2 { - return "", arityErr(i, argv[0], argv) + return "", incorrectArgCountError(i, argv[0], argv) } var r string if len(argv) == 2 { r = argv[1] } - return r, errReturn + return r, ErrReturn } -// CommandError is a function to return error codes for commands for TCL -func CommandError(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandError is a function to return error codes for commands for TCL + */ +func CommandError(i *Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 1 && len(argv) != 2 { - return "", arityErr(i, argv[0], argv) + return "", incorrectArgCountError(i, argv[0], argv) } return "", fmt.Errorf(argv[1]) } -// CommandPuts is a function to print strings for TCL -func CommandPuts(i *Interp, argv []string, pd interface{}) (string, error) { +/* + * CommandPuts is a function to print strings for TCL + */ +func CommandPuts(i *Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 2 { return "", fmt.Errorf("wrong number of args for %s %s", argv[0], argv) } @@ -241,8 +270,10 @@ func CommandPuts(i *Interp, argv []string, pd interface{}) (string, error) { return "", nil } -// RegisterCoreCommands is a callable to register TCL commands. -func (i *Interp) RegisterCoreCommands() { +/* + * RegisterCoreCommands is a callable to register TCL commands. + */ +func (i *Interpreter) RegisterCoreCommands() { name := [...]string{"+", "-", "*", "/", ">", ">=", "<", "<=", "==", "!="} for _, n := range name { _ = i.RegisterCommand(n, CommandMath, nil) diff --git a/pkg/picol/picol.go b/pkg/picol/picol.go index 0beb01d..10a068b 100644 --- a/pkg/picol/picol.go +++ b/pkg/picol/picol.go @@ -6,38 +6,66 @@ import ( "strings" ) +/* + * Error variables + */ var ( - errReturn = errors.New("RETURN") - errBreak = errors.New("BREAK") - errContinue = errors.New("CONTINUE") + ErrReturn = errors.New("RETURN") + ErrBreak = errors.New("BREAK") + ErrContinue = errors.New("CONTINUE") ) -type Var string -type CmdFunc func(i *Interp, argv []string, privdata interface{}) (string, error) -type Cmd struct { - fn CmdFunc +/* + * Variable type + */ +type Variable string + +/* + * CommandFunc type + */ +type CommandFunc func(interp *Interpreter, argv []string, privdata interface{}) (string, error) + +/* + * Command structure + */ +type Command struct { + fn CommandFunc privdata interface{} } + +/* + * CallFrame structure + */ type CallFrame struct { - vars map[string]Var + vars map[string]Variable parent *CallFrame } -type Interp struct { + +/* + * Interpreter structure + */ +type Interpreter struct { level int callframe *CallFrame - commands map[string]Cmd + commands map[string]Command } -func InitInterp() *Interp { - return &Interp{ +/* + * NewInterpreter initializes a new Interpreter + */ +func NewInterpreter() *Interpreter { + return &Interpreter{ level: 0, - callframe: &CallFrame{vars: make(map[string]Var)}, - commands: make(map[string]Cmd), + callframe: &CallFrame{vars: make(map[string]Variable)}, + commands: make(map[string]Command), } } -func (i *Interp) Var(name string) (Var, bool) { - for frame := i.callframe; frame != nil; frame = frame.parent { +/* + * Variable retrieves a variable's value + */ +func (interp *Interpreter) Variable(name string) (Variable, bool) { + for frame := interp.callframe; frame != nil; frame = frame.parent { v, ok := frame.vars[name] if ok { return v, ok @@ -45,94 +73,112 @@ func (i *Interp) Var(name string) (Var, bool) { } return "", false } -func (i *Interp) SetVar(name, val string) { - i.callframe.vars[name] = Var(val) + +/* + * SetVariable sets a variable's value + */ +func (interp *Interpreter) SetVariable(name, val string) { + interp.callframe.vars[name] = Variable(val) } -func (i *Interp) UnsetVar(name string) { - delete(i.callframe.vars, name) +/* + * UnsetVariable removes a variable + */ +func (interp *Interpreter) UnsetVariable(name string) { + delete(interp.callframe.vars, name) } -func (i *Interp) Command(name string) *Cmd { - v, ok := i.commands[name] +/* + * Command retrieves a command + */ +func (interp *Interpreter) Command(name string) *Command { + v, ok := interp.commands[name] if !ok { return nil } return &v } -func (i *Interp) RegisterCommand(name string, fn CmdFunc, privdata interface{}) error { - c := i.Command(name) - if c != nil { +/* + * RegisterCommand registers a new command + */ +func (interp *Interpreter) RegisterCommand(name string, fn CommandFunc, privdata interface{}) error { + cmd := interp.Command(name) + if cmd != nil { return fmt.Errorf("Command '%s' already defined", name) } - i.commands[name] = Cmd{fn, privdata} + interp.commands[name] = Command{fn, privdata} return nil } -/* EVAL! */ -func (i *Interp) Eval(t string) (string, error) { - p := initParser(t) +/* + * Eval evaluates a script + */ +func (interp *Interpreter) Eval(script string) (string, error) { + parser := initParser(script) var result string var err error argv := []string{} for { - prevtype := p.Type - // XXX - t = p.GetToken() - if p.Type == ptEOF { + prevType := parser.Type + token := parser.GetToken() + if parser.Type == ptEOF { break } - switch p.Type { + switch parser.Type { case ptVAR: - v, ok := i.Var(t) + v, ok := interp.Variable(token) if !ok { - return "", fmt.Errorf("no such variable '%s'", t) + return "", fmt.Errorf("no such variable '%s'", token) } - t = string(v) + token = string(v) case ptCMD: - result, err = i.Eval(t) + result, err = interp.Eval(token) if err != nil { return result, err - } else { - t = result } + token = result case ptESC: - // XXX: escape handling missing! + /* + * TODO: escape handling missing! + */ case ptSEP: - prevtype = p.Type + prevType = parser.Type continue } - // We have a complete command + args. Call it! - if p.Type == ptEOL { - prevtype = p.Type + if parser.Type == ptEOL { + prevType = parser.Type if len(argv) != 0 { - c := i.Command(argv[0]) - if c == nil { + cmd := interp.Command(argv[0]) + if cmd == nil { return "", fmt.Errorf("no such command '%s'", argv[0]) } - result, err = c.fn(i, argv, c.privdata) + result, err = cmd.fn(interp, argv, cmd.privdata) if err != nil { return result, err } } - // Prepare for the next command + /* + * Prepare for the next command + */ argv = []string{} continue } - // We have a new token, append to the previous or as new arg? - if prevtype == ptSEP || prevtype == ptEOL { - argv = append(argv, t) + /* + * We have a new token, append to the previous or as new arg? + */ + if prevType == ptSEP || prevType == ptEOL { + argv = append(argv, token) } else { // Interpolation - argv[len(argv)-1] = strings.Join([]string{argv[len(argv)-1], t}, "") + argv[len(argv)-1] = strings.Join([]string{argv[len(argv)-1], token}, "") } - prevtype = p.Type + prevType = parser.Type } return result, nil } diff --git a/pkg/picol/picol_unused/main.go_unused b/pkg/picol/picol_unused/main.go_unused index 6860fdb..cc5fbbd 100644 --- a/pkg/picol/picol_unused/main.go_unused +++ b/pkg/picol/picol_unused/main.go_unused @@ -7,13 +7,13 @@ import ( "io/ioutil" "os" - picol "github.com/dragonheim/gagent/src/picol" + picol "github.com/dragonheim/gagent/pkg/picol" ) var fname = flag.String("f", "", "file name") // CommandPuts is a simple version of the TCL puts function. -func CommandPuts(i *picol.Interp, argv []string, pd interface{}) (string, error) { +func CommandPuts(i *picol.Interpreter, argv []string, pd interface{}) (string, error) { if len(argv) != 2 { return "", fmt.Errorf("wrong number of args for %s %s", argv[0], argv) } @@ -23,7 +23,7 @@ func CommandPuts(i *picol.Interp, argv []string, pd interface{}) (string, error) func main() { flag.Parse() - interp := picol.InitInterp() + interp := picol.NewInterpreter() interp.RegisterCoreCommands() interp.RegisterCommand("puts", CommandPuts, nil) From 1bcc682b7cdfe85468ce38819d1fbc354a5b573f Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 21 Mar 2023 07:34:10 -0700 Subject: [PATCH 43/80] refactor: converted int64 to int32 where appropriate. refactor: reduced usage of fmt in favor of logs and string concatication. refactor: minor re-ordering of the data structures to reduce storage space required. --- assets/docker/Dockerfile | 2 +- cmd/gagent/main.go | 4 +-- internal/gstructs/gstructs.go | 40 +++++++++++++-------------- internal/router/router.go | 5 ++-- internal/setup/setup.go | 12 ++++---- internal/worker/worker.go | 6 ++-- pkg/picol/commands.go | 5 ++-- pkg/picol/parser.go | 17 ++++++++++-- pkg/picol/picol_unused/main.go_unused | 10 ------- 9 files changed, 53 insertions(+), 48 deletions(-) diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index 1f6c1ba..a7a80cd 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,5 +1,5 @@ FROM nikatjef/golang:1.20 as builder -ARG SEMVER=${SEMVER:-0.0.7} +ARG SEMVER=${SEMVER:-0.0.8} WORKDIR /gagent COPY . . diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index b8a584d..5516a3a 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -56,7 +56,7 @@ var environment struct { * 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.6" +var semVER = "0.0.8" /* * This is the application configuration. It is populated from the configuration @@ -290,7 +290,7 @@ func init() { if config.MonitorPort != 0 { go func() { log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) - log.Fatal(http.ListenAndServe(string(config.ListenAddr)+strconv.FormatInt(config.MonitorPort, 10), nil)) + log.Fatal(http.ListenAndServe(string(config.ListenAddr)+strconv.Itoa(config.MonitorPort), nil)) }() } } diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 4f6a066..5db81d9 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -8,11 +8,11 @@ type GagentConfig struct { Mode string `hcl:"mode,attr"` UUID string `hcl:"uuid,optional"` ListenAddr string `hcl:"listenaddr,optional"` - MonitorPort int64 `hcl:"monitorport,optional"` - ClientPort int64 `hcl:"clientport,optional"` - RouterPort int64 `hcl:"routerport,optional"` - WorkerPort int64 `hcl:"workerport,optional"` ChainDBPath string `hcl:"chaindbpath,optional"` + MonitorPort int `hcl:"monitorport,optional"` + ClientPort int `hcl:"clientport,optional"` + RouterPort int `hcl:"routerport,optional"` + WorkerPort int `hcl:"workerport,optional"` Clients []*ClientDetails `hcl:"client,block"` Routers []*RouterDetails `hcl:"router,block"` Workers []*WorkerDetails `hcl:"worker,block"` @@ -62,27 +62,27 @@ type RouterDetails struct { */ RouterAddr string `hcl:"address,attr"` - /* - * G'Agent client will use this port to communicate with the routers. - */ - ClientPort int64 `hcl:"clientport,optional"` - - /* - * G'Agent router will use this port to communicate with other routers. - */ - RouterPort int64 `hcl:"routerport,optional"` - - /* - * G'Agent worker will use this port to communicate with the routers. - */ - WorkerPort int64 `hcl:"workerport,optional"` - /* * These tags will be passed to the router upon connection. The router * will then use these tags to help determine which worker / client to * send the client's requests and results to. */ RouterTags []string `hcl:"tags,optional"` + + /* + * G'Agent client will use this port to communicate with the routers. + */ + ClientPort int `hcl:"clientport,optional"` + + /* + * G'Agent router will use this port to communicate with other routers. + */ + RouterPort int `hcl:"routerport,optional"` + + /* + * G'Agent worker will use this port to communicate with the routers. + */ + WorkerPort int `hcl:"workerport,optional"` } /* @@ -111,8 +111,8 @@ type WorkerDetails struct { type AgentDetails struct { Client string `hcl:"client"` - Status int64 `hcl:"status"` Shasum string `hcl:"shasum"` + Status int `hcl:"status"` Hints []string ScriptCode []byte Answer []byte diff --git a/internal/router/router.go b/internal/router/router.go index 8f19480..dc91b3a 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -4,6 +4,7 @@ import ( fmt "fmt" log "log" http "net/http" + strconv "strconv" sync "sync" gcdb "github.com/dragonheim/gagent/internal/chaindb" @@ -44,7 +45,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { db.Init() - workerListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.WorkerPort) + workerListener := "tcp://" + config.ListenAddr + ":" + strconv.Itoa(config.WorkerPort) _ = workerSock.Bind(workerListener) workers := make([]string, 0) @@ -112,7 +113,7 @@ func createClientListener(wg *sync.WaitGroup, config gstructs.GagentConfig) { clientSock, _ := zmq.NewSocket(zmq.ROUTER) defer clientSock.Close() - clientListener := fmt.Sprintf("tcp://%s:%d", config.ListenAddr, config.ClientPort) + clientListener := "tcp://" + config.ListenAddr + ":" + strconv.Itoa(config.ClientPort) log.Printf("[DEBUG] Binding to: %s", clientListener) _ = clientSock.Bind(clientListener) diff --git a/internal/setup/setup.go b/internal/setup/setup.go index 4350dc1..4672501 100644 --- a/internal/setup/setup.go +++ b/internal/setup/setup.go @@ -24,9 +24,9 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { rootBody.SetAttributeValue("mode", cty.StringVal(config.Mode)) rootBody.SetAttributeValue("uuid", cty.StringVal(config.UUID)) rootBody.SetAttributeValue("listenaddr", cty.StringVal("0.0.0.0")) - rootBody.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort)) - rootBody.SetAttributeValue("routerport", cty.NumberIntVal(config.RouterPort)) - rootBody.SetAttributeValue("workerport", cty.NumberIntVal(config.WorkerPort)) + rootBody.SetAttributeValue("clientport", cty.NumberIntVal(int64(config.ClientPort))) + rootBody.SetAttributeValue("routerport", cty.NumberIntVal(int64(config.RouterPort))) + rootBody.SetAttributeValue("workerport", cty.NumberIntVal(int64(config.WorkerPort))) rootBody.AppendNewline() clientBlock1 := rootBody.AppendNewBlock("client", []string{config.Name}) @@ -47,9 +47,9 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { routerBody1 := routerBlock1.Body() routerBody1.SetAttributeValue("routerid", cty.StringVal(config.UUID)) routerBody1.SetAttributeValue("address", cty.StringVal("127.0.0.1")) - routerBody1.SetAttributeValue("clientport", cty.NumberIntVal(config.ClientPort)) - routerBody1.SetAttributeValue("routerport", cty.NumberIntVal(config.RouterPort)) - routerBody1.SetAttributeValue("workerport", cty.NumberIntVal(config.WorkerPort)) + routerBody1.SetAttributeValue("clientport", cty.NumberIntVal(int64(config.ClientPort))) + routerBody1.SetAttributeValue("routerport", cty.NumberIntVal(int64(config.RouterPort))) + routerBody1.SetAttributeValue("workerport", cty.NumberIntVal(int64(config.WorkerPort))) rootBody.AppendNewline() workerBlock1 := rootBody.AppendNewBlock("worker", []string{config.Name}) diff --git a/internal/worker/worker.go b/internal/worker/worker.go index b13a53c..3ff1b7b 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -8,7 +8,7 @@ import ( gstructs "github.com/dragonheim/gagent/internal/gstructs" /* - * picol "github.com/dragonheim/gagent/src/picol" + * picol "github.com/dragonheim/gagent/pkg/picol" */ prometheus "github.com/prometheus/client_golang/prometheus" @@ -43,13 +43,13 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { /* * Generate connect string for this router. */ - connectString := "tcp://" + config.Routers[key].RouterAddr + ":" + strconv.FormatInt(rport, 10) + connectString := "tcp://" + config.Routers[key].RouterAddr + ":" + strconv.Itoa(rport) wg.Add(1) go getAgent(wg, config.UUID, connectString) } /* - * workerListener := "tcp://" + config.ListenAddr + ":" + strconv.FormatInt(config.WorkerPort, 10) + * workerListener := "tcp://" + config.ListenAddr + ":" + strconv.Itoa(config.WorkerPort) */ } diff --git a/pkg/picol/commands.go b/pkg/picol/commands.go index 0729f96..a1b8d7a 100644 --- a/pkg/picol/commands.go +++ b/pkg/picol/commands.go @@ -1,6 +1,7 @@ package picol import ( + "errors" "fmt" "strconv" "strings" @@ -92,8 +93,8 @@ func CommandMath(i *Interpreter, argv []string, pd interface{}) (string, error) if a != b { c = 1 } - default: // FIXME I hate warnings - c = 0 + default: + return "0", errors.New("invalid operator " + argv[0]) } return fmt.Sprintf("%d", c), nil } diff --git a/pkg/picol/parser.go b/pkg/picol/parser.go index 65d9003..e2cbb8b 100644 --- a/pkg/picol/parser.go +++ b/pkg/picol/parser.go @@ -5,6 +5,7 @@ import ( "unicode/utf8" ) +// Define parser token types const ( ptESC = iota ptSTR @@ -15,6 +16,7 @@ const ( ptEOF ) +// parserStruct represents the parser state type parserStruct struct { text string p, start, end, ln int @@ -22,26 +24,31 @@ type parserStruct struct { Type int } +// initParser initializes a new parserStruct instance func initParser(text string) *parserStruct { - return &parserStruct{text, 0, 0, 0, len(text), 0, ptEOL} + return &parserStruct{text: text, ln: len(text), Type: ptEOL} } +// next advances the parser position by one rune func (p *parserStruct) next() { _, w := utf8.DecodeRuneInString(p.text[p.p:]) p.p += w p.ln -= w } +// current returns the current rune at the parser position func (p *parserStruct) current() rune { r, _ := utf8.DecodeRuneInString(p.text[p.p:]) return r } +// token returns the current token text between start and end positions func (p *parserStruct) token() (t string) { defer recover() return p.text[p.start:p.end] } +// parseSep parses whitespace separators func (p *parserStruct) parseSep() string { p.start = p.p for ; p.p < len(p.text); p.next() { @@ -54,6 +61,7 @@ func (p *parserStruct) parseSep() string { return p.token() } +// parseEol parses end of line and comments func (p *parserStruct) parseEol() string { p.start = p.p @@ -70,6 +78,7 @@ func (p *parserStruct) parseEol() string { return p.token() } +// parseCommand parses a command within brackets func (p *parserStruct) parseCommand() string { level, blevel := 1, 0 p.next() // skip @@ -103,6 +112,7 @@ Loop: return p.token() } +// parseVar parses a variable reference func (p *parserStruct) parseVar() string { p.next() // skip the $ p.start = p.p @@ -132,6 +142,7 @@ func (p *parserStruct) parseVar() string { return p.token() } +// parseBrace parses a brace-enclosed string func (p *parserStruct) parseBrace() string { level := 1 p.next() // skip @@ -160,6 +171,7 @@ Loop: return p.token() } +// parseString parses a string with or without quotes func (p *parserStruct) parseString() string { newword := p.Type == ptSEP || p.Type == ptEOL || p.Type == ptSTR @@ -203,6 +215,7 @@ Loop: return p.token() } +// parseComment skips over comment text func (p *parserStruct) parseComment() string { for p.ln != 0 && p.current() != '\n' { p.next() @@ -210,6 +223,7 @@ func (p *parserStruct) parseComment() string { return p.token() } +// GetToken returns the next token from the parser func (p *parserStruct) GetToken() string { for { if p.ln == 0 { @@ -246,5 +260,4 @@ func (p *parserStruct) GetToken() string { return p.parseString() } } - /* return p.token() /* unreached */ } diff --git a/pkg/picol/picol_unused/main.go_unused b/pkg/picol/picol_unused/main.go_unused index cc5fbbd..c1fb8fa 100644 --- a/pkg/picol/picol_unused/main.go_unused +++ b/pkg/picol/picol_unused/main.go_unused @@ -12,20 +12,10 @@ import ( var fname = flag.String("f", "", "file name") -// CommandPuts is a simple version of the TCL puts function. -func CommandPuts(i *picol.Interpreter, argv []string, pd interface{}) (string, error) { - if len(argv) != 2 { - return "", fmt.Errorf("wrong number of args for %s %s", argv[0], argv) - } - fmt.Println(argv[1]) - return "", nil -} - func main() { flag.Parse() interp := picol.NewInterpreter() interp.RegisterCoreCommands() - interp.RegisterCommand("puts", CommandPuts, nil) buf, err := ioutil.ReadFile(*fname) if err == nil { From d5fcd115924d4518d4b2557cb98399fb936183e4 Mon Sep 17 00:00:00 2001 From: James Wells Date: Wed, 22 Mar 2023 17:37:11 -0700 Subject: [PATCH 44/80] refactor: refactored the chainDB and added write capability. --- internal/chaindb/chaindb.go | 79 ++++++++++++++++++++++++++----------- internal/router/router.go | 7 +++- 2 files changed, 62 insertions(+), 24 deletions(-) diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go index 54c1712..1941770 100644 --- a/internal/chaindb/chaindb.go +++ b/internal/chaindb/chaindb.go @@ -1,68 +1,101 @@ package chaindb import ( - sha "crypto/sha256" + sha256 "crypto/sha256" fmt "fmt" + ioutil "io/ioutil" log "log" time "time" gstructs "github.com/dragonheim/gagent/internal/gstructs" + cty "github.com/zclconf/go-cty/cty" hclsimple "github.com/hashicorp/hcl/v2/hclsimple" - /* - * hclwrite "github.com/hashicorp/hcl/v2/hclwrite" - */) + hclwrite "github.com/hashicorp/hcl/v2/hclwrite" +) type GagentDb struct { - chainRow []*gagentDbRow `hcl:"timestamp,block"` + ChainRow []*GagentDbRow `hcl:"timestamp,block"` } -type gagentDbRow struct { - timestamp time.Time `hcl:"timestamp"` +type GagentDbRow struct { + Timestamp time.Time `hcl:"timestamp"` DBName string `hcl:"chainid,optional"` Agent gstructs.AgentDetails `hcl:"agent,block"` - dbCurrHash [32]byte `hcl:"currhash"` - dbPrevHash [32]byte `hcl:"prevhash"` + DbCurrHash [32]byte `hcl:"currhash"` + DbPrevHash [32]byte `hcl:"prevhash"` } /* * Initialize the database */ -func (db *GagentDb) Init() { - db.chainRow = make([]*gagentDbRow, 0) +func NewGagentDb() *GagentDb { + return &GagentDb{ + ChainRow: make([]*GagentDbRow, 0), + } } /* * Load the database from disk */ -func (db *GagentDb) Load() error { - err := hclsimple.DecodeFile("chaindb.hcl", nil, &db) +func (db *GagentDb) LoadHCL() error { + err := hclsimple.DecodeFile("chaindb.hcl", nil, db) + if err != nil { + return err + } log.Printf("[DEBUG] DB values: %v\n", db) - return err + return nil +} + +/* + * Write the database to an HCL file + */ +func (db *GagentDb) WriteHCL() error { + f := hclwrite.NewEmptyFile() + rootBody := f.Body() + + for _, row := range db.ChainRow { + rowBlock := rootBody.AppendNewBlock("row", []string{}) + rowBody := rowBlock.Body() + + rowBody.SetAttributeValue("timestamp", cty.StringVal(row.Timestamp.Format(time.RFC3339))) + rowBody.SetAttributeValue("chainid", cty.StringVal(row.DBName)) + rowBody.SetAttributeValue("currhash", cty.StringVal(fmt.Sprintf("%x", row.DbCurrHash))) + rowBody.SetAttributeValue("prevhash", cty.StringVal(fmt.Sprintf("%x", row.DbPrevHash))) + + agentBlock := rowBody.AppendNewBlock("agent", []string{}) + agentBody := agentBlock.Body() + agentBody.SetAttributeValue("name", cty.StringVal(row.Agent.Client)) + agentBody.SetAttributeValue("version", cty.StringVal(row.Agent.Shasum)) + } + + return ioutil.WriteFile("chaindb_out.hcl", f.Bytes(), 0644) } /* * Add a new row to the chaindb */ -func (db *GagentDb) AddRow(row *gagentDbRow) error { - row.timestamp = time.Now() - db.chainRow = append(db.chainRow, row) - - return nil +func (db *GagentDb) AddRow(row *GagentDbRow) { + row.Timestamp = time.Now() + db.ChainRow = append(db.ChainRow, row) + db.SetCurrHash() + db.SetPrevHash() } /* * Set current hash of the database */ func (db *GagentDb) SetCurrHash() { - db.chainRow[len(db.chainRow)-1].dbCurrHash = [32]byte{} - foo := sha.Sum256([]byte(fmt.Sprintf("%v", db))) - db.chainRow[len(db.chainRow)-1].dbCurrHash = foo + row := db.ChainRow[len(db.ChainRow)-1] + row.DbCurrHash = sha256.Sum256([]byte(fmt.Sprintf("%v", db))) } /* * Set previous hash of the database */ func (db *GagentDb) SetPrevHash() { - db.chainRow[len(db.chainRow)-1].dbPrevHash = db.chainRow[len(db.chainRow)-1].dbCurrHash + row := db.ChainRow[len(db.ChainRow)-1] + if len(db.ChainRow) > 1 { + row.DbPrevHash = db.ChainRow[len(db.ChainRow)-2].DbCurrHash + } } diff --git a/internal/router/router.go b/internal/router/router.go index dc91b3a..991418e 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -43,7 +43,12 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { workerSock, _ := zmq.NewSocket(zmq.DEALER) defer workerSock.Close() - db.Init() + chain := gcdb.NewGagentDb() + log.Println("[DEBUG] Loading chaindb ") + err := chain.LoadHCL() + if err != nil { + log.Printf("[ERROR] Error loading chaindb: %s", err) + } workerListener := "tcp://" + config.ListenAddr + ":" + strconv.Itoa(config.WorkerPort) _ = workerSock.Bind(workerListener) From 7a9225ce860f513cb6edc9ac2701a12ce833dabd Mon Sep 17 00:00:00 2001 From: James Wells Date: Wed, 22 Mar 2023 19:20:16 -0700 Subject: [PATCH 45/80] Adding support for a genesis DB. --- assets/examples/{ => agents}/add-two.tcl | 0 assets/examples/agents/fib.tcl | 13 +++++++++++++ assets/examples/{ => agents}/hello-earth.tcl | 0 assets/examples/agents/t2.tcl | 18 ++++++++++++++++++ cmd/gagent/main.go | 2 +- internal/chaindb/chaindb.go | 4 ++-- internal/router/router.go | 2 +- 7 files changed, 35 insertions(+), 4 deletions(-) rename assets/examples/{ => agents}/add-two.tcl (100%) create mode 100644 assets/examples/agents/fib.tcl rename assets/examples/{ => agents}/hello-earth.tcl (100%) create mode 100644 assets/examples/agents/t2.tcl diff --git a/assets/examples/add-two.tcl b/assets/examples/agents/add-two.tcl similarity index 100% rename from assets/examples/add-two.tcl rename to assets/examples/agents/add-two.tcl diff --git a/assets/examples/agents/fib.tcl b/assets/examples/agents/fib.tcl new file mode 100644 index 0000000..8696b16 --- /dev/null +++ b/assets/examples/agents/fib.tcl @@ -0,0 +1,13 @@ +########################################## +### Perform Fibanaci sequence up to 10 ### +########################################## +set GHINT [split "math, fib" ,] +proc fib {x} { + if {<= $x 1} { + return 1 + } else { + + [fib [- $x 1]] [fib [- $x 2]] + } +} + +puts [fib 20] \ No newline at end of file diff --git a/assets/examples/hello-earth.tcl b/assets/examples/agents/hello-earth.tcl similarity index 100% rename from assets/examples/hello-earth.tcl rename to assets/examples/agents/hello-earth.tcl diff --git a/assets/examples/agents/t2.tcl b/assets/examples/agents/t2.tcl new file mode 100644 index 0000000..44b1533 --- /dev/null +++ b/assets/examples/agents/t2.tcl @@ -0,0 +1,18 @@ +########################################### +### Square numbers in sequence up to 10 ### +########################################### +set GHINT [split "math, square" ,] +proc square {x} { + * $x $x +} + +set a 1 +while {<= $a 10} { + if {== $a 5} { + puts {Missing five!} + set a [+ $a 1] + continue + } + puts "I can compute that $a*$a = [square $a]" + set a [+ $a 1] +} \ No newline at end of file diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 5516a3a..2101ab8 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -290,7 +290,7 @@ func init() { if config.MonitorPort != 0 { go func() { log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) - log.Fatal(http.ListenAndServe(string(config.ListenAddr)+strconv.Itoa(config.MonitorPort), nil)) + log.Fatal(http.ListenAndServe(string(config.ListenAddr)+":"+strconv.Itoa(config.MonitorPort), nil)) }() } } diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go index 1941770..4b98516 100644 --- a/internal/chaindb/chaindb.go +++ b/internal/chaindb/chaindb.go @@ -38,8 +38,8 @@ func NewGagentDb() *GagentDb { /* * Load the database from disk */ -func (db *GagentDb) LoadHCL() error { - err := hclsimple.DecodeFile("chaindb.hcl", nil, db) +func (db *GagentDb) LoadHCL(ChainDBPath string) error { + err := hclsimple.DecodeFile(ChainDBPath, nil, db) if err != nil { return err } diff --git a/internal/router/router.go b/internal/router/router.go index 991418e..906f831 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -45,7 +45,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { chain := gcdb.NewGagentDb() log.Println("[DEBUG] Loading chaindb ") - err := chain.LoadHCL() + err := chain.LoadHCL(config.ChainDBPath) if err != nil { log.Printf("[ERROR] Error loading chaindb: %s", err) } From db351f3892468c8e8e445d3fef64bcf6bbe802fe Mon Sep 17 00:00:00 2001 From: James Wells Date: Sat, 25 Mar 2023 09:15:27 -0700 Subject: [PATCH 46/80] fix: was using struct member for two different things. --- assets/docker/Dockerfile | 4 ++-- cmd/gagent/main.go | 22 +++++++++++----------- internal/client/client.go | 7 ++++--- internal/gstructs/gstructs.go | 1 + internal/router/router.go | 8 -------- 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index a7a80cd..f652599 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,5 +1,5 @@ -FROM nikatjef/golang:1.20 as builder -ARG SEMVER=${SEMVER:-0.0.8} +FROM dragonheim/golang:1.20 as builder +ARG SEMVER=${SEMVER:-0.0.9} WORKDIR /gagent COPY . . diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 2101ab8..52cfc5a 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -4,7 +4,6 @@ import ( log "log" http "net/http" os "os" - strconv "strconv" sync "sync" autorestart "github.com/slayer/autorestart" @@ -56,7 +55,7 @@ var environment struct { * 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.8" +var semVER = "0.0.9" /* * This is the application configuration. It is populated from the configuration @@ -131,8 +130,6 @@ func main() { * reads the environment variables. It also sets up the logging. */ func init() { - autorestart.StartWatcher() - cfg := environment if err := env.Parse(&cfg); err != nil { log.Printf("%+v\n", err) @@ -261,7 +258,7 @@ func init() { log.Printf("[ERROR] Agent file not specified") os.Exit(8) } else { - config.File = opts["--agent"].(string) + config.Agent = opts["--agent"].(string) } if opts["pull"] == true { @@ -287,10 +284,13 @@ func init() { /* * Start Prometheus metrics exporter */ - if config.MonitorPort != 0 { - go func() { - log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) - log.Fatal(http.ListenAndServe(string(config.ListenAddr)+":"+strconv.Itoa(config.MonitorPort), nil)) - }() - } + // if config.MonitorPort != 0 { + // go func() { + // log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) + // log.Fatal(http.ListenAndServe(string(config.ListenAddr)+":"+strconv.Itoa(config.MonitorPort), nil)) + // }() + // } + autorestart.WatchFilename = config.File + autorestart.StartWatcher() + } diff --git a/internal/client/client.go b/internal/client/client.go index 413eb93..3f894ca 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -8,6 +8,7 @@ import ( log "log" os "os" regexp "regexp" + strconv "strconv" strings "strings" sync "sync" time "time" @@ -33,9 +34,9 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { var err error if config.CMode { - agent.ScriptCode, err = ioutil.ReadFile(config.File) + agent.ScriptCode, err = ioutil.ReadFile(config.Agent) if err != nil { - log.Printf("[ERROR] No such file or directory: %s", config.File) + log.Printf("[ERROR] No such file or directory: %s", config.Agent) os.Exit(4) } log.Printf("[DEBUG] Agent file contents: \n----- -----\n%s\n----- -----\n", agent.ScriptCode) @@ -56,7 +57,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { if config.Routers[key].ClientPort != 0 { rport = config.Routers[key].ClientPort } - connectString := fmt.Sprintf("tcp://%s:%d", config.Routers[key].RouterAddr, rport) + connectString := "tcp://" + config.Routers[key].RouterAddr + ":" + strconv.Itoa(rport) wg.Add(1) go sendAgent(wg, config.UUID, connectString, agent) diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 5db81d9..851c93c 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -18,6 +18,7 @@ type GagentConfig struct { Workers []*WorkerDetails `hcl:"worker,block"` Version string File string + Agent string CMode bool } diff --git a/internal/router/router.go b/internal/router/router.go index 906f831..b2eca6c 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -10,17 +10,10 @@ import ( gcdb "github.com/dragonheim/gagent/internal/chaindb" gstructs "github.com/dragonheim/gagent/internal/gstructs" - prometheus "github.com/prometheus/client_golang/prometheus" - promauto "github.com/prometheus/client_golang/prometheus/promauto" - zmq "github.com/pebbe/zmq4" ) var ( - opsProcessed = promauto.NewCounter(prometheus.CounterOpts{ - Name: "client_requests_received", - }) - db gcdb.GagentDb ) @@ -144,7 +137,6 @@ func unwrap(msg []string) (head string, tail []string) { func answerClient(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { - opsProcessed.Inc() /* * fmt.Fprintf(w, "%v\n", r) */ From 13d18d771460ad1566d7d3a12662345fa609149b Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 28 Mar 2023 09:55:51 -0700 Subject: [PATCH 47/80] fix: fixing a security issue in chaindb. fix: re-enabled dragonheim, since Docker decided not to remove it. --- .devcontainer/devcontainer.json | 4 ++-- internal/chaindb/chaindb.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2b009a7..fb4ed8a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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.20-bullseye", + "VARIANT": "1.20-bullseye", // Options "NODE_VERSION": "none" } diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go index 4b98516..3cb3721 100644 --- a/internal/chaindb/chaindb.go +++ b/internal/chaindb/chaindb.go @@ -69,7 +69,7 @@ func (db *GagentDb) WriteHCL() error { agentBody.SetAttributeValue("version", cty.StringVal(row.Agent.Shasum)) } - return ioutil.WriteFile("chaindb_out.hcl", f.Bytes(), 0644) + return ioutil.WriteFile("chaindb_out.hcl", f.Bytes(), 0600) } /* From 2b0975b30ab651afbc6c08bcb2c491548c40c617 Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 28 Mar 2023 13:23:09 -0700 Subject: [PATCH 48/80] fix: changed db destination to programatic instead of hardcoded. fix: minor cleanup. feat: cleaned up agent hint collection. --- internal/chaindb/chaindb.go | 4 ++-- internal/client/client.go | 14 +++++++++++--- internal/router/router.go | 7 +++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go index 3cb3721..1782c79 100644 --- a/internal/chaindb/chaindb.go +++ b/internal/chaindb/chaindb.go @@ -50,7 +50,7 @@ func (db *GagentDb) LoadHCL(ChainDBPath string) error { /* * Write the database to an HCL file */ -func (db *GagentDb) WriteHCL() error { +func (db *GagentDb) WriteHCL(ChainDBPath string) error { f := hclwrite.NewEmptyFile() rootBody := f.Body() @@ -69,7 +69,7 @@ func (db *GagentDb) WriteHCL() error { agentBody.SetAttributeValue("version", cty.StringVal(row.Agent.Shasum)) } - return ioutil.WriteFile("chaindb_out.hcl", f.Bytes(), 0600) + return ioutil.WriteFile(ChainDBPath, f.Bytes(), 0600) } /* diff --git a/internal/client/client.go b/internal/client/client.go index 3f894ca..3985de6 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -69,13 +69,21 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { */ func getTagsFromHints(agent gstructs.AgentDetails) []string { var tags []string - re := regexp.MustCompile(`\s*set\s+GHINT\s*\[\s*split\s*"(?P.+)"\s*\,\s*\]`) + + // Use named capture groups to extract the hints + re := regexp.MustCompile(`^*set\s+GHINT\s*\[\s*split\s*"(?P[^"]+)"\s*,\s*\]`) res := re.FindStringSubmatch(string(agent.ScriptCode)) - if len(res) < 1 { + + // If we don't have at least 2 matches, we have no hints + if len(res) < 2 { log.Printf("[ERROR] Agent is missing GHINT tags") os.Exit(4) } - tags = strings.Split(res[1], ",") + + // Use named capturing group index + hintsIndex := re.SubexpIndex("Hints") + tags = strings.Split(res[hintsIndex], ",") + log.Printf("[DEBUG] G'Agent hints: %v\n", tags) return tags diff --git a/internal/router/router.go b/internal/router/router.go index b2eca6c..80f2a30 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -122,7 +122,6 @@ func createClientListener(wg *sync.WaitGroup, config gstructs.GagentConfig) { } log.Printf("[DEBUG] Client message received: %s", msg) } - } func unwrap(msg []string) (head string, tail []string) { @@ -137,9 +136,6 @@ func unwrap(msg []string) (head string, tail []string) { func answerClient(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { - /* - * fmt.Fprintf(w, "%v\n", r) - */ http.NotFound(w, r) return } @@ -152,18 +148,21 @@ func answerClient(w http.ResponseWriter, r *http.Request) { * Handle GET requests */ case http.MethodGet: + log.Println("[DEBUG] GET method received") fmt.Fprintf(w, "%v\n", r) /* * Handle POST requests */ case http.MethodPost: + log.Println("[DEBUG] POST method received") fmt.Fprintf(w, "%v\n", r) /* * Handle PUT requests */ case http.MethodOptions: + log.Println("[DEBUG] PUT method received") w.Header().Set("Allow", "GET, POST, OPTIONS") w.WriteHeader(http.StatusNoContent) From 8077c66fc96b7a6ffbe1e01a2de4e25013f6d44a Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 30 Mar 2023 17:39:04 -0700 Subject: [PATCH 49/80] feat: make environment variables useful. fix: made config file an environment variable. fix: reordered and renamed part of the Agent structure. --- assets/examples/gagent.hcl | 2 +- cmd/gagent/main.go | 39 +++++++++++++++++++++++------------ internal/client/client.go | 9 ++++---- internal/gstructs/gstructs.go | 12 +++++------ internal/router/router.go | 15 +++++++++++--- 5 files changed, 50 insertions(+), 27 deletions(-) diff --git a/assets/examples/gagent.hcl b/assets/examples/gagent.hcl index bf201e4..b1fce4d 100644 --- a/assets/examples/gagent.hcl +++ b/assets/examples/gagent.hcl @@ -49,7 +49,7 @@ mode = "router" /* * This is the port to G'Agent will listen for on - * for Prometheus queries. It defaults to 9101. + * for Prometheus queries. Can be overriden by MONITOR_PORT environment variable * Monitoring will be disabled if this is set to 0. * * Optional. diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 52cfc5a..350dbb9 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -4,6 +4,7 @@ import ( log "log" http "net/http" os "os" + strconv "strconv" sync "sync" autorestart "github.com/slayer/autorestart" @@ -46,9 +47,9 @@ import ( */ var environment struct { - Mode string `env:"GAGENT_MODE" envDefault:"setup"` - Port int `env:"PORT" envDefault:"3000"` - UUID string `env:"GAGENT_UUID" envDefault:""` + ConfigFile string `env:"GAGENT_CONFIG" envDefault:"/etc/gagent/gagent.hcl"` + Mode string `env:"GAGENT_MODE" envDefault:"setup"` + MonitorPort int `env:"MONITOR_PORT" envDefault:"0"` } /* @@ -151,7 +152,7 @@ func init() { */ config.Version = semVER - config.File = "/etc/gagent/gagent.hcl" + config.File = cfg.ConfigFile config.Mode = "setup" @@ -173,7 +174,7 @@ func init() { * G'Agent will use this port for monitoring via prometheus., If set * is set to 0, G'Agent will not listen for prometheus metrics. */ - config.MonitorPort = 9101 + config.MonitorPort = cfg.MonitorPort /* * G'Agent client will use this port to communicate with the routers. @@ -229,6 +230,20 @@ func init() { usage += " --agent= -- filename of the agent to be uploaded to the G'Agent network. Required in push mode\n" usage += "\n" + usage += "Environment Variables:\n" + usage += " GAGENT_CONFIG -- [default: /etc/gagent/gagent.hcl]\n" + usage += " GAGENT_MONITOR -- [default: 0]\n" + usage += " MODE -- [default: setup]\n" + usage += "\n" + + usage += "Examples:\n" + usage += " gagent client pull --config=/etc/gagent/gagent.hcl\n" + usage += " gagent client push --config=/etc/gagent/gagent.hcl --agent=/tmp/agent.tcl\n" + usage += " gagent router --config=/etc/gagent/gagent.hcl\n" + usage += " gagent worker --config=/etc/gagent/gagent.hcl\n" + usage += " gagent setup --config=/etc/gagent/gagent.hcl\n" + usage += "\n" + /* * Consume the usage variable and the command line arguments to create a * dictionary / map. @@ -279,17 +294,15 @@ func init() { } } - log.Printf("[DEBUG] Config is %v\n", config) - /* * Start Prometheus metrics exporter */ - // if config.MonitorPort != 0 { - // go func() { - // log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) - // log.Fatal(http.ListenAndServe(string(config.ListenAddr)+":"+strconv.Itoa(config.MonitorPort), nil)) - // }() - // } + if config.MonitorPort != 0 { + go func() { + log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) + log.Fatal(http.ListenAndServe(string(config.ListenAddr)+":"+strconv.Itoa(config.MonitorPort), nil)) + }() + } autorestart.WatchFilename = config.File autorestart.StartWatcher() diff --git a/internal/client/client.go b/internal/client/client.go index 3985de6..d679b6d 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -34,15 +34,15 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { var err error if config.CMode { - agent.ScriptCode, err = ioutil.ReadFile(config.Agent) + agent.Script, err = ioutil.ReadFile(config.Agent) if err != nil { log.Printf("[ERROR] No such file or directory: %s", config.Agent) os.Exit(4) } - log.Printf("[DEBUG] Agent file contents: \n----- -----\n%s\n----- -----\n", agent.ScriptCode) + log.Printf("[DEBUG] Agent file contents: \n----- -----\n%s\n----- -----\n", agent.Script) } agent.Client = config.UUID - tmpsum := sha.Sum256([]byte(agent.ScriptCode)) + tmpsum := sha.Sum256([]byte(agent.Script)) agent.Shasum = fmt.Sprintf("%v", hex.EncodeToString(tmpsum[:])) log.Printf("[INFO] SHA256 of Agent file: %s", agent.Shasum) agent.Status = 1 @@ -72,7 +72,7 @@ func getTagsFromHints(agent gstructs.AgentDetails) []string { // Use named capture groups to extract the hints re := regexp.MustCompile(`^*set\s+GHINT\s*\[\s*split\s*"(?P[^"]+)"\s*,\s*\]`) - res := re.FindStringSubmatch(string(agent.ScriptCode)) + res := re.FindStringSubmatch(string(agent.Script)) // If we don't have at least 2 matches, we have no hints if len(res) < 2 { @@ -108,6 +108,7 @@ func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent gstr } log.Printf("[DEBUG] Start sending agent...\n") + agent.Status = 2 status, err := sock.SendMessage(agent) if err != nil { log.Printf("[ERROR] Failed to send agent to router\n") diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 851c93c..9d2917f 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -111,10 +111,10 @@ type WorkerDetails struct { } type AgentDetails struct { - Client string `hcl:"client"` - Shasum string `hcl:"shasum"` - Status int `hcl:"status"` - Hints []string - ScriptCode []byte - Answer []byte + Status byte `hcl:"status"` + Client string `hcl:"client"` + Shasum string `hcl:"shasum"` + Hints []string + Script []byte + Answer []byte } diff --git a/internal/router/router.go b/internal/router/router.go index 80f2a30..b961256 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -105,15 +105,23 @@ LOOP: /* * Create listener for client requests */ -func createClientListener(wg *sync.WaitGroup, config gstructs.GagentConfig) { +func createClientListener(wg *sync.WaitGroup, config gstructs.GagentConfig) error { defer wg.Done() - clientSock, _ := zmq.NewSocket(zmq.ROUTER) + clientSock, err := zmq.NewSocket(zmq.ROUTER) + if err != nil { + log.Printf("[ERROR] Error creating client socket: %s", err) + return err + } defer clientSock.Close() clientListener := "tcp://" + config.ListenAddr + ":" + strconv.Itoa(config.ClientPort) log.Printf("[DEBUG] Binding to: %s", clientListener) - _ = clientSock.Bind(clientListener) + err = clientSock.Bind(clientListener) + if err != nil { + log.Printf("[ERROR] Error binding client socket: %s", err) + return err + } for { msg, err := clientSock.RecvMessage(0) @@ -122,6 +130,7 @@ func createClientListener(wg *sync.WaitGroup, config gstructs.GagentConfig) { } log.Printf("[DEBUG] Client message received: %s", msg) } + return nil } func unwrap(msg []string) (head string, tail []string) { From c5f2cb534bfbed8442266a2a92592147a644c9c8 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 31 Mar 2023 07:06:28 -0700 Subject: [PATCH 50/80] fix: somehow I list the license, re-adding. --- pkg/picol/LICENSE.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pkg/picol/LICENSE.md diff --git a/pkg/picol/LICENSE.md b/pkg/picol/LICENSE.md new file mode 100644 index 0000000..92c0253 --- /dev/null +++ b/pkg/picol/LICENSE.md @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 Lain dono + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file From 7d5c02d16b87d2342e89e461f3a83d7d8a576ac6 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 31 Mar 2023 07:07:24 -0700 Subject: [PATCH 51/80] fix: removing build status as the build servers no longer exist. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index c4a8d13..e849733 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Maintained Status](https://img.shields.io/maintenance/yes/2023?style=plastic)](https://github.com/dragonheim/gagent) [![License](https://img.shields.io/badge/License-MIT-limegreen.svg)](https://github.com/dragonheim/gagent/src/branch/main/LICENSE) -[![Build Status](https://drone.dragonheim.net/api/badges/dragonheim/gagent/status.svg)](https://drone.dragonheim.net/dragonheim/gagent) [![Go Report Card](https://goreportcard.com/badge/github.com/dragonheim/gagent)](https://goreportcard.com/report/github.com/dragonheim/gagent) [![Docker Pulls](https://img.shields.io/docker/pulls/dragonheim/gagent)](https://hub.docker.com/r/dragonheim/gagent/tags?page=1&ordering=last_updated) From ac8c225752b81e2fe00edc61ed292a84dad22da4 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 31 Mar 2023 07:07:57 -0700 Subject: [PATCH 52/80] fix: commenting out some ineffective assignments. --- pkg/picol/picol.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/picol/picol.go b/pkg/picol/picol.go index 10a068b..5b53ecb 100644 --- a/pkg/picol/picol.go +++ b/pkg/picol/picol.go @@ -147,12 +147,12 @@ func (interp *Interpreter) Eval(script string) (string, error) { * TODO: escape handling missing! */ case ptSEP: - prevType = parser.Type + // prevType = parser.Type continue } if parser.Type == ptEOL { - prevType = parser.Type + // prevType = parser.Type if len(argv) != 0 { cmd := interp.Command(argv[0]) if cmd == nil { @@ -178,7 +178,7 @@ func (interp *Interpreter) Eval(script string) (string, error) { } else { // Interpolation argv[len(argv)-1] = strings.Join([]string{argv[len(argv)-1], token}, "") } - prevType = parser.Type + // prevType = parser.Type } return result, nil } From 7f9a5777bd32a07fe146b6bf5e68313b654485a4 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 3 Apr 2023 18:39:01 -0700 Subject: [PATCH 53/80] feat: Adding very preliminar and broken test harness. --- assets/examples/genesis.json | 9 +- cmd/gagent/main.go | 3 +- cmd/gagent/main_test.go | 71 ++++++++++++ go.mod | 3 + go.sum | 9 ++ internal/chaindb/chaindb_test.go | 65 +++++++++++ internal/client/client_test.go | 152 +++++++++++++++++++++++++ internal/gstructs/agent_status.go | 35 ++++++ internal/gstructs/agent_status_test.go | 59 ++++++++++ internal/gstructs/gstructs.go | 12 +- internal/gstructs/gstructs_test.go | 76 +++++++++++++ internal/router/router_test.go | 72 ++++++++++++ internal/setup/setup_test.go | 57 ++++++++++ internal/worker/worker_test.go | 65 +++++++++++ 14 files changed, 678 insertions(+), 10 deletions(-) create mode 100644 cmd/gagent/main_test.go create mode 100644 internal/chaindb/chaindb_test.go create mode 100644 internal/client/client_test.go create mode 100644 internal/gstructs/agent_status.go create mode 100644 internal/gstructs/agent_status_test.go create mode 100644 internal/gstructs/gstructs_test.go create mode 100644 internal/router/router_test.go create mode 100644 internal/setup/setup_test.go create mode 100644 internal/worker/worker_test.go diff --git a/assets/examples/genesis.json b/assets/examples/genesis.json index 797ef6b..32b325b 100644 --- a/assets/examples/genesis.json +++ b/assets/examples/genesis.json @@ -1,13 +1,16 @@ { - "genesis_time": "2021-10-25:00:00.000000000Z", + "timestamp": "2021-10-25:00:00.000000000Z", "chainid": "gagent_ledger", "agent": { + "status": "complete", "client": "7e9d13fe-5151-5876-66c0-20ca03e8fca4", "shasum": "a76f7c3c7bc0f94b4f8aa63c605f8534db5675bb05d761f4461127fcadbf32d4", - "status": "complete" + "hints": {}, + "script": "", + "answer": "" }, "clients": { - "client": "7e9d13fe-5151-5876-66c0-20ca03e8fca4" + "clientID": "7e9d13fe-5151-5876-66c0-20ca03e8fca4" } } diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 350dbb9..44ac06a 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -300,7 +300,8 @@ func init() { if config.MonitorPort != 0 { go func() { log.Printf("[INFO] Starting Prometheus metrics exporter on port %d\n", config.MonitorPort) - log.Fatal(http.ListenAndServe(string(config.ListenAddr)+":"+strconv.Itoa(config.MonitorPort), nil)) + err := http.ListenAndServe(string(config.ListenAddr)+":"+strconv.Itoa(config.MonitorPort), nil) + log.Printf("[ERROR] Prometheus metrics exporter returned: %s\n", err) }() } autorestart.WatchFilename = config.File diff --git a/cmd/gagent/main_test.go b/cmd/gagent/main_test.go new file mode 100644 index 0000000..66c16f0 --- /dev/null +++ b/cmd/gagent/main_test.go @@ -0,0 +1,71 @@ +package main_test + +import ( + "io/ioutil" + "os" + "testing" + + main "github.com/dragonheim/gagent/cmd/gagent" + gstructs "github.com/dragonheim/gagent/internal/gstructs" +) + +// This function will create a temporary config file for testing purposes +func createTestConfigFile() (string, error) { + tmpfile, err := ioutil.TempFile("", "test_config_*.hcl") + if err != nil { + return "", err + } + + content := []byte(`mode = "setup" +listen_addr = "0.0.0.0" +monitor_port = 8888 +client_port = 35572 +router_port = 35570 +worker_port = 35571 +`) + if _, err := tmpfile.Write(content); err != nil { + return "", err + } + if err := tmpfile.Close(); err != nil { + return "", err + } + + return tmpfile.Name(), nil +} + +func TestMain(t *testing.T) { + t.Run("Test setup mode with temp config file", func(t *testing.T) { + tmpConfig, err := createTestConfigFile() + if err != nil { + t.Fatalf("Failed to create temp config file: %v", err) + } + defer os.Remove(tmpConfig) + + config := gstructs.GagentConfig{ + File: tmpConfig, + Mode: "setup", + } + + // Run the main function with the temporary config + main.Run(config) + + // Check if the config has been set up correctly + expectedConfig := gstructs.GagentConfig{ + Mode: "setup", + ListenAddr: "0.0.0.0", + MonitorPort: 8888, + ClientPort: 35572, + RouterPort: 35570, + WorkerPort: 35571, + } + + if config.Mode != expectedConfig.Mode || + config.ListenAddr != expectedConfig.ListenAddr || + config.MonitorPort != expectedConfig.MonitorPort || + config.ClientPort != expectedConfig.ClientPort || + config.RouterPort != expectedConfig.RouterPort || + config.WorkerPort != expectedConfig.WorkerPort { + t.Fatalf("Expected config %+v, got %+v", expectedConfig, config) + } + }) +} diff --git a/go.mod b/go.mod index dcddcfd..bd63971 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/pebbe/zmq4 v1.2.9 github.com/prometheus/client_golang v1.14.0 github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae + github.com/stretchr/testify v1.8.0 github.com/zclconf/go-cty v1.13.0 ) @@ -20,11 +21,13 @@ require ( github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/kr/pretty v0.2.0 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect diff --git a/go.sum b/go.sum index e1c8dd3..bc82f88 100644 --- a/go.sum +++ b/go.sum @@ -12,7 +12,9 @@ github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/I github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= @@ -41,6 +43,7 @@ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTS github.com/pebbe/zmq4 v1.2.9 h1:JlHcdgq6zpppNR1tH0wXJq0XK03pRUc4lBlHTD7aj/4= github.com/pebbe/zmq4 v1.2.9/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.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= @@ -52,7 +55,11 @@ github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= 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.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0= github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -66,5 +73,7 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM= google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/chaindb/chaindb_test.go b/internal/chaindb/chaindb_test.go new file mode 100644 index 0000000..c735328 --- /dev/null +++ b/internal/chaindb/chaindb_test.go @@ -0,0 +1,65 @@ +package chaindb + +import ( + "bytes" + "os" + "testing" + "time" + + gstructs "github.com/dragonheim/gagent/internal/gstructs" +) + +const testChainDBPath = "test_chaindb.hcl" + +func TestGagentDb(t *testing.T) { + // Create a new GagentDb + db := NewGagentDb() + + // Add a row to the database + row := &GagentDbRow{ + DBName: "testDB", + Agent: gstructs.AgentDetails{ + Client: "testAgent", + Shasum: "v1.0.0", + }, + } + db.AddRow(row) + + // Check if the row was added correctly + if len(db.ChainRow) != 1 { + t.Errorf("Expected length of ChainRow to be 1, but got %d", len(db.ChainRow)) + } + + // Check if the timestamp was set correctly + if db.ChainRow[0].Timestamp.After(time.Now()) { + t.Error("Timestamp is incorrectly set in the future") + } + + // Write the database to an HCL file + err := db.WriteHCL(testChainDBPath) + if err != nil { + t.Errorf("Error writing HCL file: %v", err) + } + + // Load the database from the HCL file + loadedDb := NewGagentDb() + err = loadedDb.LoadHCL(testChainDBPath) + if err != nil { + t.Errorf("Error loading HCL file: %v", err) + } + + // Check if the loaded database is the same as the original one + if !bytes.Equal(loadedDb.ChainRow[0].DbCurrHash[:], db.ChainRow[0].DbCurrHash[:]) { + t.Error("Loaded database has a different current hash than the original one") + } + + if !bytes.Equal(loadedDb.ChainRow[0].DbPrevHash[:], db.ChainRow[0].DbPrevHash[:]) { + t.Error("Loaded database has a different previous hash than the original one") + } + + // Clean up the test HCL file + err = os.Remove(testChainDBPath) + if err != nil { + t.Errorf("Error cleaning up test HCL file: %v", err) + } +} diff --git a/internal/client/client_test.go b/internal/client/client_test.go new file mode 100644 index 0000000..c2461d1 --- /dev/null +++ b/internal/client/client_test.go @@ -0,0 +1,152 @@ +package client + +import ( + "bytes" + "errors" + "io/ioutil" + "log" + "os" + "sync" + "testing" + + gstructs "github.com/dragonheim/gagent/internal/gstructs" + zmq "github.com/pebbe/zmq4" +) + +type mockSocket struct { + sendMessageError error +} + +func (m *mockSocket) Close() error { return nil } +func (m *mockSocket) Bind(endpoint string) error { return nil } +func (m *mockSocket) Connect(endpoint string) error { return nil } +func (m *mockSocket) SetIdentity(identity string) error { return nil } +func (m *mockSocket) SendMessage(parts ...interface{}) (int, error) { return 0, m.sendMessageError } +func (m *mockSocket) RecvMessage(flags zmq.Flag) ([]string, error) { return nil, nil } +func (m *mockSocket) RecvMessageBytes(flags zmq.Flag) ([][]byte, error) { return nil, nil } +func (m *mockSocket) RecvMessageString(flags zmq.Flag) ([]string, error) { return nil, nil } +func (m *mockSocket) SetSubscribe(filter string) error { return nil } +func (m *mockSocket) SetUnsubscribe(filter string) error { return nil } +func (m *mockSocket) Send(msg string, flags zmq.Flag) (int, error) { return 0, nil } +func (m *mockSocket) SendBytes(msg []byte, flags zmq.Flag) (int, error) { return 0, nil } +func (m *mockSocket) SendFrame(msg []byte, flags zmq.Flag) (int, error) { return 0, nil } +func (m *mockSocket) SendMultipart(parts [][]byte, flags zmq.Flag) (int, error) { return 0, nil } +func (m *mockSocket) Recv(flags zmq.Flag) (string, error) { return "", nil } +func (m *mockSocket) RecvBytes(flags zmq.Flag) ([]byte, error) { return nil, nil } +func (m *mockSocket) RecvFrame(flags zmq.Flag) ([]byte, error) { return nil, nil } +func (m *mockSocket) RecvMultipart(flags zmq.Flag) ([][]byte, error) { return nil, nil } +func (m *mockSocket) SetOption(option zmq.SocketOption, value interface{}) error { return nil } +func (m *mockSocket) GetOption(option zmq.SocketOption) (interface{}, error) { return nil, nil } +func (m *mockSocket) Events() zmq.State { return 0 } +func (m *mockSocket) String() string { return "" } + +func TestGetTagsFromHints(t *testing.T) { + agent := gstructs.AgentDetails{ + Script: []byte(`*set GHINT[split "tag1,tag2,tag3",]`), + } + + expectedHints := []string{"tag1", "tag2", "tag3"} + hints := getTagsFromHints(agent) + + if !equalStringSlices(hints, expectedHints) { + t.Errorf("Expected hints %v, but got %v", expectedHints, hints) + } +} + +func TestSendAgent(t *testing.T) { + wg := &sync.WaitGroup{} + config := gstructs.GagentConfig{ + UUID: "test-uuid", + ClientPort: 1234, + Routers: map[string]gstructs.Router{ + "test-router": { + RouterAddr: "127.0.0.1", + ClientPort: 1234, + }, + }, + } + + agent := gstructs.AgentDetails{ + Client: "test-client", + Script: []byte(`*set GHINT[split "tag1,tag2,tag3",]`), + } + + // Replace zmq.NewSocket with a function that returns a mock socket + origNewSocket := newSocket + defer func() { newSocket = origNewSocket }() + newSocket = func(t zmq.Type) (zmq.Socket, error) { + return &mockSocket{}, nil + } + + wg.Add(1) + go sendAgent(wg, config.UUID, "tcp://127.0.0.1:1234", agent) + wg.Wait() + + // Test with an error in sending a message + newSocket = func(t zmq.Type) (zmq.Socket, error) { + return &mockSocket{sendMessageError: errors.New("send message error")}, nil + } + + wg.Add(1) + go sendAgent(wg, config.UUID, "tcp://127.0.0.1:1234", agent) + wg.Wait() +} + +func equalStringSlices(a, b []string) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if a[i] != b[i] { + return false + } + } + return true +} + +func TestMain(t *testing.T) { + // Prepare a temporary agent file for testing + tmpAgentFile, err := ioutil.TempFile("", "agent") + if err != nil { + t.Fatal(err) + } + defer os.Remove(tmpAgentFile.Name()) + + content := []byte(`*set GHINT[split "tag1,tag2,tag3",]`) + if _, err := tmpAgentFile.Write(content); err != nil { + t.Fatal(err) + } + if err := tmpAgentFile.Close(); err != nil { + t.Fatal(err) + } + + config := gstructs.GagentConfig{ + CMode: true, + UUID: "test-uuid", + ClientPort: 1234, + Agent: tmpAgentFile.Name(), + Routers: map[string]gstructs.Router{ + "test-router": { + RouterAddr: "127.0.0.1", + ClientPort: 1234, + }, + }, + } + + // Replace log output with a buffer to suppress output during testing + origLogOutput := log.Writer() + defer log.SetOutput(origLogOutput) + log.SetOutput(&bytes.Buffer{}) + + // Replace zmq.NewSocket with a function that returns a mock socket + origNewSocket := newSocket + defer func() { newSocket = origNewSocket }() + newSocket = func(t zmq.Type) (zmq.Socket, error) { + return &mockSocket{}, nil + } + + wg := &sync.WaitGroup{} + wg.Add(1) + go Main(wg, config) + wg.Wait() +} diff --git a/internal/gstructs/agent_status.go b/internal/gstructs/agent_status.go new file mode 100644 index 0000000..ab36540 --- /dev/null +++ b/internal/gstructs/agent_status.go @@ -0,0 +1,35 @@ +package gstructs + +import ( + "fmt" +) + +type AgentStatus []string + +var AgentStatuses = AgentStatus{ + "ERROR", + "INIT", + "SENDING", + "RECEIVING", + "ROUTING", + "PROCESSING", + "COMPLETED", + "RETURNING", + "ERROR", +} + +func (a AgentStatus) GetByIndex(index int) (string, error) { + if index < 0 || index >= len(a) { + return "", fmt.Errorf("invalid index: %d", index) + } + return a[index], nil +} + +func (a AgentStatus) GetByName(name string) (byte, error) { + for i, status := range a { + if status == name { + return byte(i), nil + } + } + return 0, fmt.Errorf("value not found: %s", name) +} diff --git a/internal/gstructs/agent_status_test.go b/internal/gstructs/agent_status_test.go new file mode 100644 index 0000000..7d84c26 --- /dev/null +++ b/internal/gstructs/agent_status_test.go @@ -0,0 +1,59 @@ +package gstructs_test + +import ( + "testing" + + "github.com/dragonheim/gagent/internal/gstructs" + "github.com/stretchr/testify/assert" +) + +func TestGetByIndex(t *testing.T) { + agentStatuses := gstructs.AgentStatuses + + tests := []struct { + index int + expected string + shouldReturn bool + }{ + {0, "ERROR", true}, + {1, "INIT", true}, + {8, "ERROR", true}, + {9, "", false}, + {-1, "", false}, + } + + for _, test := range tests { + res, err := agentStatuses.GetByIndex(test.index) + if test.shouldReturn { + assert.NoError(t, err) + assert.Equal(t, test.expected, res) + } else { + assert.Error(t, err) + } + } +} + +func TestGetByName(t *testing.T) { + agentStatuses := gstructs.AgentStatuses + + tests := []struct { + name string + expected byte + shouldReturn bool + }{ + {"ERROR", 0, true}, + {"INIT", 1, true}, + {"COMPLETED", 6, true}, + {"INVALID", 0, false}, + } + + for _, test := range tests { + res, err := agentStatuses.GetByName(test.name) + if test.shouldReturn { + assert.NoError(t, err) + assert.Equal(t, test.expected, res) + } else { + assert.Error(t, err) + } + } +} diff --git a/internal/gstructs/gstructs.go b/internal/gstructs/gstructs.go index 9d2917f..d814ab0 100644 --- a/internal/gstructs/gstructs.go +++ b/internal/gstructs/gstructs.go @@ -111,10 +111,10 @@ type WorkerDetails struct { } type AgentDetails struct { - Status byte `hcl:"status"` - Client string `hcl:"client"` - Shasum string `hcl:"shasum"` - Hints []string - Script []byte - Answer []byte + Status byte `hcl:"status"` + Client string `hcl:"client"` + Shasum string `hcl:"shasum"` + Hints []string `hcl:"hints"` + Script []byte `hcl:"script"` + Answer []byte `hcl:"answer"` } diff --git a/internal/gstructs/gstructs_test.go b/internal/gstructs/gstructs_test.go new file mode 100644 index 0000000..160a47e --- /dev/null +++ b/internal/gstructs/gstructs_test.go @@ -0,0 +1,76 @@ +package gstructs_test + +import ( + "testing" + + "github.com/dragonheim/gagent/internal/gstructs" +) + +func TestGagentConfig(t *testing.T) { + config := gstructs.GagentConfig{ + Name: "test-config", + Mode: "client", + UUID: "test-uuid", + ListenAddr: "127.0.0.1", + ChainDBPath: "/tmp/chaindb", + MonitorPort: 8888, + ClientPort: 1234, + RouterPort: 5678, + WorkerPort: 9012, + Clients: []*gstructs.ClientDetails{ + { + ClientName: "test-client", + ClientID: "client-id", + }, + }, + Routers: []*gstructs.RouterDetails{ + { + RouterName: "test-router", + RouterID: "router-id", + RouterAddr: "192.168.1.1", + RouterTags: []string{"tag1", "tag2"}, + ClientPort: 1234, + RouterPort: 5678, + WorkerPort: 9012, + }, + }, + Workers: []*gstructs.WorkerDetails{ + { + WorkerName: "test-worker", + WorkerID: "worker-id", + WorkerTags: []string{"tag3", "tag4"}, + }, + }, + Version: "1.0.0", + File: "config.hcl", + Agent: "agent.gagent", + CMode: true, + } + + if config.Name != "test-config" { + t.Errorf("Expected config name to be 'test-config', got %s", config.Name) + } + if config.Mode != "client" { + t.Errorf("Expected config mode to be 'client', got %s", config.Mode) + } + // TODO: add more assertions for other config fields +} + +func TestAgentDetails(t *testing.T) { + agent := gstructs.AgentDetails{ + Status: 1, + Client: "test-client", + Shasum: "123456789abcdef", + Hints: []string{"tag1", "tag2", "tag3"}, + Script: []byte("sample script content"), + Answer: []byte("sample answer content"), + } + + if agent.Status != 1 { + t.Errorf("Expected agent status to be 1, got %d", agent.Status) + } + if agent.Client != "test-client" { + t.Errorf("Expected agent client to be 'test-client', got %s", agent.Client) + } + // TODO: add more assertions for other agent fields +} diff --git a/internal/router/router_test.go b/internal/router/router_test.go new file mode 100644 index 0000000..35b90c2 --- /dev/null +++ b/internal/router/router_test.go @@ -0,0 +1,72 @@ +package router_test + +import ( + "net/http" + "net/http/httptest" + "sync" + "testing" + "time" + + gs "github.com/dragonheim/gagent/internal/gstructs" + "github.com/dragonheim/gagent/internal/router" +) + +func TestRouterMain(t *testing.T) { + config := gs.GagentConfig{ + Name: "test-config", + Mode: "router", + UUID: "test-uuid", + ListenAddr: "127.0.0.1", + ClientPort: 1234, + RouterPort: 5678, + WorkerPort: 9012, + ChainDBPath: "test-chaindb-path", + } + + wg := &sync.WaitGroup{} + wg.Add(1) + + go router.Main(wg, config) + + // Allow router to start before sending HTTP requests + time.Sleep(time.Millisecond * 100) + + // Test GET request + resp := makeRequest(t, "GET", "http://localhost:1234/hello") + if resp.StatusCode != http.StatusOK { + t.Errorf("Expected status code %d, got %d", http.StatusOK, resp.StatusCode) + } + + // Test POST request + resp = makeRequest(t, "POST", "http://localhost:1234/hello") + if resp.StatusCode != http.StatusOK { + t.Errorf("Expected status code %d, got %d", http.StatusOK, resp.StatusCode) + } + + // Test OPTIONS request + resp = makeRequest(t, "OPTIONS", "http://localhost:1234/hello") + if resp.StatusCode != http.StatusNoContent { + t.Errorf("Expected status code %d, got %d", http.StatusNoContent, resp.StatusCode) + } + + // Test unsupported method + resp = makeRequest(t, "PUT", "http://localhost:1234/hello") + if resp.StatusCode != http.StatusMethodNotAllowed { + t.Errorf("Expected status code %d, got %d", http.StatusMethodNotAllowed, resp.StatusCode) + } + + wg.Wait() +} + +func makeRequest(t *testing.T, method, url string) *http.Response { + req, err := http.NewRequest(method, url, nil) + if err != nil { + t.Fatalf("Error creating request: %v", err) + } + + rr := httptest.NewRecorder() + handler := http.HandlerFunc(router.AnswerClient) + handler.ServeHTTP(rr, req) + + return rr.Result() +} diff --git a/internal/setup/setup_test.go b/internal/setup/setup_test.go new file mode 100644 index 0000000..5ffc8a5 --- /dev/null +++ b/internal/setup/setup_test.go @@ -0,0 +1,57 @@ +package setup_test + +import ( + "bytes" + "io" + "log" + "os" + "testing" + + "strings" + "sync" + + gs "github.com/dragonheim/gagent/internal/gstructs" + "github.com/dragonheim/gagent/internal/setup" +) + +func TestSetupMain(t *testing.T) { + config := gs.GagentConfig{ + Name: "test-config", + Mode: "client", + UUID: "test-uuid", + ListenAddr: "127.0.0.1", + ClientPort: 1234, + RouterPort: 5678, + WorkerPort: 9012, + } + + wg := &sync.WaitGroup{} + wg.Add(1) + + capturedOutput := captureOutput(func() { + setup.Main(wg, config) + }) + + expectedOutput := `Configuration file created` + if !strings.Contains(capturedOutput, expectedOutput) { + t.Errorf("Expected output to contain '%s', got '%s'", expectedOutput, capturedOutput) + } + + wg.Wait() +} + +func captureOutput(f func()) string { + original := *log.Writer() + r, w, _ := os.Pipe() + log.SetOutput(w) + + f() + + w.Close() + log.SetOutput(original) + + var buf bytes.Buffer + io.Copy(&buf, r) + + return buf.String() +} diff --git a/internal/worker/worker_test.go b/internal/worker/worker_test.go new file mode 100644 index 0000000..35bab82 --- /dev/null +++ b/internal/worker/worker_test.go @@ -0,0 +1,65 @@ +package worker_test + +import ( + "bytes" + "io" + "log" + "os" + "testing" + + "strings" + "sync" + + gs "github.com/dragonheim/gagent/internal/gstructs" + "github.com/dragonheim/gagent/internal/worker" +) + +func TestWorkerMain(t *testing.T) { + config := gs.GagentConfig{ + Name: "test-config", + Mode: "worker", + UUID: "test-uuid", + ListenAddr: "127.0.0.1", + ClientPort: 1234, + RouterPort: 5678, + WorkerPort: 9012, + Routers: []*gs.RouterDetails{ + { + RouterName: "test-router", + RouterID: "test-router-id", + RouterAddr: "127.0.0.1", + WorkerPort: 9012, + }, + }, + } + + wg := &sync.WaitGroup{} + wg.Add(1) + + capturedOutput := captureOutput(func() { + worker.Main(wg, config) + }) + + expectedOutput := `Starting worker` + if !strings.Contains(capturedOutput, expectedOutput) { + t.Errorf("Expected output to contain '%s', got '%s'", expectedOutput, capturedOutput) + } + + wg.Wait() +} + +func captureOutput(f func()) string { + original := *log.Writer() + r, w, _ := os.Pipe() + log.SetOutput(w) + + f() + + w.Close() + log.SetOutput(original) + + var buf bytes.Buffer + io.Copy(&buf, r) + + return buf.String() +} From bdeaf2ec9295f42eecdadf2780b0d02d7cb54732 Mon Sep 17 00:00:00 2001 From: James Wells Date: Mon, 3 Apr 2023 19:43:35 -0700 Subject: [PATCH 54/80] feat: added some more test harness. --- pkg/picol/commands.go | 30 +-- pkg/picol/commands_test.go | 300 +++++++++++++++++++++ pkg/picol/parser.go | 44 +-- pkg/picol/parser_test.go | 79 ++++++ pkg/picol/picol.go | 14 +- pkg/picol/picol_test.go | 56 ++++ pkg/picol/picol_unused/main.go_unused | 18 +- pkg/picol/picol_unused/main_test.go_unused | 31 +++ 8 files changed, 513 insertions(+), 59 deletions(-) create mode 100644 pkg/picol/commands_test.go create mode 100644 pkg/picol/parser_test.go create mode 100644 pkg/picol/picol_test.go create mode 100644 pkg/picol/picol_unused/main_test.go_unused diff --git a/pkg/picol/commands.go b/pkg/picol/commands.go index a1b8d7a..1c21af3 100644 --- a/pkg/picol/commands.go +++ b/pkg/picol/commands.go @@ -5,7 +5,6 @@ import ( "fmt" "strconv" "strings" - "testing" ) /* @@ -18,9 +17,9 @@ func incorrectArgCountError(i *Interpreter, name string, argv []string) error { } /* - * needleInHaystack returns true if the string is in a slice + * NeedleInHaystack returns true if the string is in a slice */ -func needleInHaystack(needle string, haystack []string) bool { +func NeedleInHaystack(needle string, haystack []string) bool { for _, haystackMember := range haystack { if haystackMember == needle { return true @@ -29,27 +28,6 @@ func needleInHaystack(needle string, haystack []string) bool { return false } -/* - * Test_needleInHaystack tests the return value of needleInHaystack - */ -func Test_needleInHaystack(t *testing.T) { - var haystack = []string{"a", "b", "c"} - var needle = "a" - if !needleInHaystack(needle, haystack) { - t.Errorf("%s not in %s", needle, haystack) - } - - needle = "j" - if needleInHaystack(needle, haystack) { - t.Errorf("%s in %s", needle, haystack) - } - - needle = "ab" - if needleInHaystack(needle, haystack) { - t.Errorf("%s in %s", needle, haystack) - } -} - /* * CommandMath is the math command for TCL */ @@ -274,7 +252,7 @@ func CommandPuts(i *Interpreter, argv []string, pd interface{}) (string, error) /* * RegisterCoreCommands is a callable to register TCL commands. */ -func (i *Interpreter) RegisterCoreCommands() { +func (i *Interpreter) RegisterCoreCommands() error { name := [...]string{"+", "-", "*", "/", ">", ">=", "<", "<=", "==", "!="} for _, n := range name { _ = i.RegisterCommand(n, CommandMath, nil) @@ -289,4 +267,6 @@ func (i *Interpreter) RegisterCoreCommands() { _ = i.RegisterCommand("return", CommandReturn, nil) _ = i.RegisterCommand("error", CommandError, nil) _ = i.RegisterCommand("puts", CommandPuts, nil) + + return nil } diff --git a/pkg/picol/commands_test.go b/pkg/picol/commands_test.go new file mode 100644 index 0000000..66e8ed8 --- /dev/null +++ b/pkg/picol/commands_test.go @@ -0,0 +1,300 @@ +package picol_test + +import ( + "testing" + + "github.com/dragonheim/gagent/pkg/picol" +) + +func Test_NeedleInHaystack(t *testing.T) { + var haystack = []string{"a", "b", "c"} + var needle = "a" + if !picol.NeedleInHaystack(needle, haystack) { + t.Errorf("%s not in %s", needle, haystack) + } + + needle = "j" + if picol.NeedleInHaystack(needle, haystack) { + t.Errorf("%s in %s", needle, haystack) + } + + needle = "ab" + if picol.NeedleInHaystack(needle, haystack) { + t.Errorf("%s in %s", needle, haystack) + } +} + +func Test_CommandMath(t *testing.T) { + // You can add more test cases for various operations and edge cases + testCases := []struct { + argv []string + result string + err error + }{ + {[]string{"+", "2", "3"}, "5", nil}, + {[]string{"-", "8", "3"}, "5", nil}, + {[]string{"*", "2", "3"}, "6", nil}, + {[]string{"/", "6", "3"}, "2", nil}, + {[]string{">", "4", "2"}, "1", nil}, + } + + i := picol.NewInterpreter() + for _, tc := range testCases { + result, err := picol.CommandMath(i, tc.argv, nil) + if result != tc.result || (err != nil && tc.err != nil && err.Error() != tc.err.Error()) { + t.Errorf("CommandMath(%v) = (%v, %v); expected (%v, %v)", tc.argv, result, err, tc.result, tc.err) + } + } +} + +func Test_CommandSet(t *testing.T) { + testCases := []struct { + argv []string + result string + err error + }{ + {[]string{"set", "x", "42"}, "42", nil}, + {[]string{"set", "y", "abc"}, "abc", nil}, + } + + i := picol.NewInterpreter() + for _, tc := range testCases { + result, err := picol.CommandSet(i, tc.argv, nil) + if result != tc.result || (err != nil && tc.err != nil && err.Error() != tc.err.Error()) { + t.Errorf("CommandSet(%v) = (%v, %v); expected (%v, %v)", tc.argv, result, err, tc.result, tc.err) + } + } +} + +func Test_CommandUnset(t *testing.T) { + testCases := []struct { + argv []string + result string + err error + }{ + {[]string{"unset", "x"}, "", nil}, + {[]string{"unset", "y"}, "", nil}, + } + + i := picol.NewInterpreter() + i.SetVariable("x", "42") + i.SetVariable("y", "abc") + + for _, tc := range testCases { + result, err := picol.CommandUnset(i, tc.argv, nil) + if result != tc.result || (err != nil && tc.err != nil && err.Error() != tc.err.Error()) { + t.Errorf("CommandUnset(%v) = (%v, %v); expected (%v, %v)", tc.argv, result, err, tc.result, tc.err) + } + } +} + +func Test_CommandIf(t *testing.T) { + testCases := []struct { + argv []string + result string + err error + }{ + {[]string{"unset", "x"}, "", nil}, + {[]string{"unset", "y"}, "", nil}, + } + + i := picol.NewInterpreter() + i.SetVariable("x", "42") + i.SetVariable("y", "abc") + + for _, tc := range testCases { + result, err := picol.CommandUnset(i, tc.argv, nil) + if result != tc.result || (err != nil && tc.err != nil && err.Error() != tc.err.Error()) { + t.Errorf("CommandUnset(%v) = (%v, %v); expected (%v, %v)", tc.argv, result, err, tc.result, tc.err) + } + } +} + +func Test_CommandWhile(t *testing.T) { + i := picol.NewInterpreter() + + // Test simple while loop + err := i.RegisterCoreCommands() + if err != nil { + t.Fatal(err) + } + + script := ` + set i 0 + set result 0 + while { < $i 5 } { + set result [+ $result $i] + set i [+ $i 1] + } + ` + + res, err := i.Eval(script) + if err != nil { + t.Fatalf("Error during while loop evaluation: %s", err) + } + + expectedResult := "10" + if res != expectedResult { + t.Errorf("Expected %s, got %s", expectedResult, res) + } + + // Test nested while loops + script = ` + set i 0 + set j 0 + set result 0 + while { < $i 3 } { + set j 0 + while { < $j 3 } { + set result [+ $result $j] + set j [+ $j 1] + } + set i [+ $i 1] + } + ` + + res, err = i.Eval(script) + if err != nil { + t.Fatalf("Error during nested while loop evaluation: %s", err) + } + + expectedResult = "9" + if res != expectedResult { + t.Errorf("Expected %s, got %s", expectedResult, res) + } +} + +// You can also add test functions for other commands like CommandProc, CommandReturn, etc. +func Test_CommandRetCodes(t *testing.T) { + i := picol.NewInterpreter() + + err := i.RegisterCoreCommands() + if err != nil { + t.Fatal(err) + } + + // Test break + script := ` + while { 1 } { + break + } + ` + _, err = i.Eval(script) + if err != nil { + t.Fatalf("Error during break evaluation: %s", err) + } + + // Test continue + script = ` + set i 0 + set result 0 + while { < $i 5 } { + if { == $i 2 } { + continue + } + set result [+ $result $i] + set i [+ $i 1] + } + ` + expectedResult := "7" + res, err := i.Eval(script) + if err != nil { + t.Fatalf("Error during continue evaluation: %s", err) + } + if res != expectedResult { + t.Errorf("Expected %s, got %s", expectedResult, res) + } +} + +func Test_CommandProc(t *testing.T) { + i := picol.NewInterpreter() + + err := i.RegisterCoreCommands() + if err != nil { + t.Fatal(err) + } + + script := ` + proc sum {a b} { + return [+ $a $b] + } + set res [sum 3 4] + ` + expectedResult := "7" + res, err := i.Eval(script) + if err != nil { + t.Fatalf("Error during proc evaluation: %s", err) + } + if res != expectedResult { + t.Errorf("Expected %s, got %s", expectedResult, res) + } +} + +func Test_CommandReturn(t *testing.T) { + i := picol.NewInterpreter() + + err := i.RegisterCoreCommands() + if err != nil { + t.Fatal(err) + } + + script := ` + proc testReturn {val} { + return $val + } + set res [testReturn 42] + ` + expectedResult := "42" + res, err := i.Eval(script) + if err != nil { + t.Fatalf("Error during return evaluation: %s", err) + } + if res != expectedResult { + t.Errorf("Expected %s, got %s", expectedResult, res) + } +} + +func Test_CommandError(t *testing.T) { + i := picol.NewInterpreter() + + err := i.RegisterCoreCommands() + if err != nil { + t.Fatal(err) + } + + script := ` + error "An error occurred" + ` + _, err = i.Eval(script) + if err == nil || err.Error() != "An error occurred" { + t.Fatalf("Error not raised or incorrect error message: %s", err) + } +} + +func Test_CommandPuts(t *testing.T) { + i := picol.NewInterpreter() + + err := i.RegisterCoreCommands() + if err != nil { + t.Fatal(err) + } + + // The following test checks if the "puts" command runs without any error. + // However, it doesn't check the printed output since it's not straightforward to capture stdout in tests. + script := ` + puts "Hello, world!" + ` + _, err = i.Eval(script) + if err != nil { + t.Fatalf("Error during puts evaluation: %s", err) + } +} + +func Test_RegisterCoreCommands(t *testing.T) { + i := picol.NewInterpreter() + + err := i.RegisterCoreCommands() + if err != nil { + t.Fatalf("Error during core command registration: %s", err) + } +} diff --git a/pkg/picol/parser.go b/pkg/picol/parser.go index e2cbb8b..f2cc441 100644 --- a/pkg/picol/parser.go +++ b/pkg/picol/parser.go @@ -7,13 +7,13 @@ import ( // Define parser token types const ( - ptESC = iota - ptSTR - ptCMD - ptVAR - ptSEP - ptEOL - ptEOF + ParserTokenESC = iota + ParserTokenSTR + ParserTokenCMD + ParserTokenVAR + ParserTokenSEP + ParserTokenEOL + ParserTokenEOF ) // parserStruct represents the parser state @@ -26,7 +26,7 @@ type parserStruct struct { // initParser initializes a new parserStruct instance func initParser(text string) *parserStruct { - return &parserStruct{text: text, ln: len(text), Type: ptEOL} + return &parserStruct{text: text, ln: len(text), Type: ParserTokenEOL} } // next advances the parser position by one rune @@ -57,7 +57,7 @@ func (p *parserStruct) parseSep() string { } } p.end = p.p - p.Type = ptSEP + p.Type = ParserTokenSEP return p.token() } @@ -74,7 +74,7 @@ func (p *parserStruct) parseEol() string { } p.end = p.p - p.Type = ptEOL + p.Type = ParserTokenEOL return p.token() } @@ -105,7 +105,7 @@ Loop: p.next() } p.end = p.p - p.Type = ptCMD + p.Type = ParserTokenCMD if p.p < len(p.text) && p.current() == ']' { p.next() } @@ -118,7 +118,7 @@ func (p *parserStruct) parseVar() string { p.start = p.p if p.current() == '{' { - p.Type = ptVAR + p.Type = ParserTokenVAR return p.parseBrace() } @@ -134,10 +134,10 @@ func (p *parserStruct) parseVar() string { if p.start == p.p { // It's just a single char string "$" p.start = p.p - 1 p.end = p.p - p.Type = ptSTR + p.Type = ParserTokenSTR } else { p.end = p.p - p.Type = ptVAR + p.Type = ParserTokenVAR } return p.token() } @@ -173,10 +173,10 @@ Loop: // parseString parses a string with or without quotes func (p *parserStruct) parseString() string { - newword := p.Type == ptSEP || p.Type == ptEOL || p.Type == ptSTR + newword := p.Type == ParserTokenSEP || p.Type == ParserTokenEOL || p.Type == ParserTokenSTR if c := p.current(); newword && c == '{' { - p.Type = ptSTR + p.Type = ParserTokenSTR return p.parseBrace() } else if newword && c == '"' { p.insidequote = 1 @@ -197,7 +197,7 @@ Loop: case '"': if p.insidequote != 0 { p.end = p.p - p.Type = ptESC + p.Type = ParserTokenESC p.next() p.insidequote = 0 return p.token() @@ -211,7 +211,7 @@ Loop: } p.end = p.p - p.Type = ptESC + p.Type = ParserTokenESC return p.token() } @@ -227,10 +227,10 @@ func (p *parserStruct) parseComment() string { func (p *parserStruct) GetToken() string { for { if p.ln == 0 { - if p.Type != ptEOL && p.Type != ptEOF { - p.Type = ptEOL + if p.Type != ParserTokenEOL && p.Type != ParserTokenEOF { + p.Type = ParserTokenEOL } else { - p.Type = ptEOF + p.Type = ParserTokenEOF } return p.token() } @@ -251,7 +251,7 @@ func (p *parserStruct) GetToken() string { case '$': return p.parseVar() case '#': - if p.Type == ptEOL { + if p.Type == ParserTokenEOL { p.parseComment() continue } diff --git a/pkg/picol/parser_test.go b/pkg/picol/parser_test.go new file mode 100644 index 0000000..a5247f7 --- /dev/null +++ b/pkg/picol/parser_test.go @@ -0,0 +1,79 @@ +package picol_test + +import ( + "testing" + + "github.com/dragonheim/gagent/pkg/picol" +) + +func TestParser(t *testing.T) { + testCases := []struct { + name string + input string + expected []int + }{ + { + "Simple test", + "set x 10\nincr x", + []int{ + picol.ParserTokenSTR, + picol.ParserTokenSEP, + picol.ParserTokenSTR, + picol.ParserTokenSEP, + picol.ParserTokenSTR, + picol.ParserTokenEOL, + picol.ParserTokenSTR, + picol.ParserTokenSEP, + picol.ParserTokenSTR, + picol.ParserTokenEOL, + picol.ParserTokenEOF, + }, + }, + { + "Variable and command test", + "set x $y\nputs [expr $x * 2]", + []int{ + picol.ParserTokenSTR, + picol.ParserTokenSEP, + picol.ParserTokenSTR, + picol.ParserTokenSEP, + picol.ParserTokenVAR, + picol.ParserTokenEOL, + picol.ParserTokenSTR, + picol.ParserTokenSEP, + picol.ParserTokenCMD, + picol.ParserTokenEOL, + picol.ParserTokenEOF, + }, + }, + { + "Braces and quotes test", + `set x {"Hello World"}`, + []int{ + picol.ParserTokenSTR, + picol.ParserTokenSEP, + picol.ParserTokenSTR, + picol.ParserTokenSEP, + picol.ParserTokenSTR, + picol.ParserTokenEOL, + picol.ParserTokenEOF, + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + parser := picol.InitParser(tc.input) + + for _, expectedType := range tc.expected { + token := parser.GetToken() + if parser.Type != expectedType { + t.Errorf("Expected token type %d, got %d", expectedType, parser.Type) + } + if parser.Type == picol.ParserTokenEOF { + break + } + } + }) + } +} diff --git a/pkg/picol/picol.go b/pkg/picol/picol.go index 5b53ecb..7390d5f 100644 --- a/pkg/picol/picol.go +++ b/pkg/picol/picol.go @@ -125,33 +125,33 @@ func (interp *Interpreter) Eval(script string) (string, error) { for { prevType := parser.Type token := parser.GetToken() - if parser.Type == ptEOF { + if parser.Type == ParserTokenEOF { break } switch parser.Type { - case ptVAR: + case ParserTokenVAR: v, ok := interp.Variable(token) if !ok { return "", fmt.Errorf("no such variable '%s'", token) } token = string(v) - case ptCMD: + case ParserTokenCMD: result, err = interp.Eval(token) if err != nil { return result, err } token = result - case ptESC: + case ParserTokenESC: /* * TODO: escape handling missing! */ - case ptSEP: + case ParserTokenSEP: // prevType = parser.Type continue } - if parser.Type == ptEOL { + if parser.Type == ParserTokenEOL { // prevType = parser.Type if len(argv) != 0 { cmd := interp.Command(argv[0]) @@ -173,7 +173,7 @@ func (interp *Interpreter) Eval(script string) (string, error) { /* * We have a new token, append to the previous or as new arg? */ - if prevType == ptSEP || prevType == ptEOL { + if prevType == ParserTokenSEP || prevType == ParserTokenEOL { argv = append(argv, token) } else { // Interpolation argv[len(argv)-1] = strings.Join([]string{argv[len(argv)-1], token}, "") diff --git a/pkg/picol/picol_test.go b/pkg/picol/picol_test.go new file mode 100644 index 0000000..3137dcc --- /dev/null +++ b/pkg/picol/picol_test.go @@ -0,0 +1,56 @@ +package picol_test + +import ( + "testing" + + "github.com/dragonheim/gagent/pkg/picol" +) + +func TestInterpreter(t *testing.T) { + interp := picol.NewInterpreter() + + // Register a command + err := interp.RegisterCommand("test", testCommand, nil) + if err != nil { + t.Fatalf("Error registering test command: %v", err) + } + + // Test command execution + script := "test hello world" + result, err := interp.Eval(script) + if err != nil { + t.Fatalf("Error executing script: %v", err) + } + expected := "hello world" + if result != expected { + t.Errorf("Expected result '%s', got '%s'", expected, result) + } + + // Test variable setting + interp.SetVariable("x", "42") + + // Test variable retrieval + val, ok := interp.Variable("x") + if !ok { + t.Fatalf("Variable 'x' not found") + } + expectedVar := "42" + if val != picol.Variable(expectedVar) { + t.Errorf("Expected variable value '%s', got '%s'", expectedVar, val) + } + + // Test variable unsetting + interp.UnsetVariable("x") + _, ok = interp.Variable("x") + if ok { + t.Fatalf("Variable 'x' should have been unset") + } +} + +// testCommand is a simple custom command for testing +func testCommand(interp *picol.Interpreter, argv []string, privdata interface{}) (string, error) { + if len(argv) != 3 { + return "", nil + } + return argv[1] + " " + argv[2], nil +} diff --git a/pkg/picol/picol_unused/main.go_unused b/pkg/picol/picol_unused/main.go_unused index c1fb8fa..4db8dd1 100644 --- a/pkg/picol/picol_unused/main.go_unused +++ b/pkg/picol/picol_unused/main.go_unused @@ -12,16 +12,15 @@ import ( var fname = flag.String("f", "", "file name") -func main() { - flag.Parse() +func RunPicol(fname string) error { interp := picol.NewInterpreter() interp.RegisterCoreCommands() - buf, err := ioutil.ReadFile(*fname) + buf, err := ioutil.ReadFile(fname) if err == nil { result, err := interp.Eval(string(buf)) if err != nil { - fmt.Println("ERRROR", result, err) + return fmt.Errorf("Error: %s, Result: %s", err, result) } } else { for { @@ -30,8 +29,17 @@ func main() { clibuf, _ := scanner.ReadString('\n') result, err := interp.Eval(clibuf[:len(clibuf)-1]) if len(result) != 0 { - fmt.Println("ERRROR", result, err) + return fmt.Errorf("Error: %s, Result: %s", err, result) } } } + return nil +} + +func main() { + flag.Parse() + err := RunPicol(*fname) + if err != nil { + fmt.Println(err) + } } diff --git a/pkg/picol/picol_unused/main_test.go_unused b/pkg/picol/picol_unused/main_test.go_unused new file mode 100644 index 0000000..896671d --- /dev/null +++ b/pkg/picol/picol_unused/main_test.go_unused @@ -0,0 +1,31 @@ +package main_test + +import ( + "io/ioutil" + "os" + "testing" + + picol "github.com/dragonheim/gagent/pkg/picol/picol_unused" +) + +func Test_RunPicol(t *testing.T) { + // Create a temporary test file + content := []byte("set a 5\nset b 7\n+ $a $b\n") + tmpfile, err := ioutil.TempFile("", "picol_test") + if err != nil { + t.Fatalf("Error creating temporary test file: %v", err) + } + defer os.Remove(tmpfile.Name()) // clean up + + if _, err := tmpfile.Write(content); err != nil { + t.Fatalf("Error writing content to temporary test file: %v", err) + } + if err := tmpfile.Close(); err != nil { + t.Fatalf("Error closing temporary test file: %v", err) + } + + err = picol.RunPicol(tmpfile.Name()) + if err != nil { + t.Errorf("Error during RunPicol: %v", err) + } +} From 8f77f2258cf5aecfec98926c6bfc64c7dfe821b6 Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 18 May 2023 18:04:20 -0700 Subject: [PATCH 55/80] fix: modified to fix some of the test failures. --- internal/chaindb/chaindb_test.go | 2 +- internal/router/router.go | 4 ++-- internal/setup/setup_test.go | 2 +- internal/worker/worker_test.go | 2 +- pkg/picol/parser.go | 2 +- pkg/picol/parser_test.go | 2 +- pkg/picol/picol.go | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/chaindb/chaindb_test.go b/internal/chaindb/chaindb_test.go index c735328..39fd10b 100644 --- a/internal/chaindb/chaindb_test.go +++ b/internal/chaindb/chaindb_test.go @@ -9,7 +9,7 @@ import ( gstructs "github.com/dragonheim/gagent/internal/gstructs" ) -const testChainDBPath = "test_chaindb.hcl" +const testChainDBPath = "/tmp/test_chaindb.hcl" func TestGagentDb(t *testing.T) { // Create a new GagentDb diff --git a/internal/router/router.go b/internal/router/router.go index b961256..a535833 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -29,7 +29,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { log.Printf("[INFO] Starting router\n") defer wg.Done() - http.HandleFunc("/hello", answerClient) + http.HandleFunc("/hello", AnswerClient) clientSock, _ := zmq.NewSocket(zmq.ROUTER) defer clientSock.Close() @@ -143,7 +143,7 @@ func unwrap(msg []string) (head string, tail []string) { return } -func answerClient(w http.ResponseWriter, r *http.Request) { +func AnswerClient(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { http.NotFound(w, r) return diff --git a/internal/setup/setup_test.go b/internal/setup/setup_test.go index 5ffc8a5..37d626e 100644 --- a/internal/setup/setup_test.go +++ b/internal/setup/setup_test.go @@ -41,7 +41,7 @@ func TestSetupMain(t *testing.T) { } func captureOutput(f func()) string { - original := *log.Writer() + original := log.Writer() r, w, _ := os.Pipe() log.SetOutput(w) diff --git a/internal/worker/worker_test.go b/internal/worker/worker_test.go index 35bab82..83411c0 100644 --- a/internal/worker/worker_test.go +++ b/internal/worker/worker_test.go @@ -49,7 +49,7 @@ func TestWorkerMain(t *testing.T) { } func captureOutput(f func()) string { - original := *log.Writer() + original := log.Writer() r, w, _ := os.Pipe() log.SetOutput(w) diff --git a/pkg/picol/parser.go b/pkg/picol/parser.go index f2cc441..e46c898 100644 --- a/pkg/picol/parser.go +++ b/pkg/picol/parser.go @@ -25,7 +25,7 @@ type parserStruct struct { } // initParser initializes a new parserStruct instance -func initParser(text string) *parserStruct { +func InitParser(text string) *parserStruct { return &parserStruct{text: text, ln: len(text), Type: ParserTokenEOL} } diff --git a/pkg/picol/parser_test.go b/pkg/picol/parser_test.go index a5247f7..fe5939e 100644 --- a/pkg/picol/parser_test.go +++ b/pkg/picol/parser_test.go @@ -66,7 +66,7 @@ func TestParser(t *testing.T) { parser := picol.InitParser(tc.input) for _, expectedType := range tc.expected { - token := parser.GetToken() + parser.GetToken() if parser.Type != expectedType { t.Errorf("Expected token type %d, got %d", expectedType, parser.Type) } diff --git a/pkg/picol/picol.go b/pkg/picol/picol.go index 7390d5f..4e2dbe4 100644 --- a/pkg/picol/picol.go +++ b/pkg/picol/picol.go @@ -116,7 +116,7 @@ func (interp *Interpreter) RegisterCommand(name string, fn CommandFunc, privdata * Eval evaluates a script */ func (interp *Interpreter) Eval(script string) (string, error) { - parser := initParser(script) + parser := InitParser(script) var result string var err error From 426a360f1e82e9f121a23498883c80d7c7ef8d96 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 2 Jun 2023 06:26:42 -0700 Subject: [PATCH 56/80] fix: upgrading to resolve some security vulnerabilities. --- cmd/gagent/main.go | 8 +++++--- go.mod | 21 +++++++++++---------- go.sum | 27 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 44ac06a..3436d47 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -29,6 +29,8 @@ import ( promhttp "github.com/prometheus/client_golang/prometheus/promhttp" uuid "github.com/jakehl/goid" + + versioninfo "github.com/carlmjohnson/versioninfo" ) /* @@ -55,8 +57,8 @@ var environment struct { /* * 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" */ -var semVER = "0.0.9" /* * This is the application configuration. It is populated from the configuration @@ -150,7 +152,7 @@ func init() { /* * Initialize the configuration */ - config.Version = semVER + config.Version = versioninfo.Version config.File = cfg.ConfigFile @@ -248,7 +250,7 @@ func init() { * Consume the usage variable and the command line arguments to create a * dictionary / map. */ - opts, _ := docopt.ParseArgs(usage, nil, semVER) + opts, _ := docopt.ParseArgs(usage, nil, config.Version) log.Printf("[DEBUG] Arguments are %v\n", opts) if opts["--config"] != nil { diff --git a/go.mod b/go.mod index bd63971..cd54429 100644 --- a/go.mod +++ b/go.mod @@ -6,14 +6,15 @@ 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.16.2 + github.com/carlmjohnson/versioninfo v0.22.4 + github.com/hashicorp/hcl/v2 v2.17.0 github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 github.com/pebbe/zmq4 v1.2.9 - github.com/prometheus/client_golang v1.14.0 + github.com/prometheus/client_golang v1.15.1 github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae github.com/stretchr/testify v1.8.0 - github.com/zclconf/go-cty v1.13.0 + github.com/zclconf/go-cty v1.13.2 ) require ( @@ -24,15 +25,15 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/kr/pretty v0.2.0 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect - google.golang.org/protobuf v1.29.1 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.10.1 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/text v0.9.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index bc82f88..734eecf 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,11 @@ 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/carlmjohnson/versioninfo v0.22.4 h1:AucUHDSKmk6j7Yx3dECGUxaowGHOAN0Zx5/EBtsXn4Y= +github.com/carlmjohnson/versioninfo v0.22.4/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -26,15 +29,21 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hashicorp/hcl/v2 v2.16.2 h1:mpkHZh/Tv+xet3sy3F9Ld4FyI2tUpWe9x3XtPx9f1a0= github.com/hashicorp/hcl/v2 v2.16.2/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= +github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= +github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= @@ -42,16 +51,26 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/pebbe/zmq4 v1.2.9 h1:JlHcdgq6zpppNR1tH0wXJq0XK03pRUc4lBlHTD7aj/4= github.com/pebbe/zmq4 v1.2.9/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= 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.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI= +github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= 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= @@ -62,16 +81,24 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0= github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= +github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= +github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM= google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 3bb7096625af1d090dffc15d6b818c85470cb68a Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 2 Jun 2023 06:36:13 -0700 Subject: [PATCH 57/80] fix: forgot to remove old dependencies. --- go.mod | 2 +- go.sum | 28 +--------------------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/go.mod b/go.mod index cd54429..514a6b0 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/go.sum b/go.sum index 734eecf..bd4ff39 100644 --- a/go.sum +++ b/go.sum @@ -20,28 +20,19 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.16.2 h1:mpkHZh/Tv+xet3sy3F9Ld4FyI2tUpWe9x3XtPx9f1a0= -github.com/hashicorp/hcl/v2 v2.16.2/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= -github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= @@ -51,26 +42,17 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/pebbe/zmq4 v1.2.9 h1:JlHcdgq6zpppNR1tH0wXJq0XK03pRUc4lBlHTD7aj/4= github.com/pebbe/zmq4 v1.2.9/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= 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.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI= github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= 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= @@ -79,24 +61,16 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0= -github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM= -google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From d13a3095939ead68755962b775613e4b15218ac5 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 30 Jun 2023 17:47:45 -0700 Subject: [PATCH 58/80] minor cleanup and standardization of package names. --- cmd/gagent/main.go | 9 +++------ cmd/gagent/main_test.go | 6 +++--- internal/chaindb/chaindb.go | 13 +++++++------ internal/chaindb/chaindb_test.go | 4 ++-- internal/client/client.go | 10 +++++----- internal/client/client_test.go | 15 ++++++++------- internal/gstructs/agent_status_test.go | 6 +++--- internal/gstructs/gstructs_test.go | 12 ++++++------ internal/worker/worker_test.go | 1 + 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index 3436d47..48ff061 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -50,6 +50,7 @@ import ( var environment struct { ConfigFile string `env:"GAGENT_CONFIG" envDefault:"/etc/gagent/gagent.hcl"` + LogLevel string `env:"GAGENT_LOGLEVEL" envDefault:"WARN"` Mode string `env:"GAGENT_MODE" envDefault:"setup"` MonitorPort int `env:"MONITOR_PORT" envDefault:"0"` } @@ -134,15 +135,11 @@ func main() { */ func init() { cfg := environment - if err := env.Parse(&cfg); err != nil { - log.Printf("%+v\n", err) - } - - log.Printf("%+v\n", cfg) + env.Parse(&cfg) filter := &logutils.LevelFilter{ Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"}, - MinLevel: logutils.LogLevel("DEBUG"), + MinLevel: logutils.LogLevel(cfg.LogLevel), Writer: os.Stderr, } log.SetOutput(filter) diff --git a/cmd/gagent/main_test.go b/cmd/gagent/main_test.go index 66c16f0..25e74c1 100644 --- a/cmd/gagent/main_test.go +++ b/cmd/gagent/main_test.go @@ -1,11 +1,11 @@ -package main_test +package main import ( "io/ioutil" "os" "testing" - main "github.com/dragonheim/gagent/cmd/gagent" + // main "github.com/dragonheim/gagent/cmd/gagent" gstructs "github.com/dragonheim/gagent/internal/gstructs" ) @@ -47,7 +47,7 @@ func TestMain(t *testing.T) { } // Run the main function with the temporary config - main.Run(config) + t.Run(config) // Check if the config has been set up correctly expectedConfig := gstructs.GagentConfig{ diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go index 1782c79..3e3965a 100644 --- a/internal/chaindb/chaindb.go +++ b/internal/chaindb/chaindb.go @@ -7,7 +7,8 @@ import ( log "log" time "time" - gstructs "github.com/dragonheim/gagent/internal/gstructs" + gs "github.com/dragonheim/gagent/internal/gstructs" + cty "github.com/zclconf/go-cty/cty" hclsimple "github.com/hashicorp/hcl/v2/hclsimple" @@ -19,11 +20,11 @@ type GagentDb struct { } type GagentDbRow struct { - Timestamp time.Time `hcl:"timestamp"` - DBName string `hcl:"chainid,optional"` - Agent gstructs.AgentDetails `hcl:"agent,block"` - DbCurrHash [32]byte `hcl:"currhash"` - DbPrevHash [32]byte `hcl:"prevhash"` + Timestamp time.Time `hcl:"timestamp"` + DBName string `hcl:"chainid,optional"` + Agent gs.AgentDetails `hcl:"agent,block"` + DbCurrHash [32]byte `hcl:"currhash"` + DbPrevHash [32]byte `hcl:"prevhash"` } /* diff --git a/internal/chaindb/chaindb_test.go b/internal/chaindb/chaindb_test.go index 39fd10b..8c2d980 100644 --- a/internal/chaindb/chaindb_test.go +++ b/internal/chaindb/chaindb_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - gstructs "github.com/dragonheim/gagent/internal/gstructs" + gs "github.com/dragonheim/gagent/internal/gstructs" ) const testChainDBPath = "/tmp/test_chaindb.hcl" @@ -18,7 +18,7 @@ func TestGagentDb(t *testing.T) { // Add a row to the database row := &GagentDbRow{ DBName: "testDB", - Agent: gstructs.AgentDetails{ + Agent: gs.AgentDetails{ Client: "testAgent", Shasum: "v1.0.0", }, diff --git a/internal/client/client.go b/internal/client/client.go index d679b6d..364a352 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -13,7 +13,7 @@ import ( sync "sync" time "time" - gstructs "github.com/dragonheim/gagent/internal/gstructs" + gs "github.com/dragonheim/gagent/internal/gstructs" zmq "github.com/pebbe/zmq4" ) @@ -26,11 +26,11 @@ import ( * of it's most recent request. * Main is the entrypoint for the client process */ -func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { +func Main(wg *sync.WaitGroup, config gs.GagentConfig) { log.Printf("[INFO] Starting client\n") defer wg.Done() - var agent gstructs.AgentDetails + var agent gs.AgentDetails var err error if config.CMode { @@ -67,7 +67,7 @@ func Main(wg *sync.WaitGroup, config gstructs.GagentConfig) { /* * Parse Agent file for GHINT data to populate the G'Agent hints */ -func getTagsFromHints(agent gstructs.AgentDetails) []string { +func getTagsFromHints(agent gs.AgentDetails) []string { var tags []string // Use named capture groups to extract the hints @@ -89,7 +89,7 @@ func getTagsFromHints(agent gstructs.AgentDetails) []string { return tags } -func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent gstructs.AgentDetails) { +func sendAgent(wg *sync.WaitGroup, uuid string, connectString string, agent gs.AgentDetails) { defer wg.Done() var mu sync.Mutex diff --git a/internal/client/client_test.go b/internal/client/client_test.go index c2461d1..2f00858 100644 --- a/internal/client/client_test.go +++ b/internal/client/client_test.go @@ -9,7 +9,8 @@ import ( "sync" "testing" - gstructs "github.com/dragonheim/gagent/internal/gstructs" + gs "github.com/dragonheim/gagent/internal/gstructs" + zmq "github.com/pebbe/zmq4" ) @@ -41,7 +42,7 @@ func (m *mockSocket) Events() zmq.State func (m *mockSocket) String() string { return "" } func TestGetTagsFromHints(t *testing.T) { - agent := gstructs.AgentDetails{ + agent := gs.AgentDetails{ Script: []byte(`*set GHINT[split "tag1,tag2,tag3",]`), } @@ -55,10 +56,10 @@ func TestGetTagsFromHints(t *testing.T) { func TestSendAgent(t *testing.T) { wg := &sync.WaitGroup{} - config := gstructs.GagentConfig{ + config := gs.GagentConfig{ UUID: "test-uuid", ClientPort: 1234, - Routers: map[string]gstructs.Router{ + Routers: map[string]gs.Router{ "test-router": { RouterAddr: "127.0.0.1", ClientPort: 1234, @@ -66,7 +67,7 @@ func TestSendAgent(t *testing.T) { }, } - agent := gstructs.AgentDetails{ + agent := gs.AgentDetails{ Client: "test-client", Script: []byte(`*set GHINT[split "tag1,tag2,tag3",]`), } @@ -120,12 +121,12 @@ func TestMain(t *testing.T) { t.Fatal(err) } - config := gstructs.GagentConfig{ + config := gs.GagentConfig{ CMode: true, UUID: "test-uuid", ClientPort: 1234, Agent: tmpAgentFile.Name(), - Routers: map[string]gstructs.Router{ + Routers: map[string]gs.Router{ "test-router": { RouterAddr: "127.0.0.1", ClientPort: 1234, diff --git a/internal/gstructs/agent_status_test.go b/internal/gstructs/agent_status_test.go index 7d84c26..dda29ac 100644 --- a/internal/gstructs/agent_status_test.go +++ b/internal/gstructs/agent_status_test.go @@ -3,12 +3,12 @@ package gstructs_test import ( "testing" - "github.com/dragonheim/gagent/internal/gstructs" + gs "github.com/dragonheim/gagent/internal/gstructs" "github.com/stretchr/testify/assert" ) func TestGetByIndex(t *testing.T) { - agentStatuses := gstructs.AgentStatuses + agentStatuses := gs.AgentStatuses tests := []struct { index int @@ -34,7 +34,7 @@ func TestGetByIndex(t *testing.T) { } func TestGetByName(t *testing.T) { - agentStatuses := gstructs.AgentStatuses + agentStatuses := gs.AgentStatuses tests := []struct { name string diff --git a/internal/gstructs/gstructs_test.go b/internal/gstructs/gstructs_test.go index 160a47e..1bb774a 100644 --- a/internal/gstructs/gstructs_test.go +++ b/internal/gstructs/gstructs_test.go @@ -3,11 +3,11 @@ package gstructs_test import ( "testing" - "github.com/dragonheim/gagent/internal/gstructs" + gs "github.com/dragonheim/gagent/internal/gstructs" ) func TestGagentConfig(t *testing.T) { - config := gstructs.GagentConfig{ + config := gs.GagentConfig{ Name: "test-config", Mode: "client", UUID: "test-uuid", @@ -17,13 +17,13 @@ func TestGagentConfig(t *testing.T) { ClientPort: 1234, RouterPort: 5678, WorkerPort: 9012, - Clients: []*gstructs.ClientDetails{ + Clients: []*gs.ClientDetails{ { ClientName: "test-client", ClientID: "client-id", }, }, - Routers: []*gstructs.RouterDetails{ + Routers: []*gs.RouterDetails{ { RouterName: "test-router", RouterID: "router-id", @@ -34,7 +34,7 @@ func TestGagentConfig(t *testing.T) { WorkerPort: 9012, }, }, - Workers: []*gstructs.WorkerDetails{ + Workers: []*gs.WorkerDetails{ { WorkerName: "test-worker", WorkerID: "worker-id", @@ -57,7 +57,7 @@ func TestGagentConfig(t *testing.T) { } func TestAgentDetails(t *testing.T) { - agent := gstructs.AgentDetails{ + agent := gs.AgentDetails{ Status: 1, Client: "test-client", Shasum: "123456789abcdef", diff --git a/internal/worker/worker_test.go b/internal/worker/worker_test.go index 83411c0..e98a02f 100644 --- a/internal/worker/worker_test.go +++ b/internal/worker/worker_test.go @@ -11,6 +11,7 @@ import ( "sync" gs "github.com/dragonheim/gagent/internal/gstructs" + "github.com/dragonheim/gagent/internal/worker" ) From 81acc798e9997f807b8c58c25b78d77e2cc69166 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 30 Jun 2023 17:56:30 -0700 Subject: [PATCH 59/80] Added some commentary to the README to help avoid future confusion. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e849733..ef8d670 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ A Golang based mobile agent system loosely inspired by the [Agent Tcl / D'Agents](http://www.cs.dartmouth.edu/~dfk/agents/) system created by Robert S. Gray of Dartmouth college. +Please note that this program is mostly meant to be used as a tool for me to learn software development in Go, and is not meant to be used in a production environments. + +GPT-4 has been used in various parts of this project to debug, improve functionality and provide examples of how to get over various hurdles as I learn Go. + ## Sumary G'Agent streamlines interplanetary data searches using TCL scripts, allowing efficient communication despite time delays between Earth and Mars. From 82a964fc501058fe45f1abfe27362c90711451b8 Mon Sep 17 00:00:00 2001 From: James Wells Date: Sun, 6 Aug 2023 14:10:24 -0700 Subject: [PATCH 60/80] Updated module dependencies. --- go.mod | 14 +++++++------- go.sum | 33 ++++++++++++++------------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index 514a6b0..50c4001 100644 --- a/go.mod +++ b/go.mod @@ -10,10 +10,10 @@ require ( github.com/hashicorp/hcl/v2 v2.17.0 github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 - github.com/pebbe/zmq4 v1.2.9 - github.com/prometheus/client_golang v1.15.1 + github.com/pebbe/zmq4 v1.2.10 + github.com/prometheus/client_golang v1.16.0 github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae - github.com/stretchr/testify v1.8.0 + github.com/stretchr/testify v1.8.4 github.com/zclconf/go-cty v1.13.2 ) @@ -31,9 +31,9 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/common v0.44.0 // indirect - github.com/prometheus/procfs v0.10.1 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + github.com/prometheus/procfs v0.11.0 // indirect + golang.org/x/sys v0.9.0 // indirect + golang.org/x/text v0.10.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index bd4ff39..68be6a8 100644 --- a/go.sum +++ b/go.sum @@ -15,7 +15,6 @@ github.com/carlmjohnson/versioninfo v0.22.4/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPv github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= @@ -40,41 +39,37 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zk github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/pebbe/zmq4 v1.2.9 h1:JlHcdgq6zpppNR1tH0wXJq0XK03pRUc4lBlHTD7aj/4= -github.com/pebbe/zmq4 v1.2.9/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= +github.com/pebbe/zmq4 v1.2.10 h1:wQkqRZ3CZeABIeidr3e8uQZMMH5YAykA/WN0L5zkd1c= +github.com/pebbe/zmq4 v1.2.10/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.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI= -github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= -github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= +github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= +github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= 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.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 97c8af881607d7768a448a230a2f4e1029432be9 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 9 Feb 2024 12:47:17 -0800 Subject: [PATCH 61/80] fix: Replaced ioutil as it was deprecated in Golang. --- README.md | 4 +- cmd/gagent/main_test.go | 7 +-- go.mod | 28 +++++----- go.sum | 65 ++++++++++------------ internal/chaindb/chaindb.go | 4 +- internal/chaindb/chaindb_test.go | 8 +-- internal/client/client.go | 3 +- internal/client/client_test.go | 16 +++--- internal/gstructs/agent_status.go | 2 +- internal/gstructs/agent_status_test.go | 4 +- internal/gstructs/gstructs_test.go | 2 +- internal/router/router_test.go | 12 ++-- internal/setup/setup_test.go | 16 +++--- internal/worker/worker_test.go | 16 +++--- pkg/picol/commands.go | 8 +-- pkg/picol/commands_test.go | 4 +- pkg/picol/picol_unused/main.go_unused | 12 ++-- pkg/picol/picol_unused/main_test.go_unused | 8 +-- 18 files changed, 105 insertions(+), 114 deletions(-) diff --git a/README.md b/README.md index ef8d670..42acc46 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # G'Agent -[![Maintained Status](https://img.shields.io/maintenance/yes/2023?style=plastic)](https://github.com/dragonheim/gagent) +[![Maintained Status](https://img.shields.io/maintenance/yes/2024?style=plastic)](https://github.com/dragonheim/gagent) [![License](https://img.shields.io/badge/License-MIT-limegreen.svg)](https://github.com/dragonheim/gagent/src/branch/main/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/dragonheim/gagent)](https://goreportcard.com/report/github.com/dragonheim/gagent) @@ -7,7 +7,7 @@ A Golang based mobile agent system loosely inspired by the [Agent Tcl / D'Agents](http://www.cs.dartmouth.edu/~dfk/agents/) system created by Robert S. Gray of Dartmouth college. -Please note that this program is mostly meant to be used as a tool for me to learn software development in Go, and is not meant to be used in a production environments. +Please note that this program is mostly meant to be used as a tool for me to learn software development in Go, and is not meant to be used in production environments. GPT-4 has been used in various parts of this project to debug, improve functionality and provide examples of how to get over various hurdles as I learn Go. diff --git a/cmd/gagent/main_test.go b/cmd/gagent/main_test.go index 25e74c1..3efdb37 100644 --- a/cmd/gagent/main_test.go +++ b/cmd/gagent/main_test.go @@ -1,9 +1,8 @@ package main import ( - "io/ioutil" - "os" - "testing" + os "os" + testing "testing" // main "github.com/dragonheim/gagent/cmd/gagent" gstructs "github.com/dragonheim/gagent/internal/gstructs" @@ -11,7 +10,7 @@ import ( // This function will create a temporary config file for testing purposes func createTestConfigFile() (string, error) { - tmpfile, err := ioutil.TempFile("", "test_config_*.hcl") + tmpfile, err := os.CreateTemp("", "test_config_*.hcl") if err != nil { return "", err } diff --git a/go.mod b/go.mod index 50c4001..a9a36dc 100644 --- a/go.mod +++ b/go.mod @@ -1,39 +1,37 @@ module github.com/dragonheim/gagent -go 1.18 +go 1.21 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/carlmjohnson/versioninfo v0.22.4 - github.com/hashicorp/hcl/v2 v2.17.0 + github.com/carlmjohnson/versioninfo v0.22.5 + github.com/hashicorp/hcl/v2 v2.19.1 github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 github.com/pebbe/zmq4 v1.2.10 - github.com/prometheus/client_golang v1.16.0 + github.com/prometheus/client_golang v1.18.0 github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae github.com/stretchr/testify v1.8.4 - github.com/zclconf/go-cty v1.13.2 + github.com/zclconf/go-cty v1.14.2 ) require ( github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/kr/text v0.2.0 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.44.0 // indirect - github.com/prometheus/procfs v0.11.0 // indirect - golang.org/x/sys v0.9.0 // indirect - golang.org/x/text v0.10.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.46.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect + golang.org/x/sys v0.17.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 68be6a8..8fcadd8 100644 --- a/go.sum +++ b/go.sum @@ -2,74 +2,69 @@ github.com/Showmax/go-fqdn v1.0.0 h1:0rG5IbmVliNT5O19Mfuvna9LL7zlHyRfsSvBPZmF9tM github.com/Showmax/go-fqdn v1.0.0/go.mod h1:SfrFBzmDCtCGrnHhoDjuvFnKsWjEQX/Q9ARZvOrJAko= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a h1:YJuVATwP+Gzk7nys0U/DKjKkoYp1n/sYm0yi5vX8W8M= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a/go.mod h1:pBRbUcGboHT5qBceq2Cg/WIcDbO78a8wPxTg8zmS3Hs= 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/carlmjohnson/versioninfo v0.22.4 h1:AucUHDSKmk6j7Yx3dECGUxaowGHOAN0Zx5/EBtsXn4Y= -github.com/carlmjohnson/versioninfo v0.22.4/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8= +github.com/carlmjohnson/versioninfo v0.22.5 h1:O00sjOLUAFxYQjlN/bzYTuZiS0y6fWDQjMRvwtKgwwc= +github.com/carlmjohnson/versioninfo v0.22.5/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= -github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= +github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/pebbe/zmq4 v1.2.10 h1:wQkqRZ3CZeABIeidr3e8uQZMMH5YAykA/WN0L5zkd1c= github.com/pebbe/zmq4 v1.2.10/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.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= -github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= -github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= -github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= -github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= -github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= +github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= 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/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= 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/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= -github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= -golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI= +github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go index 3e3965a..bc15c4f 100644 --- a/internal/chaindb/chaindb.go +++ b/internal/chaindb/chaindb.go @@ -3,8 +3,8 @@ package chaindb import ( sha256 "crypto/sha256" fmt "fmt" - ioutil "io/ioutil" log "log" + os "os" time "time" gs "github.com/dragonheim/gagent/internal/gstructs" @@ -70,7 +70,7 @@ func (db *GagentDb) WriteHCL(ChainDBPath string) error { agentBody.SetAttributeValue("version", cty.StringVal(row.Agent.Shasum)) } - return ioutil.WriteFile(ChainDBPath, f.Bytes(), 0600) + return os.WriteFile(ChainDBPath, f.Bytes(), 0600) } /* diff --git a/internal/chaindb/chaindb_test.go b/internal/chaindb/chaindb_test.go index 8c2d980..aa838b3 100644 --- a/internal/chaindb/chaindb_test.go +++ b/internal/chaindb/chaindb_test.go @@ -1,10 +1,10 @@ package chaindb import ( - "bytes" - "os" - "testing" - "time" + bytes "bytes" + os "os" + testing "testing" + time "time" gs "github.com/dragonheim/gagent/internal/gstructs" ) diff --git a/internal/client/client.go b/internal/client/client.go index 364a352..21862e0 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -4,7 +4,6 @@ import ( sha "crypto/sha256" hex "encoding/hex" fmt "fmt" - ioutil "io/ioutil" log "log" os "os" regexp "regexp" @@ -34,7 +33,7 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) { var err error if config.CMode { - agent.Script, err = ioutil.ReadFile(config.Agent) + agent.Script, err = os.ReadFile(config.Agent) if err != nil { log.Printf("[ERROR] No such file or directory: %s", config.Agent) os.Exit(4) diff --git a/internal/client/client_test.go b/internal/client/client_test.go index 2f00858..41c4297 100644 --- a/internal/client/client_test.go +++ b/internal/client/client_test.go @@ -1,13 +1,13 @@ package client import ( - "bytes" - "errors" - "io/ioutil" - "log" - "os" - "sync" - "testing" + bytes "bytes" + errors "errors" + io "io" + log "log" + os "os" + sync "sync" + testing "testing" gs "github.com/dragonheim/gagent/internal/gstructs" @@ -107,7 +107,7 @@ func equalStringSlices(a, b []string) bool { func TestMain(t *testing.T) { // Prepare a temporary agent file for testing - tmpAgentFile, err := ioutil.TempFile("", "agent") + tmpAgentFile, err := io.TempFile("", "agent") if err != nil { t.Fatal(err) } diff --git a/internal/gstructs/agent_status.go b/internal/gstructs/agent_status.go index ab36540..e439bad 100644 --- a/internal/gstructs/agent_status.go +++ b/internal/gstructs/agent_status.go @@ -1,7 +1,7 @@ package gstructs import ( - "fmt" + fmt "fmt" ) type AgentStatus []string diff --git a/internal/gstructs/agent_status_test.go b/internal/gstructs/agent_status_test.go index dda29ac..afff4ff 100644 --- a/internal/gstructs/agent_status_test.go +++ b/internal/gstructs/agent_status_test.go @@ -1,10 +1,10 @@ package gstructs_test import ( - "testing" + testing "testing" gs "github.com/dragonheim/gagent/internal/gstructs" - "github.com/stretchr/testify/assert" + assert "github.com/stretchr/testify/assert" ) func TestGetByIndex(t *testing.T) { diff --git a/internal/gstructs/gstructs_test.go b/internal/gstructs/gstructs_test.go index 1bb774a..98121ed 100644 --- a/internal/gstructs/gstructs_test.go +++ b/internal/gstructs/gstructs_test.go @@ -1,7 +1,7 @@ package gstructs_test import ( - "testing" + testing "testing" gs "github.com/dragonheim/gagent/internal/gstructs" ) diff --git a/internal/router/router_test.go b/internal/router/router_test.go index 35b90c2..2b52a5e 100644 --- a/internal/router/router_test.go +++ b/internal/router/router_test.go @@ -1,14 +1,14 @@ package router_test import ( - "net/http" - "net/http/httptest" - "sync" - "testing" - "time" + http "net/http" + httptest "net/http/httptest" + sync "sync" + testing "testing" + time "time" gs "github.com/dragonheim/gagent/internal/gstructs" - "github.com/dragonheim/gagent/internal/router" + router "github.com/dragonheim/gagent/internal/router" ) func TestRouterMain(t *testing.T) { diff --git a/internal/setup/setup_test.go b/internal/setup/setup_test.go index 37d626e..cb6da23 100644 --- a/internal/setup/setup_test.go +++ b/internal/setup/setup_test.go @@ -1,17 +1,17 @@ package setup_test import ( - "bytes" - "io" - "log" - "os" - "testing" + bytes "bytes" + io "io" + log "log" + os "os" + testing "testing" - "strings" - "sync" + strings "strings" + sync "sync" gs "github.com/dragonheim/gagent/internal/gstructs" - "github.com/dragonheim/gagent/internal/setup" + setup "github.com/dragonheim/gagent/internal/setup" ) func TestSetupMain(t *testing.T) { diff --git a/internal/worker/worker_test.go b/internal/worker/worker_test.go index e98a02f..b3188ee 100644 --- a/internal/worker/worker_test.go +++ b/internal/worker/worker_test.go @@ -1,18 +1,18 @@ package worker_test import ( - "bytes" - "io" - "log" - "os" - "testing" + bytes "bytes" + io "io" + log "log" + os "os" + testing "testing" - "strings" - "sync" + strings "strings" + sync "sync" gs "github.com/dragonheim/gagent/internal/gstructs" - "github.com/dragonheim/gagent/internal/worker" + worker "github.com/dragonheim/gagent/internal/worker" ) func TestWorkerMain(t *testing.T) { diff --git a/pkg/picol/commands.go b/pkg/picol/commands.go index 1c21af3..345e4be 100644 --- a/pkg/picol/commands.go +++ b/pkg/picol/commands.go @@ -1,10 +1,10 @@ package picol import ( - "errors" - "fmt" - "strconv" - "strings" + errors "errors" + fmt "fmt" + strconv "strconv" + strings "strings" ) /* diff --git a/pkg/picol/commands_test.go b/pkg/picol/commands_test.go index 66e8ed8..b166078 100644 --- a/pkg/picol/commands_test.go +++ b/pkg/picol/commands_test.go @@ -1,9 +1,9 @@ package picol_test import ( - "testing" + testing "testing" - "github.com/dragonheim/gagent/pkg/picol" + picol "github.com/dragonheim/gagent/pkg/picol" ) func Test_NeedleInHaystack(t *testing.T) { diff --git a/pkg/picol/picol_unused/main.go_unused b/pkg/picol/picol_unused/main.go_unused index 4db8dd1..954c29a 100644 --- a/pkg/picol/picol_unused/main.go_unused +++ b/pkg/picol/picol_unused/main.go_unused @@ -1,11 +1,11 @@ package main import ( - "bufio" - "flag" - "fmt" - "io/ioutil" - "os" + bufio "bufio" + flag "flag" + fmt "fmt" + io "io" + os "os" picol "github.com/dragonheim/gagent/pkg/picol" ) @@ -16,7 +16,7 @@ func RunPicol(fname string) error { interp := picol.NewInterpreter() interp.RegisterCoreCommands() - buf, err := ioutil.ReadFile(fname) + buf, err := io.ReadFile(fname) if err == nil { result, err := interp.Eval(string(buf)) if err != nil { diff --git a/pkg/picol/picol_unused/main_test.go_unused b/pkg/picol/picol_unused/main_test.go_unused index 896671d..8efd72f 100644 --- a/pkg/picol/picol_unused/main_test.go_unused +++ b/pkg/picol/picol_unused/main_test.go_unused @@ -1,9 +1,9 @@ package main_test import ( - "io/ioutil" - "os" - "testing" + io "io" + os "os" + testing "testing" picol "github.com/dragonheim/gagent/pkg/picol/picol_unused" ) @@ -11,7 +11,7 @@ import ( func Test_RunPicol(t *testing.T) { // Create a temporary test file content := []byte("set a 5\nset b 7\n+ $a $b\n") - tmpfile, err := ioutil.TempFile("", "picol_test") + tmpfile, err := io.TempFile("", "picol_test") if err != nil { t.Fatalf("Error creating temporary test file: %v", err) } From 685a3eb16aa922000cb8c93ee5f074324a74d995 Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 23 Apr 2024 16:00:42 -0700 Subject: [PATCH 62/80] Updated to latest Go compiler and latest Alpine images. --- .drone.yml | 118 --------------------------------------- assets/docker/Dockerfile | 6 +- go.mod | 23 ++++---- go.sum | 52 +++++++++-------- 4 files changed, 44 insertions(+), 155 deletions(-) delete mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 07dbb89..0000000 --- a/.drone.yml +++ /dev/null @@ -1,118 +0,0 @@ ---- -kind: pipeline -type: docker -name: validation - -platform: - arch: amd64 - -clone: - depth: 1 - -volumes: - - name: dockersock - host: - path: /run/docker.sock - -steps: - - name: Notify Datadog That We Are Starting - image: masci/drone-datadog - settings: - api_key: - from_secret: Datadog - events: - - title: "Begin Build: ${DRONE_REPO}" - text: "Build ${DRONE_BUILD_NUMBER}(${DRONE_COMMIT_LINK})" - alert_type: "info" - when: - ref: - include: - - refs/tags/** - - - name: Validate code base and dependencies - image: dragonheim/golang:latest - volumes: - - name: dockersock - path: /var/run/docker.sock - environment: - TRIVY_QUIET: true - TRIVY_LIGHT: true - TRIVY_FORMAT: table - TRIVY_IGNORE_UNFIXED: true - TRIVY_NO_PROGRESS: true - commands: - # Populate temporary container with tools / files we will need for building and testing - - apk add --no-cache zeromq-dev zeromq - - # Format Golang code. Golang does not really care about formatting, but this standardizes things - - go fmt ./... - - # Perform basic linting of the Golang code. Ideally this should never be needed, but merges can introduce imcompatabilities. - - go vet ./... - - # Perform code security check of lower level vulnerabilities. This will not break the build, we just want this information, just in case. - - trivy fs --exit-code 0 --severity UNKNOWN,LOW,MEDIUM . - - # Perform code security check of higher level vulnerabilities. This can break the build. - - trivy fs --skip-update --exit-code 1 --severity CRITICAL,HIGH . - - # Build new container image. - - docker buildx build --platform linux/amd64 --progress plain --build-arg SEMVER="dev" -t "${DRONE_REPO}:dev" -f assets/docker/Dockerfile . - - # Perform image security check of lower level vulnerabilities. This will not break the build, we just want this information, just in case. - - trivy image --skip-update --exit-code 0 --severity UNKNOWN,LOW,MEDIUM,HIGH "${DRONE_REPO}:dev" - - # Perform image security check of higher level vulnerabilities. This can break the build. - - trivy image --skip-update --exit-code 1 --severity CRITICAL "${DRONE_REPO}:dev" - - # - name: Create Test Environment - # image: dragonheim/terraform:1.0 - # volumes: - # - name: dockersock - # path: /var/run/docker.sock - # environment: - # TRIVY_QUIET: true - # commands: - # - cd assets/tfenv - # - terraform init - # - terraform plan - - - name: Test application - image: "${DRONE_REPO}:dev" - volumes: - - name: dockersock - path: /var/run/docker.sock - commands: - - echo "running" - - - name: Build and push container - image: dragonheim/golang:latest - volumes: - - name: dockersock - path: /var/run/docker.sock - when: - ref: - include: - - refs/tags/** - commands: - # Build new container image. - - docker buildx build --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER}" -t "${DRONE_REPO}:latest" -f docker/Dockerfile . - - # Perform image security check of higher level vulnerabilities. This can break the build. - - trivy image --skip-update --exit-code 1 --severity CRITICAL "${DRONE_REPO}:latest" - - # Push new build - - docker buildx build --push --platform linux/amd64 --progress plain --build-arg SEMVER="${DRONE_SEMVER}" -t "${DRONE_REPO}:latest" -t "${DRONE_REPO}:${DRONE_SEMVER}" -f docker/Dockerfile . - - - name: Notify Datadog That We Have Completed - image: masci/drone-datadog - settings: - api_key: - from_secret: Datadog - events: - - title: "Build failure on amd64" - text: "Build ${DRONE_BUILD_NUMBER}" - alert_type: "error" - when: - status: - - failure diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index f652599..fe856bd 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,5 +1,5 @@ -FROM dragonheim/golang:1.20 as builder -ARG SEMVER=${SEMVER:-0.0.9} +FROM dragonheim/golang:1.22 as builder +ARG SEMVER=${SEMVER:-0.0.11} WORKDIR /gagent COPY . . @@ -12,7 +12,7 @@ RUN apk add --no-cache zeromq-dev build-base git RUN go build -o /gagent/bin/gagent -ldflags "-X main.semVER=${SEMVER}" cmd/gagent/main.go RUN strip /gagent/bin/gagent -FROM alpine:3.17 +FROM alpine:3.19 ARG SEMVER LABEL Name="G'Agent" LABEL Maintainer="jwells@dragonheim.net" diff --git a/go.mod b/go.mod index a9a36dc..eec5387 100644 --- a/go.mod +++ b/go.mod @@ -7,31 +7,34 @@ require ( github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a github.com/caarlos0/env/v6 v6.10.1 github.com/carlmjohnson/versioninfo v0.22.5 - github.com/hashicorp/hcl/v2 v2.19.1 + github.com/hashicorp/hcl/v2 v2.20.1 github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 - github.com/pebbe/zmq4 v1.2.10 - github.com/prometheus/client_golang v1.18.0 + github.com/pebbe/zmq4 v1.2.11 + github.com/prometheus/client_golang v1.19.0 github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae github.com/stretchr/testify v1.8.4 - github.com/zclconf/go-cty v1.14.2 + github.com/zclconf/go-cty v1.14.4 ) require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/kr/text v0.2.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.46.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect - golang.org/x/sys v0.17.0 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.53.0 // indirect + github.com/prometheus/procfs v0.14.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.32.0 // indirect + golang.org/x/tools v0.20.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 8fcadd8..0d212df 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,8 @@ github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/I github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= github.com/carlmjohnson/versioninfo v0.22.5 h1:O00sjOLUAFxYQjlN/bzYTuZiS0y6fWDQjMRvwtKgwwc= github.com/carlmjohnson/versioninfo v0.22.5/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -21,8 +21,8 @@ github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= -github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/hashicorp/hcl/v2 v2.20.1 h1:M6hgdyz7HYt1UN9e61j+qKJBqR3orTWbI1HKBJEdxtc= +github.com/hashicorp/hcl/v2 v2.20.1/go.mod h1:TZDqQ4kNKCbh1iJp99FdPiUaVDDUPivbqxZulxDYqL4= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= @@ -31,38 +31,42 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/pebbe/zmq4 v1.2.10 h1:wQkqRZ3CZeABIeidr3e8uQZMMH5YAykA/WN0L5zkd1c= -github.com/pebbe/zmq4 v1.2.10/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= +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.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= -github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= -github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= -github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +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.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= +github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= +github.com/prometheus/procfs v0.14.0 h1:Lw4VdGGoKEZilJsayHf0B+9YgLGREba2C6xr+Fdfq6s= +github.com/prometheus/procfs v0.14.0/go.mod h1:XL+Iwz8k8ZabyZfMFHPiilCniixqQarAy5Mu67pHlNQ= 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/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= 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/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI= -github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= +github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= From 21a439b1058c185a842a00c4594eb14814caed9f Mon Sep 17 00:00:00 2001 From: James Wells Date: Wed, 24 Apr 2024 13:48:35 -0700 Subject: [PATCH 63/80] Updated devcontainer. --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2b04db0..906cd89 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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.20" +ARG VARIANT="1.22" FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} COPY --from=aquasec/trivy:0.38.3 /usr/local/bin/trivy /usr/bin/trivy diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index fb4ed8a..27a63e7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,7 @@ // 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.20-bullseye", + "VARIANT": "1.22-bookworm", // Options "NODE_VERSION": "none" } @@ -23,14 +23,18 @@ "go.goroot": "/usr/local/go" }, - // Add the IDs of extensions you want installed when the container is created. + // Use the same extensions we had on Gitpod plus HCL support. "extensions": [ + "editorconfig.editorconfig", + "dbaeumer.vscode-eslint", "golang.Go", - "GitHub.copilot", - "GitHub.vscode-pull-request-github", - "wholroyd.hcl", + "stylelint.vscode-stylelint", + "DavidAnson.vscode-markdownlint", + "Vue.volar", + "ms-azuretools.vscode-docker", + "vitest.explorer", "GitHub.vscode-pull-request-github", - "hashicorp.terraform" + "wholroyd.hcl" ], // Use 'forwardPorts' to make a list of ports inside the container available locally. @@ -40,16 +44,20 @@ // Use 'portsAttributes' to set default properties for specific forwarded ports. More info: https://code.visualstudio.com/docs/remote/devcontainerjson-reference. "portsAttributes": { "9101": { - "label": "Prometheus" + "label": "Prometheus", + "onAutoForward": "notify" }, "35570": { - "label": "Router To Router" + "label": "Router To Router", + "onAutoForward": "notify" }, "35571": { - "label": "Worker To Router" + "label": "Worker To Router", + "onAutoForward": "notify" }, "35572": { - "label": "Client To Router" + "label": "Client To Router", + "onAutoForward": "notify" } }, From 823a16a97b1ca4f9291ac8313b2aace3b9dccf2b Mon Sep 17 00:00:00 2001 From: James Wells Date: Wed, 10 Jul 2024 13:46:49 -0700 Subject: [PATCH 64/80] Updated Golang and Alpine versions. --- assets/docker/Dockerfile | 2 +- go.mod | 23 ++++++++++---------- go.sum | 46 +++++++++++++++++++++------------------- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index fe856bd..5031819 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -12,7 +12,7 @@ RUN apk add --no-cache zeromq-dev build-base git RUN go build -o /gagent/bin/gagent -ldflags "-X main.semVER=${SEMVER}" cmd/gagent/main.go RUN strip /gagent/bin/gagent -FROM alpine:3.19 +FROM alpine:3.20 ARG SEMVER LABEL Name="G'Agent" LABEL Maintainer="jwells@dragonheim.net" diff --git a/go.mod b/go.mod index eec5387..d9f8bf6 100644 --- a/go.mod +++ b/go.mod @@ -1,19 +1,19 @@ module github.com/dragonheim/gagent -go 1.21 +go 1.22 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/carlmjohnson/versioninfo v0.22.5 - github.com/hashicorp/hcl/v2 v2.20.1 + github.com/hashicorp/hcl/v2 v2.21.0 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.19.0 + github.com/prometheus/client_golang v1.19.1 github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/zclconf/go-cty v1.14.4 ) @@ -26,15 +26,16 @@ require ( github.com/google/go-cmp v0.6.0 // indirect github.com/kr/text v0.2.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect + 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.53.0 // indirect - github.com/prometheus/procfs v0.14.0 // indirect - golang.org/x/mod v0.17.0 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect + golang.org/x/mod v0.19.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.20.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect + golang.org/x/tools v0.23.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 0d212df..c485511 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,8 @@ github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.20.1 h1:M6hgdyz7HYt1UN9e61j+qKJBqR3orTWbI1HKBJEdxtc= -github.com/hashicorp/hcl/v2 v2.20.1/go.mod h1:TZDqQ4kNKCbh1iJp99FdPiUaVDDUPivbqxZulxDYqL4= +github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= +github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= @@ -33,40 +33,42 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= 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.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= -github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= 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.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= -github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= -github.com/prometheus/procfs v0.14.0 h1:Lw4VdGGoKEZilJsayHf0B+9YgLGREba2C6xr+Fdfq6s= -github.com/prometheus/procfs v0.14.0/go.mod h1:XL+Iwz8k8ZabyZfMFHPiilCniixqQarAy5Mu67pHlNQ= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +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/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +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.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +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.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= -golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= From 9727822b8a9f03eb8b6de87e40573f12ebcecc3f Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 6 Sep 2024 06:59:19 -0700 Subject: [PATCH 65/80] Very preliminary CI/CD pipeline to see if I need to manually pull the code. --- .forgejo/workflows/build.yaml | 13 +++ assets/docker/Dockerfile | 2 +- cmd/gagent/main_test.go | 160 ++++++++++++++++++++++------------ go.mod | 19 ++-- go.sum | 36 ++++---- 5 files changed, 149 insertions(+), 81 deletions(-) create mode 100644 .forgejo/workflows/build.yaml diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml new file mode 100644 index 0000000..6e23e77 --- /dev/null +++ b/.forgejo/workflows/build.yaml @@ -0,0 +1,13 @@ +name: Build G'Agent +on: [push] +jobs: + trivy_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 diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index 5031819..2a28e33 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM dragonheim/golang:1.22 as builder +FROM dragonheim/golang:1.23 as builder ARG SEMVER=${SEMVER:-0.0.11} WORKDIR /gagent diff --git a/cmd/gagent/main_test.go b/cmd/gagent/main_test.go index 3efdb37..7c46d12 100644 --- a/cmd/gagent/main_test.go +++ b/cmd/gagent/main_test.go @@ -1,70 +1,120 @@ package main import ( - os "os" - testing "testing" + "bytes" + "log" + "net/http" + "net/http/httptest" + "os" + "testing" - // main "github.com/dragonheim/gagent/cmd/gagent" + env "github.com/caarlos0/env/v6" gstructs "github.com/dragonheim/gagent/internal/gstructs" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" ) -// This function will create a temporary config file for testing purposes -func createTestConfigFile() (string, error) { - tmpfile, err := os.CreateTemp("", "test_config_*.hcl") - if err != nil { - return "", err - } - - content := []byte(`mode = "setup" -listen_addr = "0.0.0.0" -monitor_port = 8888 -client_port = 35572 -router_port = 35570 -worker_port = 35571 -`) - if _, err := tmpfile.Write(content); err != nil { - return "", err - } - if err := tmpfile.Close(); err != nil { - return "", err - } - - return tmpfile.Name(), nil +// Mocking the WaitGroup to avoid actually waiting in tests +type MockWaitGroup struct { + mock.Mock } -func TestMain(t *testing.T) { - t.Run("Test setup mode with temp config file", func(t *testing.T) { - tmpConfig, err := createTestConfigFile() - if err != nil { - t.Fatalf("Failed to create temp config file: %v", err) - } - defer os.Remove(tmpConfig) +func (m *MockWaitGroup) Add(delta int) { + m.Called(delta) +} - config := gstructs.GagentConfig{ - File: tmpConfig, - Mode: "setup", - } +func (m *MockWaitGroup) Done() { + m.Called() +} - // Run the main function with the temporary config - t.Run(config) +func (m *MockWaitGroup) Wait() { + m.Called() +} - // Check if the config has been set up correctly - expectedConfig := gstructs.GagentConfig{ - Mode: "setup", - ListenAddr: "0.0.0.0", - MonitorPort: 8888, - ClientPort: 35572, - RouterPort: 35570, - WorkerPort: 35571, - } +// Mocking the config loader function to inject test configurations +func mockInitConfig() { + config = gstructs.GagentConfig{ + Mode: "client", + MonitorPort: 8080, + // Populate other required fields as needed + } +} - if config.Mode != expectedConfig.Mode || - config.ListenAddr != expectedConfig.ListenAddr || - config.MonitorPort != expectedConfig.MonitorPort || - config.ClientPort != expectedConfig.ClientPort || - config.RouterPort != expectedConfig.RouterPort || - config.WorkerPort != expectedConfig.WorkerPort { - t.Fatalf("Expected config %+v, got %+v", expectedConfig, config) - } +func TestMainFunction(t *testing.T) { + var wg MockWaitGroup + wg.On("Add", 1).Return() + wg.On("Wait").Return() + wg.On("Done").Return() + + mockInitConfig() + + // Test the client mode + config.Mode = "client" + main() + wg.AssertCalled(t, "Add", 1) + + // Test the router mode + config.Mode = "router" + main() + wg.AssertCalled(t, "Add", 1) + + // Test the worker mode + config.Mode = "worker" + main() + wg.AssertCalled(t, "Add", 1) + + // Test the setup mode + config.Mode = "setup" + main() + wg.AssertCalled(t, "Add", 1) + + // Test an invalid mode + config.Mode = "invalid" + assert.Panics(t, func() { main() }, "Expected main() to panic with invalid mode") +} + +func TestInitFunction(t *testing.T) { + // Backup original stdout and defer restoration + origStdout := os.Stdout + defer func() { os.Stdout = origStdout }() + + // Capture stdout output to test log output + var logOutput bytes.Buffer + log.SetOutput(&logOutput) + + // Test init + init() + + // Assertions + assert.Contains(t, logOutput.String(), "[DEBUG] Arguments are") + assert.NotEmpty(t, config.Version, "Config version should not be empty") + assert.NotEmpty(t, config.UUID, "Config UUID should not be empty") +} + +func TestPrometheusMetricsExporter(t *testing.T) { + mockInitConfig() + config.MonitorPort = 8080 + + req, err := http.NewRequest("GET", "/metrics", nil) + assert.NoError(t, err) + + rr := httptest.NewRecorder() + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.DefaultServeMux.ServeHTTP(w, r) }) + handler.ServeHTTP(rr, req) + + assert.Equal(t, http.StatusOK, rr.Code, "Handler returned wrong status code") + assert.Contains(t, rr.Body.String(), "go_gc_duration_seconds", "Expected metrics output") +} + +func TestEnvironmentParsing(t *testing.T) { + cfg := environment + err := env.Parse(&cfg) + assert.NoError(t, err) + + assert.Equal(t, "/etc/gagent/gagent.hcl", cfg.ConfigFile, "Expected default config file path") + assert.Equal(t, "WARN", cfg.LogLevel, "Expected default log level") + assert.Equal(t, "setup", cfg.Mode, "Expected default mode") + assert.Equal(t, 0, cfg.MonitorPort, "Expected default monitor port") } diff --git a/go.mod b/go.mod index d9f8bf6..a12bdf5 100644 --- a/go.mod +++ b/go.mod @@ -1,20 +1,20 @@ module github.com/dragonheim/gagent -go 1.22 +go 1.23 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/carlmjohnson/versioninfo v0.22.5 - github.com/hashicorp/hcl/v2 v2.21.0 + github.com/hashicorp/hcl/v2 v2.22.0 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.19.1 + github.com/prometheus/client_golang v1.20.2 github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae github.com/stretchr/testify v1.9.0 - github.com/zclconf/go-cty v1.14.4 + github.com/zclconf/go-cty v1.15.0 ) require ( @@ -24,6 +24,7 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/klauspost/compress v1.17.9 // indirect github.com/kr/text v0.2.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -31,11 +32,11 @@ require ( github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect - golang.org/x/mod v0.19.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.23.0 // indirect + golang.org/x/mod v0.20.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/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 c485511..703cde5 100644 --- a/go.sum +++ b/go.sum @@ -21,16 +21,20 @@ github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= -github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= +github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M= +github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= @@ -39,8 +43,8 @@ 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.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +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_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= @@ -53,20 +57,20 @@ github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae h1:hnJJroq/koox github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae/go.mod h1:p+QQKBy7tS+myk+y3sgnAKx4gUtD/Q9Z6KEd77cLzWY= 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.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= -github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +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.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= -golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= -golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= +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/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/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= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 44033c273aed02375cb8996deb1b19b002679183 Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 12 Sep 2024 18:53:59 -0700 Subject: [PATCH 66/80] 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= From f2b2cc705c6019012c7de2341d5188ca28823daa Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 12 Sep 2024 19:41:30 -0700 Subject: [PATCH 67/80] Actions not running on Forgjo. --- .forgejo/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index c3ed466..3581ac3 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -1,5 +1,5 @@ name: G'Agent Scan, Build, and Test -on: [push] +# on: [push] jobs: scan: runs-on: docker From 9e167cdefe006347804bf0ec3ad68bcb8a2db50a Mon Sep 17 00:00:00 2001 From: James Wells Date: Sun, 15 Sep 2024 19:09:07 -0700 Subject: [PATCH 68/80] Rework of the actions. --- .forgejo/workflows/build.yaml | 63 ++++++++++++++++++++++++++++------- README.md | 2 +- cmd/gagent/main.go | 35 ++++++++++--------- 3 files changed, 72 insertions(+), 28 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 3581ac3..09cb9fa 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -1,5 +1,14 @@ name: G'Agent Scan, Build, and Test -# on: [push] +on: + push: + branches: + - main + - releases/** + tags: + - v* + +env: + SEMVAR: 0.0.11 jobs: scan: runs-on: docker @@ -8,26 +17,56 @@ jobs: steps: - 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 . + + - uses: actions/cache@v4 + with: + path: .cache/trivy + key: tmp.woDBBj4Baw + + - run: /usr/local/bin/trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . - run: /usr/local/bin/gosec -quiet ./... - - build: + + build_simple: 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 + - run: apk add --no-cache zeromq-dev nodejs npm - uses: actions/checkout@v4 - - run: go build -o gagent cmd/gagent/main.go - - run: ./gagent --version + - run: go build -o test_artifact cmd/hello/main.go + - run: ./test_artifact --version - uses: actions/upload-artifact@v3 with: - name: gagent - path: gagent \ No newline at end of file + name: test_artifact + path: test_artifact + + test_simple: + needs: build_simple + runs-on: docker + container: + image: dragonheim/golang:latest + steps: + - run: apk add --no-cache nodejs npm + - uses: actions/download-artifact@v3 + with: + name: test_artifact + + - run: chmod a+x test_artifact + - run: ./test_artifact --version + + build_image: + needs: test_simple + runs-on: docker + container: + image: dragonheim/golang:latest + steps: + - run: apk add --no-cache zeromq-dev nodejs npm + + - uses: actions/checkout@v4 + + - run: echo "${{ secrets.DOCKER_LOGIN }}" | docker login -u dragonheim2024 --password-stdin + - run: docker buildx build --push -t dragonheim/gagent:test -f assets/docker/Dockerfile --build-arg SEMVER=${{ env.SEMVAR }} . diff --git a/README.md b/README.md index 42acc46..4ebdb37 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/dragonheim/gagent)](https://goreportcard.com/report/github.com/dragonheim/gagent) [![Docker Pulls](https://img.shields.io/docker/pulls/dragonheim/gagent)](https://hub.docker.com/r/dragonheim/gagent/tags?page=1&ordering=last_updated) -A Golang based mobile agent system loosely inspired by the [Agent Tcl / D'Agents](http://www.cs.dartmouth.edu/~dfk/agents/) system created by Robert S. Gray of Dartmouth college. +A Golang based mobile agent system loosely inspired by the [Agent Tcl / D'Agents](https://digitalcommons.dartmouth.edu/dissertations/62/) system created by Robert S. Gray of Dartmouth college. Please note that this program is mostly meant to be used as a tool for me to learn software development in Go, and is not meant to be used in production environments. diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index aea381b..db660c2 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -37,16 +37,17 @@ import ( /* * Exit Codes * 0 Success - * 1 Configuration file is missing or unreadable - * 2 Setup failed - * 3 Invalid mode of operation - * 4 Agent file is missing or unreadable - * 5 Agent is missing tags - * 6 No routers defined - * 7 No workers defined - * 8 Agent not defined - * 9 Agent hints / tags not defined - * 10 Router not connected + * 1 Environment variable parsing failed + * 2 Configuration file is missing or unreadable + * 3 Setup failed + * 4 Invalid mode of operation + * 5 Agent file is missing or unreadable + * 6 Agent is missing tags + * 7 No routers defined + * 8 No workers defined + * 9 Agent not defined + * 10 Agent hints / tags not defined + * 11 Router not connected */ var environment struct { @@ -80,7 +81,7 @@ func main() { if len(config.Routers) == 0 { log.Printf("[ERROR] No routers defined.\n") - os.Exit(6) + os.Exit(7) } wg.Add(1) @@ -116,7 +117,7 @@ func main() { default: log.Printf("[ERROR] Unknown operating mode, exiting.\n") - os.Exit(3) + os.Exit(4) } wg.Wait() @@ -132,7 +133,11 @@ func init() { versioninfo.AddFlag(nil) flag.Parse() cfg := environment - env.Parse(&cfg) + err := env.Parse(&cfg) + if err != nil { + log.Printf("[ERROR] Failed to parse environment variables: %s\n", err) + os.Exit(1) + } filter := &logutils.LevelFilter{ Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"}, @@ -251,10 +256,10 @@ func init() { config.File = opts["--config"].(string) } - err := hclsimple.DecodeFile(config.File, nil, &config) + err = hclsimple.DecodeFile(config.File, nil, &config) if err != nil && opts["setup"] == false { log.Printf("[ERROR] Failed to load configuration file: %s.\n", config.File) - os.Exit(1) + os.Exit(2) } /* From 9a897458787ca6f04eef3debaf61289707ff0855 Mon Sep 17 00:00:00 2001 From: James Wells Date: Sun, 15 Sep 2024 19:12:06 -0700 Subject: [PATCH 69/80] Removing unused pathing. --- .forgejo/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 09cb9fa..a7b4863 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -23,8 +23,8 @@ jobs: path: .cache/trivy key: tmp.woDBBj4Baw - - run: /usr/local/bin/trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . - - run: /usr/local/bin/gosec -quiet ./... + - run: trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . + - run: gosec -quiet ./... build_simple: needs: scan From df07f6be280a5e305acbbfe9a6b683304b06f88a Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 26 Dec 2024 13:49:09 -0800 Subject: [PATCH 70/80] Attempting to fix security scan. --- .forgejo/workflows/build.yaml | 4 ++-- cmd/gagent/main.go | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index a7b4863..11238a0 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -15,7 +15,7 @@ jobs: container: image: dragonheim/golang:latest steps: - - run: apk add --no-cache nodejs npm + - run: apk add --no-cache zeromq-dev nodejs npm - uses: actions/checkout@v4 - uses: actions/cache@v4 @@ -24,7 +24,7 @@ jobs: key: tmp.woDBBj4Baw - run: trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . - - run: gosec -quiet ./... + # - run: gosec -quiet ./... build_simple: needs: scan diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index db660c2..c7e4db2 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,6 +1,7 @@ package main import ( + debug "runtime/debug" flag "flag" log "log" http "net/http" @@ -31,7 +32,7 @@ import ( uuid "github.com/jakehl/goid" - versioninfo "github.com/carlmjohnson/versioninfo" + //versioninfo "github.com/carlmjohnson/versioninfo" ) /* @@ -130,7 +131,7 @@ func main() { * reads the environment variables. It also sets up the logging. */ func init() { - versioninfo.AddFlag(nil) + // versioninfo.AddFlag(nil) flag.Parse() cfg := environment err := env.Parse(&cfg) @@ -151,7 +152,8 @@ func init() { /* * Initialize the configuration */ - config.Version = versioninfo.Version + config.Version, err = debug.ReadBuildInfo() + // config.Version = versioninfo.Version config.File = cfg.ConfigFile @@ -307,5 +309,4 @@ func init() { } autorestart.WatchFilename = config.File autorestart.StartWatcher() - } From 91c591e22f0d20afa321ef584dedab0157157ab9 Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 26 Dec 2024 14:30:23 -0800 Subject: [PATCH 71/80] Fixing a compliation error and possibly versioning. --- .forgejo/workflows/build.yaml | 4 ++-- cmd/gagent/main.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 11238a0..523741c 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -36,7 +36,7 @@ jobs: - uses: actions/checkout@v4 - - run: go build -o test_artifact cmd/hello/main.go + - run: go build -o test_artifact cmd/gagent/main.go - run: ./test_artifact --version - uses: actions/upload-artifact@v3 @@ -50,7 +50,7 @@ jobs: container: image: dragonheim/golang:latest steps: - - run: apk add --no-cache nodejs npm + - run: apk add --no-cache zeromq-dev nodejs npm - uses: actions/download-artifact@v3 with: name: test_artifact diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index c7e4db2..ac0191b 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,11 +1,11 @@ package main import ( - debug "runtime/debug" flag "flag" log "log" http "net/http" os "os" + debug "runtime/debug" strconv "strconv" sync "sync" @@ -31,7 +31,6 @@ import ( promhttp "github.com/prometheus/client_golang/prometheus/promhttp" uuid "github.com/jakehl/goid" - //versioninfo "github.com/carlmjohnson/versioninfo" ) @@ -152,7 +151,8 @@ func init() { /* * Initialize the configuration */ - config.Version, err = debug.ReadBuildInfo() + buildInfo, _ := debug.ReadBuildInfo() + config.Version = buildInfo.Main.Version // config.Version = versioninfo.Version config.File = cfg.ConfigFile @@ -228,7 +228,7 @@ func init() { usage += "Options:\n" usage += " -h, --help -- Show this help screen and exit\n" - usage += " -v, -version -- Show version 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" From 8cb31d2fbc1fa8a77d1ed03ff510d4b7e9bc12bf Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 26 Dec 2024 14:35:17 -0800 Subject: [PATCH 72/80] DOH!!! Accidentally commented out the gosec check. --- .forgejo/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 523741c..9bc30fb 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -24,7 +24,7 @@ jobs: key: tmp.woDBBj4Baw - run: trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . - # - run: gosec -quiet ./... + - run: gosec -quiet ./... build_simple: needs: scan From 01e3c42ac437f2a66a3d2af222cbc7e292e211cd Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 26 Dec 2024 15:36:38 -0800 Subject: [PATCH 73/80] Attempting to ignore a known weakness. --- .forgejo/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 9bc30fb..fc725c0 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -24,7 +24,7 @@ jobs: key: tmp.woDBBj4Baw - run: trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . - - run: gosec -quiet ./... + - run: gosec -exclude=G114 -quiet ./... build_simple: needs: scan From 07215828b8b1f618e60efb922f42a6048c86fcc2 Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 26 Dec 2024 18:01:37 -0800 Subject: [PATCH 74/80] Think I fixed the versioning. --- .forgejo/workflows/build.yaml | 4 ++-- cmd/gagent/main.go | 14 ++++++-------- cmd/gagent/main_test.go | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index fc725c0..3a063af 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -8,7 +8,7 @@ on: - v* env: - SEMVAR: 0.0.11 + SEMVAR: 0.0.13 jobs: scan: runs-on: docker @@ -36,7 +36,7 @@ jobs: - uses: actions/checkout@v4 - - run: go build -o test_artifact cmd/gagent/main.go + - run: go build -o test_artifact -ldflags="-X main.Version=${{ env.SEMVAR }}" cmd/gagent/main.go - run: ./test_artifact --version - uses: actions/upload-artifact@v3 diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index ac0191b..fb55f87 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -1,11 +1,9 @@ package main import ( - flag "flag" log "log" http "net/http" os "os" - debug "runtime/debug" strconv "strconv" sync "sync" @@ -31,7 +29,6 @@ import ( promhttp "github.com/prometheus/client_golang/prometheus/promhttp" uuid "github.com/jakehl/goid" - //versioninfo "github.com/carlmjohnson/versioninfo" ) /* @@ -68,6 +65,11 @@ var config gstructs.GagentConfig */ var wg sync.WaitGroup +/* + * Set version + */ +var Version = "0.0.11" + /* * This is the main function, and it assumes that the configuration file has * already been read and parsed by the init() function. @@ -130,8 +132,6 @@ func main() { * reads the environment variables. It also sets up the logging. */ func init() { - // versioninfo.AddFlag(nil) - flag.Parse() cfg := environment err := env.Parse(&cfg) if err != nil { @@ -151,9 +151,7 @@ func init() { /* * Initialize the configuration */ - buildInfo, _ := debug.ReadBuildInfo() - config.Version = buildInfo.Main.Version - // config.Version = versioninfo.Version + config.Version = Version config.File = cfg.ConfigFile diff --git a/cmd/gagent/main_test.go b/cmd/gagent/main_test.go index 7c46d12..1e030a9 100644 --- a/cmd/gagent/main_test.go +++ b/cmd/gagent/main_test.go @@ -83,7 +83,7 @@ func TestInitFunction(t *testing.T) { log.SetOutput(&logOutput) // Test init - init() + // init() #@TODO Write a useful test for init // Assertions assert.Contains(t, logOutput.String(), "[DEBUG] Arguments are") From 4717b49701a6a76fe264c7956ce8fd11fda7a2df Mon Sep 17 00:00:00 2001 From: James Wells Date: Thu, 26 Dec 2024 18:26:41 -0800 Subject: [PATCH 75/80] Version is not propagating on CI/CD build. --- assets/docker/Dockerfile | 2 +- cmd/gagent/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/docker/Dockerfile b/assets/docker/Dockerfile index 2a28e33..cf3606b 100644 --- a/assets/docker/Dockerfile +++ b/assets/docker/Dockerfile @@ -9,7 +9,7 @@ ARG GOOS=${GOOS:-linux} ARG CGO_ENABLED=1 RUN apk add --no-cache zeromq-dev build-base git -RUN go build -o /gagent/bin/gagent -ldflags "-X main.semVER=${SEMVER}" cmd/gagent/main.go +RUN go build -o /gagent/bin/gagent -ldflags "-X main.Version=${SEMVER}" cmd/gagent/main.go RUN strip /gagent/bin/gagent FROM alpine:3.20 diff --git a/cmd/gagent/main.go b/cmd/gagent/main.go index fb55f87..196abf1 100644 --- a/cmd/gagent/main.go +++ b/cmd/gagent/main.go @@ -68,7 +68,7 @@ var wg sync.WaitGroup /* * Set version */ -var Version = "0.0.11" +var Version = "0.0.1" /* * This is the main function, and it assumes that the configuration file has From 8c664dd00701ef384596180a10045b8e6b4f94a4 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 27 Dec 2024 16:09:19 -0800 Subject: [PATCH 76/80] Moving gosec install to here instead of the tool image. --- .forgejo/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 3a063af..555242f 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -15,7 +15,8 @@ jobs: container: image: dragonheim/golang:latest steps: - - run: apk add --no-cache zeromq-dev nodejs npm + - run: apk add --no-cache curl gpg zeromq-dev nodejs npm + - run: curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s - uses: actions/checkout@v4 - uses: actions/cache@v4 From ed8a3a27e315fe6a184d1601703086f01d35ecbe Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 27 Dec 2024 16:14:09 -0800 Subject: [PATCH 77/80] Gosec installed in a different location. --- .forgejo/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 555242f..7de1f21 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -25,7 +25,7 @@ jobs: key: tmp.woDBBj4Baw - run: trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . - - run: gosec -exclude=G114 -quiet ./... + - run: ./gosec -exclude=G114 -quiet ./... build_simple: needs: scan From 6b8f83bd27d63e8215b24a210f62521b3a7bd4db Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 27 Dec 2024 16:17:06 -0800 Subject: [PATCH 78/80] Gosec installed in a different location. --- .forgejo/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 7de1f21..5c90498 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -25,7 +25,7 @@ jobs: key: tmp.woDBBj4Baw - run: trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . - - run: ./gosec -exclude=G114 -quiet ./... + - run: ./bin/gosec -exclude=G114 -quiet ./... build_simple: needs: scan From e1c359639b4d8b6b69a88e3ed5658ef992921f7b Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 27 Dec 2024 16:29:04 -0800 Subject: [PATCH 79/80] Not sure why I used ./bin/... DOH!!! --- .forgejo/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 5c90498..881a90d 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -24,8 +24,8 @@ jobs: path: .cache/trivy key: tmp.woDBBj4Baw - - run: trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . - - run: ./bin/gosec -exclude=G114 -quiet ./... + - run: /go/bin/trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . + - run: /go/bin/gosec -exclude=G114 -quiet ./... build_simple: needs: scan From 48c0bc85377b506c98c23934ebff98a90e308c28 Mon Sep 17 00:00:00 2001 From: James Wells Date: Sat, 28 Dec 2024 11:05:51 -0800 Subject: [PATCH 80/80] Rolling back gosec check to tool image. --- .forgejo/workflows/build.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 881a90d..3a063af 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -15,8 +15,7 @@ jobs: container: image: dragonheim/golang:latest steps: - - run: apk add --no-cache curl gpg zeromq-dev nodejs npm - - run: curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s + - run: apk add --no-cache zeromq-dev nodejs npm - uses: actions/checkout@v4 - uses: actions/cache@v4 @@ -24,8 +23,8 @@ jobs: path: .cache/trivy key: tmp.woDBBj4Baw - - run: /go/bin/trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . - - run: /go/bin/gosec -exclude=G114 -quiet ./... + - run: trivy fs --no-progress --severity CRITICAL --cache-dir .cache/trivy --exit-code 1 . + - run: gosec -exclude=G114 -quiet ./... build_simple: needs: scan