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(ui): allow `links` to metadata with dots. Fixes #11741 #13752

Closed Joibel closed 1 month ago

Joibel commented 1 month ago

Fixes #11741

Motivation

You cannot create UI links to our own annotations or labels.

Argo Workflows uses the format workflows.argoproj.io/something for annotations and labels. These annotations and labels have dots (.) in them.

The links documentation says you can access all workflow fields, using a dot to go down into the child entry.

These two conflict making it impossible to access our own labels and annotations, so fix it for annotations and labels.

This was discovered whilst adding an annotation to the workflows that was useful to link from in a separate feature.

Modifications

When splitting the variable name up use a specialised splitting function that understands that things under workflow.metadata.labels and workflow.metadata.annotations are always names and not to split further. It is crude

Verification

Added a unit test for the hit the special code case. There are already unit tests which test the other case.

Manually tested my new link works.

agilgur5 commented 1 month ago

For reference, links are also an outlier in using their own custom, simplified templating system and with their own syntax; see also: https://github.com/argoproj/argo-workflows/issues/8626