Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add structural templates as alternative to text placeholders #1684

Closed
Ark-kun opened this issue Oct 17, 2019 · 1 comment
Closed

Add structural templates as alternative to text placeholders #1684

Ark-kun opened this issue Oct 17, 2019 · 1 comment
Labels
area/templating Templating with `{{...}}` type/feature Feature request

Comments

@Ark-kun
Copy link
Member

Ark-kun commented Oct 17, 2019

Fixes #1293 : "Argo should provide a (limited) set of functions available in templates to support basic tasks like string modification."

Argo's text placeholders are limited and is not flexible enough .

Even with the current very limited placeholder support, it's impossible to call some programs that use go format templates (e.g. docker) since their templates clash with Argo syntax.

I have experience with many custom text-based templating languages and all of them were painful or impossible to use for some cases.

The solution is to use structural templates. There are many advantages of structural templates over text-based templates:

  • Templating system is very easy to extend.
  • No need to reinvent the wheel and write a complicated fragile parser that's still going to break.
  • Templates do not conflict with any verbatim texts.

With structural templates we can even support multiple templating engines.

Structural templates utilize the language that Argo workflows already use - YAML.

Here is a pretty complex example that uses concat and substring to construct the full image name out of the base image name and the shortened revision:

command: [
  docker,
  tag,
  {inputValue: source-image},
  {concat: [{inputValue: image-name}, ':', {substring: {str: {inputValue: revision}, count: 6}]}
]

P.S. {inputValue: source-image} is the structural equivalent of "{{inputs.parameters.source-image}}".

Here is an example of structural templating in a component/template definition: https://github.com/kubeflow/pipelines/blob/5043ec78afc63506ce70fca01d2936928cb0fedb/components/gcp/automl/create_dataset_for_tables/component.yaml#L109

@alexec
Copy link
Contributor

alexec commented Feb 7, 2022

This is fixed by Expression Tag Templates in v3.

@alexec alexec closed this as completed Feb 7, 2022
@alexec alexec added the area/templating Templating with `{{...}}` label Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/templating Templating with `{{...}}` type/feature Feature request
Projects
None yet
Development

No branches or pull requests

3 participants