|
44 | 44 | }
|
45 | 45 |
|
46 | 46 | process {
|
47 |
| - Write-Debug 'Context:' |
48 |
| - $contextObj | Out-String -Stream | ForEach-Object { Write-Debug $_ } |
| 47 | + if ($DebugPreference -eq 'Continue') { |
| 48 | + Write-Debug 'Context:' |
| 49 | + $contextObj | Out-String -Stream | ForEach-Object { Write-Debug $_ } |
| 50 | + Write-Debug "Getting info on the context [$($contextObj['AuthType'])]." |
| 51 | + } |
49 | 52 |
|
50 | 53 | # Run functions to get info on the temporary context.
|
51 | 54 | try {
|
52 |
| - Write-Debug "Getting info on the context [$($contextObj['AuthType'])]." |
53 | 55 | switch -Regex (($contextObj['AuthType'])) {
|
54 | 56 | 'PAT|UAT|IAT' {
|
55 | 57 | $viewer = Get-GitHubViewer -Context $contextObj
|
|
79 | 81 | try {
|
80 | 82 | $app = Get-GitHubApp -Slug $contextObj['Username'] -Context $contextObj
|
81 | 83 | $contextObj['DisplayName'] = [string]$app.Name
|
82 |
| - # TODO: $contextObj['App'] = $app |
| 84 | + $contextObj['App'] = $app |
83 | 85 | } catch {
|
84 |
| - Write-Warning "Failed to get the GitHub App with the slug: [$($contextObj['Username'])]." |
| 86 | + Write-Warning "Unable to get the GitHub App: [$($contextObj['Username'])]." |
85 | 87 | }
|
86 | 88 | }
|
87 | 89 | if ($script:IsGitHubActions) {
|
|
114 | 116 | if ([string]::IsNullOrEmpty($contextObj['InstallationName'])) {
|
115 | 117 | $contextObj['InstallationName'] = [string]$installationName
|
116 | 118 | }
|
117 |
| - $contextObj['Name'] = "$($contextObj['HostName'])/$($contextObj['Username'])/" + |
118 |
| - "$($contextObj['InstallationType'])/$($contextObj['InstallationName'])" |
119 |
| - } else { |
120 |
| - $contextObj['Name'] = "$($contextObj['HostName'])/$($contextObj['Username'])/" + |
121 |
| - "$($contextObj['InstallationType'])/$($contextObj['InstallationName'])" |
122 | 119 | }
|
| 120 | + $contextObj['Name'] = "$($contextObj['HostName'])/$($contextObj['Username'])/" + |
| 121 | + "$($contextObj['InstallationType'])/$($contextObj['InstallationName'])" |
123 | 122 | }
|
124 | 123 | 'App' {
|
125 | 124 | $app = Get-GitHubApp -Context $contextObj
|
|
132 | 131 | $contextObj['Events'] = [string[]]$app.Events
|
133 | 132 | $contextObj['OwnerName'] = [string]$app.Owner.Name
|
134 | 133 | $contextObj['OwnerType'] = [string]$app.Owner.Type
|
135 |
| - $contextObj['App'] = $app |
| 134 | + $contextObj['App'] = [GitHubApp]$app |
136 | 135 | $contextObj['Type'] = 'App'
|
137 | 136 | }
|
138 | 137 | default {
|
139 | 138 | throw 'Failed to get info on the context. Unknown logon type.'
|
140 | 139 | }
|
141 | 140 | }
|
142 |
| - Write-Debug "Found [$($contextObj['Type'])] with login: [$($contextObj['Name'])]" |
143 |
| - $contextObj | Out-String -Stream | ForEach-Object { Write-Debug $_ } |
144 |
| - Write-Debug '----------------------------------------------------' |
145 |
| - if ($PSCmdlet.ShouldProcess('Context', 'Set')) { |
| 141 | + if ($DebugPreference -eq 'Continue') { |
| 142 | + Write-Debug "Found [$($contextObj['Type'])] with login: [$($contextObj['Name'])]" |
| 143 | + $contextObj | Out-String -Stream | ForEach-Object { Write-Debug $_ } |
| 144 | + Write-Debug '----------------------------------------------------' |
146 | 145 | Write-Debug "Saving context: [$($contextObj['Name'])]"
|
| 146 | + } |
| 147 | + if ($PSCmdlet.ShouldProcess('Context', 'Set')) { |
147 | 148 | Set-Context -ID $($contextObj['Name']) -Context $contextObj -Vault $script:GitHub.ContextVault
|
148 | 149 | if ($Default) {
|
149 | 150 | Switch-GitHubContext -Context $contextObj['Name']
|
|
0 commit comments