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 using none statements in bicepparam files at build-params command #15107

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

polatengin
Copy link
Member

@polatengin polatengin commented Sep 18, 2024

When

  • there are multiple projects with a very similar infrastructure needs (usually encountered in software shops)
  • there are multiple layers in the same project with very similar infrastructure needs (usually encountered in multi-tenant softwares)

There should be multiple .bicep files (per project, per layer, etc.) and multiple .bicepparam files pairing with .bicep files (with using {filename}.bicep statements in .bicepparam files)

When az deployment group create --resource-group $rgname --name $rgname --template-file ./main.bicep --parameters ./main.bicepparam command executed, az cli downstreams the parameters to bicep build-params command.

Since the .bicep and .bicepparam files are paired with the using statement in .bicepparam file, it's not possible to re-use the same .bicepparam file with multiple deployments.

This PR relaxes the check in the build-params command that requires the using statement in the .bicepparam file points to the same .bicep file as the build-params command arguments

So, if the .bicepparam file has a using none statement, it'll be possible to use the same .bicepparam file in multiple deployments.


Testing the PR

// main.bicep
param unusedParam int
// main.bicepparam
using none
param unusedParam = 3

When you run the following command;

dotnet run -- build-params /home/enpolat/p/bicep/main.bicepparam --bicep-file /home/enpolat/p/bicep/main.bicep --stdout

It fails with the following error message; Bicep file ./main.bicep provided with --bicep-file can only be used if the Bicep parameters "using" declaration refers to a Bicep file on disk.

With the changes in this PR, same command runs successfully and builds the main.bicepparam file

BuildParamsCommandTests

I also added a test (https://github.com/Azure/bicep/pull/15107/files#diff-30f70729cbd5bcbfb69d4edd8ff3fa9bee94690e92f5e3e86ac9a7eb98b3f550R431) to ensure the build-params command successfully builds given .bicepparam file when there is a using none statement instead of a using {filename}.bicep statement in the .bicepparam file.


Microsoft Reviewers: Open in CodeFlow

@polatengin polatengin self-assigned this Sep 18, 2024
Copy link
Contributor

github-actions bot commented Sep 18, 2024

Test this change out locally with the following install scripts (Action run 11356153636)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 11356153636
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 11356153636"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 11356153636
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 11356153636"

Copy link
Contributor

github-actions bot commented Sep 18, 2024

Dotnet Test Results

    72 files   -     36      72 suites   - 36   29m 14s ⏱️ - 12m 6s
11 358 tests  -     24  11 358 ✅  -     24  0 💤 ±0  0 ❌ ±0 
26 447 runs   - 13 216  26 447 ✅  - 13 216  0 💤 ±0  0 ❌ ±0 

Results for commit 67cafd2. ± Comparison against base commit e7884b8.

♻️ This comment has been updated with latest results.

@polatengin polatengin marked this pull request as ready for review October 15, 2024 23:49
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

Successfully merging this pull request may close these issues.

2 participants