Skip to content

for dynamic parameters (multi-type) or action-chain publishing allow explicit casting of jinja variables #3515

@cognifloyd

Description

@cognifloyd

If I have an workflow parameter like:

example:
  required: true
  type: [integer, string]
  description: "An example parameter"

I don't think st2 can know what to cast the parameter as if I use it in a jinja template.

"{{ example }}" will always be a string, even if I do something like "{{ example | int }}"

In cases where it is not clear what data type something should be, like the above contrived example, If I explicitly run it through a jinja filter that specifies a type, please cast it as that type.

Some parameters can't specify a type because they can have various inputs, but within the context of, say, a particular ansible playbook, I know what type to expect, even if I can't tell ST2 in a schema that this var will be this type. Please allow type casting of jinja templates through either a jinja filter or some kind of new directive.

Finding a way to use the jinja filters will feel cleaner, but I implemented special parsing using directive-like magic strings for INT, AST, and JSON type objects in StackStorm-Exchange/stackstorm-ansible#14. Something more generic would be nice.

edit: see the next comment for publishing variables in action-chain workflows

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions