Skip to content

Commit

Permalink
Refactor Assert-GitHubContext to use 'object' for Context parameter a…
Browse files Browse the repository at this point in the history
…nd add verbose logging
  • Loading branch information
MariusStorhaug committed Dec 14, 2024
1 parent 7b4aec1 commit 5173300
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/functions/public/Auth/Assert-GitHubContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,27 @@
Mandatory,
ValueFromPipeline
)]
[GitHubContext] $Context,
[object] $Context,

# The required authtypes for the command.
[Parameter(Mandatory)]
[string[]] $AuthType
)

$command = (Get-PSCallStack)[1].Command
begin {
$commandName = $MyInvocation.MyCommand.Name
Write-Verbose "[$commandName] - Start"
}

process {
$command = (Get-PSCallStack)[1].Command

if ($Context.AuthType -notin $AuthType) {
throw "The context '$($Context.Name)' does not match the required AuthTypes [$AuthType] for [$command]."
}
}

if ($Context.AuthType -notin $AuthType) {
throw "The context '$($Context.Name)' does not match the required AuthTypes [$AuthType] for [$command]."
end {
Write-Verbose "[$commandName] - End"
}
}

0 comments on commit 5173300

Please sign in to comment.