Reverse the order of nested templates. (#531)

Reverse the order of nested templates. (#531)

Reverses the order of nested template declaration.

This way templates that depend nested templates over the same hook are ensured to run in the proper order.

Ensures consistency of run-order template includes, for both base yml files, and nested template yml

eg:

base.yml

templates:
  - "templates/template1.yml"
hooks:
  after_code:
    - exec: cat "/tmp/file_made_from_template1.yml.txt"

template1.yml

templates:
  - "templates/template2.yml"
hooks:
  after_code:
    - exec: cat "/tmp/file_made_from_template2.yml.txt"
    - exec: echo "data from template1" > /tmp/file_made_from_template1.yml.txt

template2.yml

hooks:
  after_code:
    - exec: echo "data from template2" > /tmp/file_made_from_template2.yml.txt
diff --git a/launcher b/launcher
index d5a6e4c..173a1d6 100755
--- a/launcher
+++ b/launcher
@@ -280,7 +280,7 @@ find_templates() {
         local nested_templates=$(find_templates $template)
 
         if [ ! -z "$nested_templates" ]; then
-          templates="$templates $nested_templates"
+          templates="$nested_templates $templates"
         fi
       done
 

GitHub sha: 0c263ec4

1 Like

This commit appears in #531 which was approved by CvX. It was merged by featheredtoast.