-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
Currently when you run nomad-pack plan the EmbeddedTmpl value is flattened into a single line string. If there is a change someone in this string, then that single line contains the before and after. These templates can get long and so it can be very hard to identify what the change is.
Ideally the plan command would print out the value of EmbeddedTmpl with the new lines and show a diff of what lines have changed.
I currently accomplish this with a bash script that I pipe the output of plan through:
#!/bin/bash
# Extract the EmbeddedTmpl line
combinedTemplates=$(sed -nE 's/.*EmbeddedTmpl: +(.*)/\1/p')
if [ -n "$combinedTemplates" ]; then
before=$(echo "$combinedTemplates" | sed -nE 's/(.*) => (.*)/\1/p')
after=$(echo "$combinedTemplates" | sed -nE 's/(.*) => (.*)/\2/p')
# Run diff and display output
diff_output=$(colordiff --unified <(echo "${before@E}") <(echo "${after@E}"))
if [ -z "$diff_output" ]; then
echo "No differences found."
else
echo "Differences:"
echo "$diff_output"
fi
else
echo "EmbeddedTmpl line not found in input."
fiMy workflow then is:
- Run
nomad-pack plan ...as normal - If there is a change to the
EmbeddedTmplI runnomad-pack plan ... | ./templatediff.sh
Here is a sample output without my script:
nomad-pack plan -f packs/robomerge/variables/production.hcl packs/robomerge/
+/- Job: "robomerge"
+/- Task Group: "robomerge" (1 create/destroy update)
+/- Task: "robomerge" (forces create/destroy update)
+/- Template {
ChangeMode: "restart"
ChangeSignal: ""
DestPath: "secrets/file.env"
+/- EmbeddedTmpl: "{{ with nomadVar \"nomad/jobs/robomerge\" }}\nROBO_HOST_INFO=\"robomerge\"\nROBO_EXTERNAL_URL=\"SOME_INTERNAL_URL\"\nROBO_RUNBOTS=\"yes\"\nROBO_PREVIEW_ONLY=\"false\"\n\nBOTNAME=\"project_one,project_two\"\n\nROBO_WATCHDOG_PORT=\"8080\"\n\n# InfluxDB
settings\nROBO_INFLUX_AUTHORIZATION={{ .INFLUX_AUTHORIZATION }}\nROBO_INFLUX_URL={{ .INFLUX_URL }}\n\n# Internal path settings, where Robomerge stores things\nROBO_VAULT_PATH=\"/robomerge/vault\"\nROBO_BRANCHSPECS_DIRECTORY=\"/robomerge/branchspecs\"\nROBO_PERSISTENCE_DIR=\"/robomerge/persistence\"\n\n#
Perforce path settings\nROBO_BRANCHSPECS_ROOT_PATH=\"//PERFORCE/PATH\"\nROBO_PERSISTENCE_BACKUP_PATH=\"//OTHER/PERFORCE/PATH\"\n\n# Perforce workspace
settings\nROBO_BRANCHSPECS_WORKSPACE=\"robomerge-branchspec\"\nROBO_PERSISTENCE_BACKUP_WORKSPACE=\"robomerge-persistencen\"\n\nROBO_NO_MAIL=\"true\"\n\n# Sentry
configuration\nEPIC_ENV=\"prod\"\nNODE_ENV=\"production\"\nEPIC_DEPLOYMENT=\"production\"\nSENTRY_DSN=\"SENTRY_DSN_URL\"\n\n# Perforce configuration\nP4PORT={{ .P4_PORT }}\nP4USER={{ .P4_USER }}\nP4PASSWD={{ .P4_PASSWORD }}\n{{ end }}\n" =>
"{{ with nomadVar \"nomad/jobs/robomerge\" }}\nROBO_HOST_INFO=\"robomerge\"\nROBO_EXTERNAL_URL=\"SOME_INTERNAL_URL\"\nROBO_RUNBOTS=\"yes\"\nROBO_PREVIEW_ONLY=\"false\"\n\nBOTNAME=\"project_one,project_two,project_three\"\n\nROBO_WATCHDOG_PORT=\"8080\"\n\n# InfluxDB
settings\nROBO_INFLUX_AUTHORIZATION={{ .INFLUX_AUTHORIZATION }}\nROBO_INFLUX_URL={{ .INFLUX_URL }}\n\n# Internal path settings, where Robomerge stores things\nROBO_VAULT_PATH=\"/robomerge/vault\"\nROBO_BRANCHSPECS_DIRECTORY=\"/robomerge/branchspecs\"\nROBO_PERSISTENCE_DIR=\"/robomerge/persistence\"\n\n#
Perforce path settings\nROBO_BRANCHSPECS_ROOT_PATH=\"//PERFORCE/PATH\"\nROBO_PERSISTENCE_BACKUP_PATH=\"//OTHER/PERFORCE/PATH\"\n\n# Perforce workspace
settings\nROBO_BRANCHSPECS_WORKSPACE=\"robomerge-branchspec\"\nROBO_PERSISTENCE_BACKUP_WORKSPACE=\"robomerge-persistencen\"\n\nROBO_NO_MAIL=\"true\"\n\n# Sentry
configuration\nEPIC_ENV=\"prod\"\nNODE_ENV=\"production\"\nEPIC_DEPLOYMENT=\"production\"\nSENTRY_DSN=\"SENTRY_DSN_URL\"\n\n# Perforce configuration\nP4PORT={{ .P4_PORT }}\nP4USER={{ .P4_USER }}\nP4PASSWD={{ .P4_PASSWORD }}\n{{ end }}\n"
Envvars: "true"
ErrMissingKey: "false"
LeftDelim: "{{"
Perms: "0644"
RightDelim: "}}"
SourcePath: ""
Splay: "5000000000"
VaultGrace: "0"
}
And the output with my script:
nomad-pack plan -f packs/robomerge/variables/production.hcl packs/robomerge/ | ./templatediff.sh
Differences:
--- /dev/fd/63 2025-09-05 10:36:47.716217407 +0000
+++ /dev/fd/62 2025-09-05 10:36:47.716217407 +0000
@@ -54,7 +54,7 @@
ROBO_RUNBOTS="yes"
ROBO_PREVIEW_ONLY="false"
-BOTNAME="project_one,project_two"
+BOTNAME="project_one,project_two,project_three"
ROBO_WATCHDOG_PORT="8080"
My script cuts out all the other changes, so still requires I run a normal plan before I pass it through my script.
Metadata
Metadata
Assignees
Type
Projects
Status
Needs Roadmapping