argoproj / argo-workflows

Workflow Engine for Kubernetes
https://argo-workflows.readthedocs.io/
Apache License 2.0
15.11k stars 3.21k forks source link

fix: consistent variable substitution for `configMapKeyRef`. Fixes #13890 #13921

Open MasonM opened 2 days ago

MasonM commented 2 days ago

Fixes #13890

Motivation

Support for substituting variables in configMapKeyRef was added in https://github.com/argoproj/argo-workflows/pull/7542 by manually parsing templates out of the string, instead of using the standard template.Replace() function. Since the manual parsing logic uses the same syntax as simple template tags (e.g. {{workflow.parameters.cm-name}}), users reasonably expect it to work the same, but it doesn't, which leads to confusion. Additionally, supporting templates like {{workflow.parameters.cm-name}}-cm is important, because that's a common pattern.

Modifications

This replaces the manual parsing code with the standard template.Replace() function that everything else uses.

Verification

Verified by running the example workflow from https://github.com/argoproj/argo-workflows/issues/13890 locally: image