-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update Initialize-AzOpsEnvironment.ps1 Fix jq casing * Update Strings.psd1 Refactor logging messages * Update Invoke-AzOpsNativeCommand.ps1 Add -NoNewLine switch * Update Assert-AzOpsJqDependency.ps1 Add logic to validate installed version * Rename Assert-AzOpsJqDependency.ps1
- Loading branch information
Showing
5 changed files
with
50 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
function Assert-AzOpsJqDependency { | ||
|
||
<# | ||
.SYNOPSIS | ||
Asserts that - if jq is installed and in current path | ||
.DESCRIPTION | ||
Asserts that - if jq is installed and in current path | ||
.PARAMETER Cmdlet | ||
The $PSCmdlet variable of the calling command. | ||
.EXAMPLE | ||
> Assert-AzOpsJqDependency -Cmdlet $PSCmdlet | ||
#> | ||
|
||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory = $false)] | ||
$Cmdlet | ||
) | ||
|
||
process { | ||
Write-PSFMessage -Level InternalComment -String 'Assert-AzOpsJqDependency.Validating' | ||
|
||
$result = (Invoke-AzOpsNativeCommand -ScriptBlock { jq --version } -IgnoreExitcode) | ||
$installed = $result -as [bool] | ||
|
||
if ($installed) { | ||
[double]$version = ($result).Split("-")[1] | ||
if ($version -ge 1.6) { | ||
Write-PSFMessage -Level InternalComment -String 'Assert-AzOpsJqDependency.Success' | ||
return | ||
} | ||
else { | ||
$exception = [System.InvalidOperationException]::new('Unsupported version of jq installed. Please update to a minimum jq version of 1.6') | ||
$errorRecord = [System.Management.Automation.ErrorRecord]::new($exception, "ConfigurationError", 'InvalidOperation', $null) | ||
Write-PSFMessage -Level Warning -String 'Assert-AzOpsJqDependency.Failed' -Tag error | ||
$Cmdlet.ThrowTerminatingError($errorRecord) | ||
} | ||
} | ||
|
||
$exception = [System.InvalidOperationException]::new('Unable to locate jq installation') | ||
$errorRecord = [System.Management.Automation.ErrorRecord]::new($exception, "ConfigurationError", 'InvalidOperation', $null) | ||
Write-PSFMessage -Level Warning -String 'Assert-AzOpsJqDependency.Failed' -Tag error | ||
$Cmdlet.ThrowTerminatingError($errorRecord) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters