From a7747040ce2d4bfd65bf9197a323d5c70b150f04 Mon Sep 17 00:00:00 2001 From: James Wells Date: Tue, 21 Sep 2021 07:08:52 -0700 Subject: [PATCH] [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.