Skip to content

Commit

Permalink
re-stencil(stable)
Browse files Browse the repository at this point in the history
  • Loading branch information
Devbase CI committed Mar 14, 2024
1 parent 11f4ad5 commit d3bc180
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# syntax, such as anchors, will be fixed automatically.
version: 2.1
orbs:
shared: getoutreach/shared@dev:first
shared: getoutreach/shared@2.25.1
queue: eddiewebb/[email protected]

parameters:
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# you are reducing compatibility guarantees.
## <<Stencil::Block(toolverOverride)>>
## <</Stencil::Block>>
golang 1.22.0
nodejs 18.17.1
protoc 21.5
golang 1.21.5
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
Expand Down
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
// Maps the go module cache on the host to the persistent volume used by devspaces.
// These should be the respective values of `go env GOMODCACHE`.
{
"from": "${env:HOME}/.asdf/installs/golang/1.22.0/packages/pkg/mod",
"to": "/home/dev/.asdf/installs/golang/1.22.0/packages/pkg/mod"
"from": "${env:HOME}/.asdf/installs/golang/1.21.5/packages/pkg/mod",
"to": "/home/dev/.asdf/installs/golang/1.21.5/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.22.0/go/src",
"to": "/home/dev/.asdf/installs/golang/1.22.0/go/src"
"from": "${env:HOME}/.asdf/installs/golang/1.21.5/go/src",
"to": "/home/dev/.asdf/installs/golang/1.21.5/go/src"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion cortex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ info:
framework: stencil
language: Golang
stencil_version: v1.37.3
golang_version: 1.22.0
golang_version: 1.21.5
cli: false
service: false
product: Outreach
Expand Down
70 changes: 10 additions & 60 deletions scripts/devbase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,75 +6,25 @@ 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() {
python="$(command -v python3 || command -v python)"
"$python" -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$1"
}

# gojq returns the path to a JIT-downloaded gojq binary.
gojq() {
set -uo pipefail

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 reads a field from a yaml file using either go-yq or python-yq
get_field_from_yaml() {
local field="$1"
local file="$2"
field="$1"
file="$2"

"$(gojq)" --yaml-input -r "$field" <"$file"
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"
fi
}

# Use the version of devbase from stencil
Expand Down
2 changes: 0 additions & 2 deletions service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ arguments:
modules:
- name: github.com/getoutreach/stencil-base
- name: github.com/getoutreach/stencil-golang
channel: unstable
- name: github.com/getoutreach/devbase
channel: main
- name: github.com/getoutreach/stencil-outreach
- name: github.com/getoutreach/stencil-circleci
- name: github.com/getoutreach/stencil-actions
Expand Down
4 changes: 2 additions & 2 deletions stencil.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: v1.37.3
modules:
- name: github.com/getoutreach/devbase
url: https://github.com/getoutreach/devbase
version: main
version: v2.25.1
- name: github.com/getoutreach/stencil-actions
url: https://github.com/getoutreach/stencil-actions
version: v0.4.0
Expand All @@ -17,7 +17,7 @@ modules:
version: v1.8.2
- name: github.com/getoutreach/stencil-golang
url: https://github.com/getoutreach/stencil-golang
version: unstable
version: v1.20.0
- name: github.com/getoutreach/stencil-outreach
url: https://github.com/getoutreach/stencil-outreach
version: v0.20.4
Expand Down

0 comments on commit d3bc180

Please sign in to comment.