hairyhenderson/gomplate

Ignore not provided parametrs

matrus2 opened this issue · 2 comments

Would be nice to have an option/flag to accept to ignore error if one parameter is not provided. For now if in datasource there is no property the error is thrown:

datasource:

cluster:
#  clusterName: "samename"
  clusterFQDN: "fqdn"

template:

# ------ Common variables
cluster_name = {{ (datasource "config").cluster.clusterName }}
cluster_fqdn = {{ (datasource "config").cluster.clusterFQDN }}

Throws error:

failed to render template templates/example.tmpl: template: templates/same.tmpl:2:30: executing "templates/some.tmpl" at <"config">: map has no entry for key "clusterName""

Hi @matrus2, you can use coll.Has to test for this.

See also the discussion in #213, which this issue effectively duplicates, so for now I'll close this, unless you see a reason to re-open!

Ok, I somehow miss has functionality, thank you for quick response.