Skip to content

Commit 4498090

Browse files
🩹 [Patch]: Refactor validation logic for KeyVaultKeyReference and PrivateKey in init.ps1
1 parent a336a08 commit 4498090

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

‎scripts/init.ps1

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,26 @@ process {
7979
$providedClientID = -not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_ClientID)
8080
$providedPrivateKey = -not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_PrivateKey)
8181
$providedKeyVaultKeyReference = -not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_KeyVaultKeyReference)
82-
82+
8383
# Validate mutual exclusion of PrivateKey and KeyVaultKeyReference
8484
if ($providedPrivateKey -and $providedKeyVaultKeyReference) {
8585
throw 'Only one of PrivateKey or KeyVaultKeyReference can be provided.'
8686
}
87-
87+
8888
# Validate that if ClientID is provided, exactly one of PrivateKey or KeyVaultKeyReference is also provided
8989
if ($providedClientID -and -not ($providedPrivateKey -or $providedKeyVaultKeyReference)) {
9090
throw 'When ClientID is provided, either PrivateKey or KeyVaultKeyReference must also be provided.'
9191
}
92-
92+
9393
$moduleStatus = [pscustomobject]@{
94-
Name = $Name
95-
Version = [string]::IsNullOrEmpty($Version) ? 'latest' : $Version
96-
Prerelease = $Prerelease
97-
'Already installed' = $null -ne $alreadyInstalled
98-
'Already imported' = $null -ne $alreadyImported
99-
'Provided Token' = $providedToken
100-
'Provided ClientID' = $providedClientID
101-
'Provided PrivateKey' = $providedPrivateKey
94+
Name = $Name
95+
Version = [string]::IsNullOrEmpty($Version) ? 'latest' : $Version
96+
Prerelease = $Prerelease
97+
'Already installed' = $null -ne $alreadyInstalled
98+
'Already imported' = $null -ne $alreadyImported
99+
'Provided Token' = $providedToken
100+
'Provided ClientID' = $providedClientID
101+
'Provided PrivateKey' = $providedPrivateKey
102102
'Provided KeyVaultKeyReference' = $providedKeyVaultKeyReference
103103
}
104104
if ($showInit) {
@@ -116,9 +116,9 @@ process {
116116
Connect-GitHub @params
117117
} elseif ($providedClientID -and $providedKeyVaultKeyReference) {
118118
$params = @{
119-
ClientID = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ClientID
120-
KeyVaultKeyReference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_KeyVaultKeyReference
121-
Silent = (-not $showInit)
119+
ClientID = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ClientID
120+
KeyVaultKeyReference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_KeyVaultKeyReference
121+
Silent = (-not $showInit)
122122
}
123123
Connect-GitHub @params
124124
} elseif ($providedToken) {

0 commit comments

Comments
 (0)