Skip to content

Commit

Permalink
[Az.Resources] Update BicepUtility.cs (#26782)
Browse files Browse the repository at this point in the history
* Update BicepUtility.cs

Parameter --documentationUri is deprecated, please use --documentation-uri instead.

* Update ChangeLog.md

* Add check for bicep version 0.24.24 before using new --documentation-uri parameter

---------

Co-authored-by: Yan Xu <yanxu1@microsoft.com>
  • Loading branch information
SimonWahlin and YanaXu authored Jan 10, 2025
1 parent dd82de4 commit 876ca26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Resources/ResourceManager/Utilities/BicepUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public static BicepUtility Create()

private const string MinimalVersionRequirementForBicepparamFileBuildWithInlineOverrides = "0.22.6";

private const string MinimalVersionRequirementForBicepPublishWithNewDocumentationUriParameter = "0.24.24";

public delegate void OutputCallback(string msg);

private readonly IProcessInvoker processInvoker;
Expand Down Expand Up @@ -153,7 +155,12 @@ public void PublishFile(string bicepFilePath, string target, string documentatio
if (!string.IsNullOrWhiteSpace(documentationUri))
{
CheckMinimalVersionRequirement(MinimalVersionRequirementForBicepPublishWithOptionalDocumentationUriParameter);
bicepPublishCommand += $" --documentationUri {GetQuotedFilePath(documentationUri)}";

if (IsBicepMinimalVersion(MinimalVersionRequirementForBicepPublishWithNewDocumentationUriParameter)) {
bicepPublishCommand += $" --documentation-uri {GetQuotedFilePath(documentationUri)}";
} else {
bicepPublishCommand += $" --documentationUri {GetQuotedFilePath(documentationUri)}";
}
}

if (withSource)
Expand Down Expand Up @@ -196,6 +203,9 @@ private string CheckMinimalVersionRequirement(string minimalVersionRequirement)
return BicepVersion;
}

private bool IsBicepMinimalVersion(string minimalVersionRequirement) =>
Version.Parse(minimalVersionRequirement).CompareTo(Version.Parse(BicepVersion)) > 0;

/// <summary>
/// Runs a bicep command, and returns stdout as a string.
/// </summary>
Expand Down Expand Up @@ -225,4 +235,4 @@ private string RunBicepCommand(string arguments, string minimalVersionRequiremen
private static string GetQuotedFilePath(string filePath)
=> $"\"{filePath.Replace("\"", "\\\"")}\"";
}
}
}
1 change: 1 addition & 0 deletions src/Resources/Resources/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->

## Upcoming Release
* Updated to use bicep parameter --documentation-uri instead of the deprecated --documentationUri
* Upgraded nuget package to signed package.
* Added DefaultApiVersion to the returned properties of the `Get-AzResourceProvider` cmdlet's Resource Type array
* Added Diagnostics/Warnings to WhatIf/Validate results for deployments.
Expand Down

0 comments on commit 876ca26

Please # to comment.