#!/usr/bin/env bash

# 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/prometheus
mkdir manifests/prometheus
                                               # optional, but we would like to generate yaml, not json
jsonnet --ext-str PrivateCloudEnv="$1" -J vendor -m manifests/prometheus kubernetes-cluster-monitoring.jsonnet | xargs -I{} sh -c 'cat {} | gojsontoyaml > {}.yaml; rm -f {}' -- {}

