Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow
using none
statements in bicepparam files at build-params
c…
…ommand (#15107) 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 > git worktree add /tmp/bicep-allow-using-none polatengin/allow-using-none-statements-build-params ```bicep // main.bicep param bar string ``` ```bicep // main.bicepparam using none param bar = 'foo' ``` When you run the following command; ```bash dotnet run --project src/Bicep.Cli/Bicep.Cli.csproj -- build-params ./main.bicepparam --bicep-file ./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](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/15107)
- Loading branch information