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

Global vars: & env: are not interpolated in tasks: desc: fields #1410

Closed
itnok opened this issue Nov 27, 2023 · 2 comments
Closed

Global vars: & env: are not interpolated in tasks: desc: fields #1410

itnok opened this issue Nov 27, 2023 · 2 comments

Comments

@itnok
Copy link

itnok commented Nov 27, 2023

  • Task version: 3
  • Operating system: darwin / macOS
  • Experiments enabled: No
  • Example Taskfile.yaml to reproduce the issue:
---
version: "3"

env:
  SOME_STATIC_ENV: "ful"
  SOME_DYNAMIC_ENV:
    sh: echo "beauti"

vars:
  SOME_STATIC_VAR: "o "
  SOME_DYNAMIC_VAR:
    sh: echo "hell"

tasks:
  not-helpful:
    desc: {{ .SOME_DYNAMIC_VAR }}{{ .SOME_STATIC_VAR }}{{ .SOME_DYNAMIC_ENV }}{{ .SOME_STATIC_ENV }} {{ OS }} world
    cmds:
      - true

Expected output:

hello beautiful darwin world

Output:

hellful darwin world

Variable interpolation works well, but it seems that desc: does not support interpolation for neither vars: or env: variables that are "dynamically" generated (or more likely vars: and env: are not computed before desc: interpolation happens?). I am looking for this to try to make my tasks a little more generic... (similar to #276 but not limited to Golang templates)

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Nov 27, 2023
@clarson99
Copy link

This same issue exists with both the desc: and prompt: fields. I'd like to be able to run something like:

ENVIROMENT=prod task deploy

But the prompt comes back looking like:

You are about to deploy to ${ENVIROMENT}, continue? [y/N]

Instead of the desired:

You are about to deploy to prod, continue? [y/N]

@vmaerten
Copy link
Member

@itnok in desc (and prompt), you can interpolate static variables but not dynamic variables. This is intentional, mainly for better performance, as this command is used for autocomplete.

@clarson99 this is working actually :

version: "3"

tasks:
  deploy
    prompt: 'You are about to deploy to {{.ENV}}'
    cmds:
      - true

@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants