Skip to content

Commit

Permalink
convertto-ghgocreds
Browse files Browse the repository at this point in the history
  • Loading branch information
Freddy Kristiansen committed Sep 27, 2021
1 parent 4761674 commit 45ea561
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion BcContainerHelper.psd1
Expand Up @@ -91,7 +91,7 @@ FunctionsToExport = 'Add-FontsToBcContainer', 'Add-GitToAlProjectFolder',
'Get-BcContainerApiCompanyId', 'Get-BcContainerApp',
'Get-BcContainerAppInfo', 'Get-BcContainerAppRuntimePackage',
'Convert-BcAppsToRuntimePackages', 'Get-PlainText',
'ConvertTo-HashTable', 'ConvertTo-OrderedDictionary',
'ConvertTo-HashTable', 'ConvertTo-OrderedDictionary', 'ConvertTo-GitHubGoCredentials',
'Get-BcContainerArtifactUrl', 'Get-BcContainerBcUser',
'Get-BcContainerCountry', 'Get-BcContainerDebugInfo',
'Get-BcContainerEula', 'Get-BcContainerEventLog',
Expand Down
1 change: 1 addition & 0 deletions BcContainerHelper.psm1
Expand Up @@ -347,6 +347,7 @@ Check-BcContainerHelperPermissions -Silent
. (Join-Path $PSScriptRoot "Misc\Get-PlainText.ps1")
. (Join-Path $PSScriptRoot "Misc\ConvertTo-HashTable.ps1")
. (Join-Path $PSScriptRoot "Misc\ConvertTo-OrderedDictionary.ps1")
. (Join-Path $PSScriptRoot "Misc\ConvertTo-GitHubGoCredentials.ps1")

# Company Handling functions
. (Join-Path $PSScriptRoot "CompanyHandling\Copy-CompanyInNavContainer.ps1")
Expand Down
25 changes: 25 additions & 0 deletions Misc/ConvertTo-GitHubGoCredentials.ps1
@@ -0,0 +1,25 @@
<#
.Synopsis
Convert HashTable (authContext) to GitHub-Go Credentials
.Description
Convert HashTable (authContext) to GitHub-Go Credentials
.Example
New-BcAuthContext -includeDeviceLogin | ConvertTo-GitHubGoCredentials | Set-Clipboard
#>
function ConvertTo-GitHubGoCredentials() {
[CmdletBinding()]
Param(
[parameter(ValueFromPipeline)]
[Hashtable] $bcAuthContext
)
if ($bcAuthContext.ContainsKey('ClientId') -and $bcAuthContext.ContainsKey('ClientSecret') -and $bcAuthContext.clientId -and $bcAuthContext.clientSecret) {
@{ "ClientId" = $bcAuthContext.ClientId; "ClientSecret" = $bcAuthContext.ClientSecret } | ConvertTo-Json -Compress
}
elseif ($bcAuthContext.ContainsKey('RefreshToken') -and $bcAuthContext.RefreshToken) {
@{ "RefreshToken" = $bcAuthContext.RefreshToken } | ConvertTo-Json -Compress
}
else {
throw "BcAuthContext is wrongly formatted"
}
}
Export-ModuleMember -Function ConvertTo-GitHubGoCredentials
1 change: 1 addition & 0 deletions ReleaseNotes.txt
Expand Up @@ -28,6 +28,7 @@ Issue #2084 Add parameter TestRunnerCodeunitId to Run-TestsInBcContainer
Run-AlPipeline should create launch.json if it doesn't exist
Add function ConvertTo-HashTable to convert PSCustomObject to HashTable
Add function ConvertTo-OrderedDictionary to convert PSCustomObject to OrderedDictionary
Add function ConvertTo-GitHubGoCredentials to convert an auth context hashtable to GitHub-Go credentials

2.0.15
Default to process isolation when Host OS is 21H1 and Container OS is 2004
Expand Down

0 comments on commit 45ea561

Please sign in to comment.