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

Allow sprig expressions in WorkflowEventBinding submit metadata #5351

Closed
svmaris opened this issue Mar 10, 2021 · 2 comments
Closed

Allow sprig expressions in WorkflowEventBinding submit metadata #5351

svmaris opened this issue Mar 10, 2021 · 2 comments
Labels
type/feature Feature request

Comments

@svmaris
Copy link

svmaris commented Mar 10, 2021

Summary

#4640 added support for expressions in the name of webhook-submitted workflows. Please allow sprig functions as well.

Use Cases

We're in the same boat as @michaeljohnalbers . We're using Bitbucket Server Webhooks to trigger generic build pipelines in Argo Workflows. Multiple services (repos) are handled by the same WorkflowTemplate. When submitting new Workflows, we'd like to see the actual service being built as part of the name of the workflow.

It seems that only 'simple' expressions are allowed right now, eg. things coming directly from the event payload or metadata. We're having a hard time getting the right naming scheme, because it has to be unique and we're limited to the Kubernetes DNS naming scheme (so it can't be too long).

We have no control over the information coming from Bitbucket Server. Ideally, we'd like to add the commit hash, but the payload only contains the full SHA256 hash, which is too long when combined with the service name. Also, there's no unix timestamp in either the headers or the payload we can use.

If we could do something like this:

spec:
  event:
    selector: ...
  submit:
    metadata:
      name: '{{payload.repository.slug}} + "-" + {{payload.changes[0].toHash | trunc 8}}'

it would be absolutely awesome.


Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

@svmaris svmaris added the type/feature Feature request label Mar 10, 2021
@alexec
Copy link
Contributor

alexec commented Mar 10, 2021

Would you like to submit a PR? You'd need to make changes:

func expressionEnvironment(ctx context.Context, namespace, discriminator string, payload *wfv1.Item) (map[string]interface{}, error) {

Similar to:

https://github.com/argoproj/argo-workflows/blob/master/util/template/template.go#L34

@svmaris
Copy link
Author

svmaris commented Mar 11, 2021

@alexec After spending half a day on figuring out how to get template.Replace() working, I finally realised I just needed to get the extra helper functions in the env for expr 🤦 . Fix is in #5374.

@alexec alexec closed this as completed in 1f7cf1e Mar 12, 2021
@simster7 simster7 mentioned this issue Mar 15, 2021
27 tasks
@simster7 simster7 mentioned this issue Mar 29, 2021
77 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature Feature request
Projects
None yet
Development

No branches or pull requests

2 participants