Today you can't construct your headers before-hand and inject them in your Request / Download task. This is sad as it would leverage the ability for eg. to have a subflow that handles the whole corp' authentication (call corp' authentication provider to get a token and inject it directly in the headers).
inputs:
- name: headers
type: JSON
- name: body
type: JSON
...
tasks:
- id: oauth
type: Request
url: "https://auth-provider/oauth"
method: POST
headers:
client_id: {{ secret('clientId') }}
client_secret: {{ secret('clientSecret') }}
- id: call
type: Request
url: "{{ inputs.url }}"
method: "{{ inputs.method }}"
headers: |
[{% for header in to_entries(inputs.headers) %}
{{header.key}}: {{header.value}},
{% endfor %}
Authorization: Bearer {{ outputs.oauth.token }}
]
body: "{{ inputs.body }}"
That's not ideal syntax but at least it removes the need of creating a custom plugin to handle oauth
Ideally this remark should also apply to Request method to allow templating it also.
I know it removes the type-checking at compile-time but imo it brings so much value to "Kestra on its own" mindset