Skip to content

Commit

Permalink
🩹 [Patch]: Refactor Get-GitHubAppByName function for improved context…
Browse files Browse the repository at this point in the history
… handling and logging (#202)

## Description

- Refactor Get-GitHubAppByName function for improved context handling
and logging

## Type of change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] 📖 [Docs]
- [ ] 🪲 [Fix]
- [x] 🩹 [Patch]
- [ ] ⚠️ [Security fix]
- [ ] 🚀 [Feature]
- [ ] 🌟 [Breaking change]

## Checklist

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
  • Loading branch information
MariusStorhaug authored Dec 13, 2024
1 parent 47a0b35 commit 1f66b0e
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/functions/private/Apps/Get-GitHubAppByName.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,25 @@
[object] $Context = (Get-GitHubContext)
)

$Context = Resolve-GitHubContext -Context $Context

$inputObject = @{
Context = $Context
APIEndpoint = "/apps/$AppSlug"
Method = 'GET'
begin {
$commandName = $MyInvocation.MyCommand.Name
Write-Verbose "[$commandName] - Start"
$Context = Resolve-GitHubContext -Context $Context
Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
process {
$inputObject = @{
Context = $Context
APIEndpoint = "/apps/$AppSlug"
Method = 'GET'
}

Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}
end {
Write-Verbose "[$commandName] - End"
}
}

0 comments on commit 1f66b0e

Please sign in to comment.