2018-12-12 18:18:00 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-03-13 23:27:20 +01:00
|
|
|
if ! [ -x "$(command -v $2)" ]; then
|
|
|
|
JSONNET_BIN=jsonnet
|
|
|
|
echo "using jsonnet from path"
|
|
|
|
else
|
|
|
|
JSONNET_BIN=$2
|
|
|
|
echo "using jsonnet from arg"
|
|
|
|
fi
|
|
|
|
|
2018-12-12 18:18:00 +01:00
|
|
|
# This script uses arg $1 (name of *.jsonnet file to use) to generate the manifests/*.yaml files.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
# only exit with zero if all commands of the pipeline exit successfully
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
# Make sure to start with a clean 'manifests' dir
|
|
|
|
rm -rf manifests
|
2020-05-26 01:23:56 +02:00
|
|
|
mkdir -p manifests/setup
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2019-03-13 23:27:20 +01:00
|
|
|
# optional, but we would like to generate yaml, not json
|
2024-05-30 22:19:48 +02:00
|
|
|
$JSONNET_BIN -J vendor -m manifests "${1-example.jsonnet}" | while IFS= read -r file; do
|
|
|
|
"$(go env GOPATH)/bin/gojsontoyaml" <"$file" >"$file.yaml"
|
|
|
|
rm -f "$file"
|
2024-03-03 00:51:34 +01:00
|
|
|
done
|
2024-05-30 22:19:48 +02:00
|
|
|
|
2020-06-19 14:58:49 +02:00
|
|
|
# Clean-up json files from manifests dir
|
2024-03-03 00:51:34 +01:00
|
|
|
find manifests -type f ! -name '*.yaml' -delete
|