diff --git a/.circleci/config.yml b/.circleci/config.yml index 2dc2dc0..757020a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 orbs: shared: getoutreach/shared@dev:first - queue: eddiewebb/queue@1.8.4 + queue: eddiewebb/queue@2.2.1 parameters: rebuild_cache: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 066c467..cde2158 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,6 +8,7 @@ updates: # stencil-golang managed dependencies ignore: - dependency-name: github.com/getoutreach/gobox + - dependency-name: github.com/getoutreach/stencil-golang/pkg - dependency-name: github.com/getoutreach/services - dependency-name: github.com/getoutreach/datastores/v2 - dependency-name: github.com/getoutreach/mint diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 1733746..b5f74de 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,16 +1,17 @@ +Please read [CONTRIBUTING.md](CONTRIBUTING.md) for additional information on contributing to this repository! ## What this PR does / why we need it - **JIRA ID**: XX-XX @@ -20,8 +21,6 @@ ## Notes for your reviewers - - diff --git a/.gitignore b/.gitignore index 032246f..e6bfd41 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,9 @@ Pulumi.*.yaml # Documentation output /apidocs +# Terraform lock files +.terraform.lock.hcl + ### Start ignores inserted by other modules ### End ignores inserted by other modules diff --git a/.tool-versions b/.tool-versions index c83d7bd..861ab9d 100644 --- a/.tool-versions +++ b/.tool-versions @@ -4,10 +4,10 @@ # you are reducing compatibility guarantees. ## <> ## <> -terraform 1.4.4 +golang 1.22.0 +nodejs 18.17.1 protoc 21.5 -nodejs 18.14.1 -golang 1.20.7 +terraform 1.5.7 # Note: Versions in this block do not override the default versions above # but sometimes you have to declare additional versions of the same tool # while leaving the 'default' version intact for the infra. diff --git a/.vscode/launch.json b/.vscode/launch.json index 327c1b7..a7a2a49 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -36,16 +36,16 @@ "to": "/home/dev/app" }, // Maps the go module cache on the host to the persistent volume used by devspaces. - // See the value of `go env GOMODCACHE` on the host and devspace. + // These should be the respective values of `go env GOMODCACHE`. { - "from": "${env:HOME}/.asdf/installs/golang/1.20.7/packages/pkg/mod", - "to": "/tmp/cache/go/mod/" + "from": "${env:HOME}/.asdf/installs/golang/1.22.0/packages/pkg/mod", + "to": "/home/dev/.asdf/installs/golang/1.22.0/packages/pkg/mod" }, { // Maps the standard library location on the host to the location in the devspace. // This enables debugging standard library code. - "from": "${env:HOME}/.asdf/installs/golang/1.20.7/go/src", - "to": "/home/dev/.asdf/installs/golang/1.20.7/go/src" + "from": "${env:HOME}/.asdf/installs/golang/1.22.0/go/src", + "to": "/home/dev/.asdf/installs/golang/1.22.0/go/src" } ] }, diff --git a/cortex.yaml b/cortex.yaml new file mode 100644 index 0000000..85f82f0 --- /dev/null +++ b/cortex.yaml @@ -0,0 +1,63 @@ +# Docs: https://docs.cortex.io/docs/reference/basics/entities#service-entities + +openapi: 3.0.0 +info: + title: lintroller + description: > + Lintroller houses all of the custom linters that Outreach uses for Go projects. + x-cortex-type: service + x-cortex-slack: + channels: + - name: dev-tooling-design + notificationsEnabled: false + - name: dev-tooling-support + notificationsEnabled: false + - name: dt-oncall + notificationsEnabled: true + - name: fnd-dt-alerts + notificationsEnabled: true + x-cortex-owners: + - type: group + name: fnd-dt + provider: CORTEX + x-cortex-tag: lintroller + x-cortex-git: + github: + repository: getoutreach/lintroller + x-cortex-oncall: + pagerduty: + id: P9HJAUT + type: SERVICE + x-cortex-link: + ## These are useful documentation links for this service. Please fill in the customLinks block if you have additional documentation links. + ## name: The name of the link + ## type: Choose one type from (dashboard,documentation,healthcheck,logs,metrics,runbook) + ## url: The link url + ## description(optional): Description to this link + - name: API Docs + type: api_documentation + url: https://engdocs.outreach.cloud/github.com/getoutreach/lintroller#section-readme + ## <> + ## <> + x-cortex-custom-metadata: + app: lintroller + name: lintroller + repo: https://github.com/getoutreach/lintroller + framework: stencil + language: Golang + stencil_version: v1.37.3 + golang_version: 1.22.0 + cli: false + service: false + product: Outreach + lifecycle: in_development + ## <> + ## <> + reporting_team: fnd-dt + lintroller: platinum + x-cortex-groups: + - lifecycle: in_development + - product: Outreach + - language: Golang + - framework: stencil + - engOrg: fnd diff --git a/go.mod b/go.mod index 8c1109f..9c7f2a2 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/getoutreach/lintroller go 1.19 require ( - github.com/getoutreach/gobox v1.73.2 + github.com/getoutreach/gobox v1.89.0 github.com/pkg/errors v0.9.1 - golang.org/x/tools v0.18.0 + golang.org/x/tools v0.19.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools/v3 v3.5.1 ) @@ -16,7 +16,7 @@ require ( ) require ( - github.com/google/go-cmp v0.5.9 // indirect - golang.org/x/mod v0.15.0 // indirect + github.com/google/go-cmp v0.6.0 // indirect + golang.org/x/mod v0.16.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) diff --git a/go.sum b/go.sum index b0383c2..b82276a 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/getoutreach/gobox v1.73.2 h1:LDTPzWHj37d/GsYCPJIHHais+f+7aUP8ZS9YuU+qJXU= -github.com/getoutreach/gobox v1.73.2/go.mod h1:Kx002WFAj+lUVqo7LLxSaQ1w2Mcqg1gefd+qQKr/QGM= -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/getoutreach/gobox v1.89.0 h1:wPuBGcFnFmyD0OdvZH/QkW86lNkp2sepfgOjjwUDsKU= +github.com/getoutreach/gobox v1.89.0/go.mod h1:w7K/e3SU+CWhu9KmnuRdXBHGWau4yE5dW5Tqb+MWZiU= +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/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -16,11 +16,11 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= -golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= 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-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/opslevel.yml b/opslevel.yml deleted file mode 100644 index cef782c..0000000 --- a/opslevel.yml +++ /dev/null @@ -1,54 +0,0 @@ -# yaml-language-server: $schema=https://app.opslevel.com/public/opslevel.schema.yml - -# Available options are listed here: https://app.opslevel.com/account -# To find the alias for a given lifecycle: https://www.opslevel.com/docs/api/opslevel-yml/#finding-the-alias-for-a-lifecycle -# To find the alias for a given tier: https://www.opslevel.com/docs/api/opslevel-yml/#finding-the-alias-for-a-tier -# More examples: https://opslevel.com/docs/api/opslevel-yml/#example-service-opslevelyml - -version: 1 -service: - name: lintroller - product: Outreach - owner: fnd-dt - language: Golang - framework: stencil - description: > - Lintroller houses all of the custom linters that Outreach uses for Go projects. - lifecycle: in_development - ## <> - - ## <> - aliases: - ## <> - - ## <> - - lintroller - tags: - ## <> - - ## <> - - key: repo - value: "https://github.com/getoutreach/lintroller" - - key: reporting_team - value: "fnd-dt" - - key: app - value: "lintroller" - - key: name - value: "lintroller" - - key: stencil_version - value: "v1.36.0" - - key: golang_version - value: "1.20.7" - - key: cli - value: "false" - - key: service - value: "false" - # This is necessary for filters in OpsLevel because we have to assume all things are - # services if they don't have the `service` tag. So we can guarantee this tag for - # bootstrapped CLIs/Libraries. - - key: notservice - value: "true" - repositories: - - name: getoutreach/lintroller - path: "/" - provider: github diff --git a/scripts/devbase.sh b/scripts/devbase.sh index 96980c4..2013ed4 100755 --- a/scripts/devbase.sh +++ b/scripts/devbase.sh @@ -6,6 +6,7 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" libDir="$DIR/../.bootstrap" lockfile="$DIR/../stencil.lock" serviceYaml="$DIR/../service.yaml" +gojqVersion="v0.12.14" # get_absolute_path returns the absolute path of a file get_absolute_path() { @@ -13,18 +14,67 @@ get_absolute_path() { "$python" -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$1" } -# get_field_from_yaml reads a field from a yaml file using either go-yq or python-yq -get_field_from_yaml() { - field="$1" - file="$2" +# gojq returns the path to a JIT-downloaded gojq binary. +gojq() { + set -uo pipefail - if [[ "$(yq e '.a' '-' <<<'{"a": "true"}' 2>&1)" == "true" ]]; then - # using golang version - yq e "$field" "$file" - else - # probably using python version - yq -r "$field" <"$file" + local gjDir + gjDir="${XDG_CACHE_HOME:-$HOME/.cache}/devbase/gojq" + local gojq="$gjDir/gojq-${gojqVersion}" + if [[ ! -x $gojq ]]; then + local platform arch + mkdir -p "$gjDir" + platform="$(uname -s | awk '{print tolower($0)}')" + arch="$(uname -m)" + case $arch in + x86_64) + arch=amd64 + ;; + aarch64) + arch=arm64 + ;; + esac + local basename="gojq_${gojqVersion}_${platform}_${arch}" + local ext + if [[ $platform == linux ]]; then + ext="tar.gz" + else + ext="zip" + fi + local archive="$basename.$ext" + + local gojqURL="https://github.com/itchyny/gojq/releases/download/$gojqVersion/$archive" + if [[ ! -e "$gjDir/$archive" ]]; then + curl --fail --location --silent --output "$gjDir/$archive" "$gojqURL" + + fi + + if [[ ! -e "$gjDir/$archive" ]]; then + echo "Failed to download gojq ($gojqURL)" >&2 + exit 1 + fi + + if [[ $ext == "zip" ]]; then + # Explanation of flags: + # quiet, junk paths/dont make directories, extract to directory + unzip -q -j -d "$gjDir" "$gjDir/$archive" "$basename/gojq" + else + tar --strip-components=1 --directory="$gjDir" --extract --file="$gjDir/$archive" "$basename/gojq" + fi + mv "$gjDir"/gojq "$gojq" fi + + echo "$gojq" + + set +uo pipefail +} + +# get_field_from_yaml reads a field from a yaml file via a JIT-downloaded gojq. +get_field_from_yaml() { + local field="$1" + local file="$2" + + "$(gojq)" --yaml-input -r "$field" <"$file" } # Use the version of devbase from stencil diff --git a/stencil.lock b/stencil.lock index ad79ff0..ea6ea5c 100644 --- a/stencil.lock +++ b/stencil.lock @@ -1,26 +1,26 @@ -version: v1.36.0 +version: v1.37.3 modules: - name: github.com/getoutreach/devbase url: https://github.com/getoutreach/devbase version: main - name: github.com/getoutreach/stencil-actions url: https://github.com/getoutreach/stencil-actions - version: v0.3.0 + version: v0.4.0 - name: github.com/getoutreach/stencil-base url: https://github.com/getoutreach/stencil-base - version: v0.12.0 + version: v0.15.1 - name: github.com/getoutreach/stencil-circleci url: https://github.com/getoutreach/stencil-circleci - version: v1.10.0 + version: v1.12.0 - name: github.com/getoutreach/stencil-discovery url: https://github.com/getoutreach/stencil-discovery - version: v1.8.0 + version: v1.8.2 - name: github.com/getoutreach/stencil-golang url: https://github.com/getoutreach/stencil-golang version: unstable - name: github.com/getoutreach/stencil-outreach url: https://github.com/getoutreach/stencil-outreach - version: v0.12.2 + version: v0.20.4 - name: github.com/getoutreach/stencil-pipeline url: https://github.com/getoutreach/stencil-pipeline version: v1.1.0 @@ -76,27 +76,21 @@ files: - name: .vscode/settings.json template: .vscode/settings.json.tpl module: github.com/getoutreach/stencil-golang - - name: CONTRIBUTING.md - template: CONTRIBUTING.md.tpl - module: github.com/getoutreach/stencil-base - name: LICENSE template: LICENSE.tpl module: github.com/getoutreach/stencil-base - name: Makefile template: Makefile.tpl module: github.com/getoutreach/stencil-golang - - name: README.md - template: README.md.tpl - module: github.com/getoutreach/stencil-base + - name: cortex.yaml + template: cortex.yaml.tpl + module: github.com/getoutreach/stencil-outreach - name: devenv.yaml template: devenv.yaml.tpl module: github.com/getoutreach/stencil-golang - name: go.mod template: go.mod.tpl module: github.com/getoutreach/stencil-golang - - name: opslevel.yml - template: opslevel.yml.tpl - module: github.com/getoutreach/stencil-outreach - name: package.json template: package.json.tpl module: github.com/getoutreach/stencil-base