-
Notifications
You must be signed in to change notification settings - Fork 755
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
allow using none
statements in bicepparam files at build-params
command
#15107
Conversation
Test this change out locally with the following install scripts (Action run 11752757163) VSCode
Azure CLI
|
@@ -63,14 +63,17 @@ public async Task<int> RunAsync(BuildParamsArguments args) | |||
if (bicepFileUri is not null && | |||
compilation.GetEntrypointSemanticModel().Root.TryGetBicepFileSemanticModelViaUsing().IsSuccess(out var usingModel)) | |||
{ | |||
if (usingModel is not SemanticModel bicepSemanticModel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work with Azure CLI if the user doesn't provide a template? E.g. here. Would this cause an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the following content in main.bicep
and main.bicepparam
files;
// main.bicep
param bar string
// main.bicepparam
using none
param bar = 'foo'
When I run the following command, it successfully build the files;
dotnet run --project src/Bicep.Cli/Bicep.Cli.csproj -- build-params ./main.bicepparam --bicep-file ./main.bicep --stdout
If I understand your comment correctly, you're asking what happens if we don't provide --bicep-file ./main.bicep
option;
dotnet run --project src/Bicep.Cli/Bicep.Cli.csproj -- build-params ./main.bicepparam --stdout
I ran the command and saw it successfully build the main.bicepparam
file.
When
There should be multiple
.bicep
files (per project, per layer, etc.) and multiple.bicepparam
files pairing with.bicep
files (withusing {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 tobicep build-params
command.Since the
.bicep
and.bicepparam
files are paired with theusing
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 theusing
statement in the.bicepparam
file points to the same.bicep
file as thebuild-params
command argumentsSo, if the
.bicepparam
file has ausing none
statement, it'll be possible to use the same.bicepparam
file in multiple deployments.Testing the PR
When you run the following command;
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
fileBuildParamsCommandTests
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 ausing none
statement instead of ausing {filename}.bicep
statement in the.bicepparam
file.Microsoft Reviewers: Open in CodeFlow