sql-runner icon indicating copy to clipboard operation
sql-runner copied to clipboard

Prevent non-supplied variables from breaking `-fillTemplates`

Open dilyand opened this issue 7 years ago • 2 comments

With templateable playbooks, we can pass arguments to be replaced in the playbook via the -var flag. However, if we miss one of those, then the -fillTemplates functionality won't work.

For example:

:targets:
  - :name:      "Redshift"
    :type:         "redshift"
    :host:         "hostname"
    :database: "snowplow"
    :port:          5439
    :username: "datamodeling"
    :password:  {{secret "redshift-datamodeling-password"}}
:variables:
  :first_day_of_prev_month_YYYY_MM_DD: {{.start}}
  :prev_month_YYYY_MM: {{.month}}
  :first_day_of_this_month_YYYY_MM_DD: {{.end}}
:steps:
...

It's easy to miss that you need to supply a value for password. It does not look like the other variables ({{var}} vs {{.var}}) and it is in another section of the playbook. But if you do not supply a value for it, then -fillTemplates won't print out the SQL queries, even though you're passing all the values that are required for that:

λ:> ./sql-runner -dryRun -playbook ./playbooks/playbook.yml.tmpl -sqlroot ./sql -var start=$(gdate -d "$(gdate +%Y-%m-01) -1 month" +%Y-%m-%d),month=$(gdate -d "$(gdate +%Y-%m-01) -1 month" +%Y-%m),end=$(gdate +%Y-%m-01) -fillTemplates

2018/10/15 16:24:43 WARNING: No queries to run

(That warning message is also not very helpful.)

dilyand avatar Oct 16 '18 09:10 dilyand

Are you talking about non-supplied variables in general, or a missing password specifically? As you say, they are distinct things.

alexanderdean avatar Oct 16 '18 09:10 alexanderdean

Any non-supplied variable has the same effect. Missing password is just a highly likely scenario.

dilyand avatar Oct 16 '18 10:10 dilyand