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

Template variable file paths are not processing parameters or variables #362

Open
bjuraga opened this issue Jul 1, 2024 · 2 comments
Open

Comments

@bjuraga
Copy link

bjuraga commented Jul 1, 2024

Given the below example foder/file structure it should be possible to do a repro.

The files are typed mostly out of memory, so there might be small typos, please excuse me for that. But the pipeline runs completely fine in Azure DevOps, so it got me triggered to file an issue here.

filesystem/repo:

/devops/azure-pipeline.yml
/devops/templates/template.yml
/infra/tenants/a/subs/a/variables.yml

azure-pipeline.yml:

stages:
- ${each tenant in parameters.tenants}:
  - ${each sub in tenant.subs}:
    - template: templates/stage.yml
      parameters:
	    tenantName: ${{ tenant.name }}
		subName: ${{ sub.name }}

stage.yml:

parameters:
- name: tenantName
  type: string
  default: ''
- name: subName
  type: string
  default: ''
stages:
- stage:
  variables:
  - template: ../../infra/tenants/${{parameters.tenantName}}/subs/${{parameters.subName}}/variables.yml

variables.yml:

variables:
  - name: location
    value: eastus

Validation outcome:

Couldn't read template ../../infra/tenants//subs///variables.yaml resolved to infra/tenants/subs/variables.yaml (self)

Seems like this is the issue:
Calculating the path is missing the access to the parameters, so it replaces them with empty string
Further, the path treats // or /// as a single /

This does work in real life, so it's a false negative

@ChristopherHX
Copy link
Owner

ChristopherHX commented Jul 1, 2024

You might need to provide more context, the minimal example works on my end (syntax errors removed, but not far away from your post)
I have attached it here for reference: test.zip

Using [ { name: a, subs: [{ name: a }] } ] as input if the extension asks about the required parameter

@ChristopherHX
Copy link
Owner

ChristopherHX commented Jul 1, 2024

I seem to get an idea what you mean

Pressing Expand yaml on stage.yml will cause this error, due to having non required parameters that have default value ""

Pressing Expand yaml on azure-pipelines.yml works

  • This validates stage.yml and all other nested templates with parameters it provides to them

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

2 participants