Skip to content

Commit

Permalink
tests/run: Use one Python invocation (no jq) for editing the config
Browse files Browse the repository at this point in the history
We've used the Python -> jq (-> jq) -> Python approach to editing the
config file since this script landed in a2405e4 (run smoke tests with
bash script, 2018-06-18, coreos/tectonic-installer#3284).  But it's
more efficient and almost equally compact to perform those edits
directly in Python.

This commit uses a here-document [1] to inject the Python script.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04
  • Loading branch information
wking committed Aug 23, 2018
1 parent b8bf8ca commit 64ba786
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,21 @@ export PATH="$(pwd)/tectonic-dev/installer:${PATH}"
cd tectonic-dev

echo -e "\\e[36m Creating Tectonic configuration...\\e[0m"
CONFIG=$(python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout)' < examples/tectonic.aws.yaml)
CONFIG=$(echo "${CONFIG}" | jq ".name = \"${CLUSTER_NAME}\"" |\
jq ".baseDomain = \"${DOMAIN}\"" |\
jq ".licensePath = \"${LICENSE_PATH}\"" |\
jq ".pullSecretPath = \"${PULL_SECRET_PATH}\"" |\
jq ".aws.region = \"${AWS_REGION}\"" |\
jq ".aws.master.iamRoleName = \"tf-tectonic-master-node\"" |\
jq ".aws.worker.iamRoleName = \"tf-tectonic-worker-node\"" |\
jq ".aws.etcd.iamRoleName = \"tf-tectonic-etcd-node\""
)
echo "${CONFIG}" | python -c 'import sys, yaml, json; yaml.safe_dump(json.load(sys.stdin), sys.stdout)' > "${CLUSTER_NAME}.yaml"
python <<-EOF >"${CLUSTER_NAME}.yaml"
import sys
import yaml
with open('examples/tectonic.aws.yaml') as f:
config = yaml.load(f)
config['name'] = '${CLUSTER_NAME}'
config['baseDomain'] = '${DOMAIN}'
config['licensePath'] = '${LICENSE_PATH}'
config['aws']['region'] = '${AWS_REGION}'
config['aws']['master']['iamRoleName'] = 'tf-tectonic-master-node'
config['aws']['worker']['iamRoleName'] = 'tf-tectonic-worker-node'
config['aws']['etcd']['iamRoleName'] = 'tf-tectonic-etcd-node'
yaml.safe_dump(config, sys.stdout)
EOF

echo -e "\\e[36m Initializing Tectonic...\\e[0m"
tectonic init --config="${CLUSTER_NAME}".yaml
Expand Down

0 comments on commit 64ba786

Please sign in to comment.