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

Required vars not required when calling tasks #1557

Open
mvhatch opened this issue Mar 20, 2024 · 3 comments
Open

Required vars not required when calling tasks #1557

mvhatch opened this issue Mar 20, 2024 · 3 comments
Labels
state: awaiting response Waiting for issue author to respond. state: can't repro Not enough information was given to reproduce the issue described.

Comments

@mvhatch
Copy link

mvhatch commented Mar 20, 2024

I tried looking to see if this was already an issue but did not find anything. Also, wasn't sure if this is a bug or a feature request.

  helm-diff:
    desc: Show the diff between the current and previous helm release
    cmds:
      - task: common:helm-diff
        vars:
          HELM_ARGS: "-f=./helm/{{.PROJ}}.yaml --set image.tag={{.DOCKER_IMAGE_TAG}}"
          K8S_REGION: '{{dig .PROJ "region" .DEFAULT_K8S_REGION (mustFromJson .K8S_CONFIG)}}'
          K8S_CLUSTER: '{{dig .PROJ "cluster" .DEFAULT_K8S_CLUSTER (mustFromJson .K8S_CONFIG)}}'
    requires:
      vars: [PROJ]

Expected running task helm-diff fails with: task: Task "helm-diff" cancelled because it is missing required variables: PROJ

Actual task runs successfully.
Note: PROJ has no default value. For comparison, this works as expected.

  helm-diff:
    desc: Show the diff between the current and previous helm release
    cmds:
      - cmd: echo "helm diff"
        vars:
          HELM_ARGS: "-f=./helm/{{.PROJ}}.yaml --set image.tag={{.DOCKER_IMAGE_TAG}}"
          K8S_REGION: '{{dig .PROJ "region" .DEFAULT_K8S_REGION (mustFromJson .K8S_CONFIG)}}'
          K8S_CLUSTER: '{{dig .PROJ "cluster" .DEFAULT_K8S_CLUSTER (mustFromJson .K8S_CONFIG)}}'
    requires:
      vars: [PROJ]
  • Task version: v3.35.1
  • Operating system: MacOS arm64
  • Experiments enabled: none
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Mar 20, 2024
@trulede
Copy link

trulede commented Mar 31, 2024

Tried this:

version: '3'
tasks:
  foo:
    vars:
      BAR: '{{.BAR | default "who"}}'  # also works without this line
    cmds:
      - echo {{.BAR}}
  bar:
    cmds:
      - task: foo
        vars:
          BAR: "{{.PROJ}}"
    requires:
      vars: [PROJ]

which yields:

$ task foo
task: [foo] echo who
who
$ task bar
task: Task "bar" cancelled because it is missing required variables: PROJ
$ task bar PROJ=fubar
task: [foo] echo fubar
fubar

Can you provide a more complete example that causes the problem? Is it possible that ".PROJ" was defined somewhere in "common:helm-diff" and so was actually considered not missing?

@neriaad
Copy link

neriaad commented Oct 22, 2024

Happened to me as well, here is a minimal example:

  docker-build:
    cmds:
      - echo "Building {{.IMAGE_NAME}}"
    requires:
      vars: [IMAGE_NAME]

Now running:
task docker-build

Should fail, but instead prints:
Building

@vmaerten
Copy link
Member

@neriaad Your example is working as expected cf :
image

@mvhatch Can you provide the full example (that I can copy / past) ?

@vmaerten vmaerten added state: awaiting response Waiting for issue author to respond. state: can't repro Not enough information was given to reproduce the issue described. and removed state: needs triage Waiting to be triaged by a maintainer. labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: awaiting response Waiting for issue author to respond. state: can't repro Not enough information was given to reproduce the issue described.
Projects
None yet
Development

No branches or pull requests

5 participants