From 58bc2799315f9e0c00b2dec123bb78de638a7c3c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 23 Aug 2018 16:15:45 -0700 Subject: [PATCH] tests/run: Use one Python invocation (no jq) for editing the config We've used the Python -> jq (-> jq) -> Python approach to editing the config file since this script landed in a2405e4d (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 --- tests/run.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index e0c61bfea5b..50d02a37769 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -40,16 +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\"" -) -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['pullSecretPath'] = '${PULL_SECRET_PATH}' + config['aws']['region'] = '${AWS_REGION}' + config['aws']['master']['iamRoleName'] = 'tf-tectonic-master-node' + config['aws']['worker']['iamRoleName'] = 'tf-tectonic-worker-node' + yaml.safe_dump(config, sys.stdout) + EOF echo -e "\\e[36m Initializing Tectonic...\\e[0m" tectonic init --config="${CLUSTER_NAME}".yaml