chevdor / tera-cli

A command line utility on top of the tera templating engine. Takes json|yaml|toml as input and can merge ENV in. You may see it as envsubst on steroid.
MIT License
75 stars 10 forks source link

YAML/JSON support #16

Closed cpkio closed 2 years ago

cpkio commented 2 years ago

It seems tera cannot handle YAML like

audit-events:
  sso.auth.success:
    description: Authentification success

Result

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Msg("Failed to render '__tera_one_off'"), source: Some(Error { kind: Msg("Forloop containers have to be an ident or a function call (tried to iterate on 'Math(MathExpr { lhs: Expr { val: Ident(\"audit\"), negated: false, filters: [] }, rhs: Expr { val: Ident(\"events\"), negated: false, filters: [] }, operator: Sub })')"), source: None }) }', src/main.rs:64:66

Remove - from audit-events and you will get

Thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Msg("Failed to render '__tera_one_off'"), source: Some(Error { kind: Msg("Tried to iterate using key value on variable `auditevents`, but it is missing a key"), source: None }) }', src/main.rs:64:66

Can one iterate over YAML map?

chevdor commented 2 years ago

The issue comes from tera itself. It would be best opening the issue here. I will push a workaround to your issue in a few min.

chevdor commented 2 years ago

I added your use case and a workaround here.