I am using python jinja2 to render some json files for CI/CD. These files will be used by application which are written in GoLang.
variables are defined a yaml files & loaded using pyymal. For example..
template
{
"enable_log": {{ enable_log}}
}
variable file:
---
us-east-2:
dev:
enable_log: true
prod:
enable_log: false
The result is as following
{ "enable_log": True }
code snippet:
template_env = Environment(loader=FileSystemLoader(cfg_dir), trim_blocks=True,
lstrip_blocks=True, undefined=StrictUndefined)
source_template = template_env.get_template(cfg_template)
config_data = yaml.load(open(VARS))
with open(out_file, 'w') as f:
data = source_template.render(config_data[region][env])
f.write(data)
I know python booleans are True & False. But the application code(Golang) is not loading that as boolean. Is there any workaround in the pyyaml to fix this problem?