Skip to content

Commit 0a54399

Browse files
committed
Tiltfile: properly escape passed manifest
Escaping by hand with replace is just wrong and will not work in many cases. shlex should take care of this. Signed-off-by: Mateusz Gozdek <[email protected]>
1 parent 1fc4df3 commit 0a54399

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Tiltfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ def deploy_worker_templates(template, substitutions):
347347
value = substitutions[substitution]
348348
yaml = yaml.replace("${" + substitution + "}", value)
349349

350-
yaml = yaml.replace('"', '\\"') # add escape character to double quotes in yaml
350+
yaml = shlex.quote(yaml)
351351
flavor_name = os.path.basename(flavor)
352-
flavor_cmd = "RANDOM=$(bash -c 'echo $RANDOM'); CLUSTER_NAME=" + flavor.replace("windows", "win") + "-$RANDOM; make generate-flavors; echo \"" + yaml + "\" > ./.tiltbuild/" + flavor + "; cat ./.tiltbuild/" + flavor + " | " + envsubst_cmd + " | " + kubectl_cmd + " apply -f - && echo \"Cluster \'$CLUSTER_NAME\' created, don't forget to delete\""
352+
flavor_cmd = "RANDOM=$(bash -c 'echo $RANDOM'); CLUSTER_NAME=" + flavor.replace("windows", "win") + "-$RANDOM; make generate-flavors; echo " + yaml + "> ./.tiltbuild/" + flavor + "; cat ./.tiltbuild/" + flavor + " | " + envsubst_cmd + " | " + kubectl_cmd + " apply -f - && echo \"Cluster \'$CLUSTER_NAME\' created, don't forget to delete\""
353353

354354
# wait for kubeconfig to be available
355355
flavor_cmd += "; until " + kubectl_cmd + " get secret ${CLUSTER_NAME}-kubeconfig > /dev/null 2>&1; do sleep 5; done; " + kubectl_cmd + " get secret ${CLUSTER_NAME}-kubeconfig -o jsonpath={.data.value} | base64 --decode > ./${CLUSTER_NAME}.kubeconfig; chmod 600 ./${CLUSTER_NAME}.kubeconfig; until " + kubectl_cmd + " --kubeconfig=./${CLUSTER_NAME}.kubeconfig get nodes > /dev/null 2>&1; do sleep 5; done"

0 commit comments

Comments
 (0)