Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve tokens from secrets management #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions modules/sdwheeler.GitTools/sdwheeler.GitTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function GetIterationPaths {
$baseurl = 'https://dev.azure.com/msft-skilling/content/powershell/_apis'
$apiurl = 'work/teamsettings/iterations?api-version=7.0'
$username = ' '
$password = ConvertTo-SecureString $env:CLDEVOPS_TOKEN -AsPlainText -Force
$password = Get-Secret -Name CLDEVOPS_TOKEN
$cred = [PSCredential]::new($username, $password)
$params = @{
uri = "$baseurl/$apiurl"
Expand Down Expand Up @@ -87,7 +87,7 @@ function Get-RepoData {
$apiurl = 'https://api.github.com/repos/' + $currentRepo.id
$hdr = @{
Accept = 'application/vnd.github.json'
Authorization = "token ${Env:\GITHUB_TOKEN}"
Authorization = "token $(Get-Secret -Name GITHUB_TOKEN -AsPlainText)"
}
break
}
Expand Down Expand Up @@ -492,7 +492,7 @@ function Get-RepoStatus {
)
$hdr = @{
Accept = 'application/vnd.github.VERSION.full+json'
Authorization = "token ${Env:\GITHUB_TOKEN}"
Authorization = "token $(Get-Secret -Name GITHUB_TOKEN -AsPlainText)"
}

$azlist = 'MicrosoftDocs/azure-docs-powershell', 'Azure/azure-docs-powershell-samples',
Expand Down Expand Up @@ -665,7 +665,7 @@ function Invoke-GitHubApi {
}
$hdr = @{
Accept = 'application/vnd.github.v3.raw+json'
Authorization = "token ${Env:\GITHUB_TOKEN}"
Authorization = "token $(Get-Secret -Name GITHUB_TOKEN -AsPlainText)"
}
$results = Invoke-RestMethod -Headers $hdr -Uri $uri -Method $method -FollowRelLink
foreach ($page in $results) { $page }
Expand Down Expand Up @@ -713,7 +713,7 @@ function Import-GitHubLabels {

$hdr = @{
Accept = 'application/vnd.github.v3+json'
Authorization = "token ${Env:\GITHUB_TOKEN}"
Authorization = "token $(Get-Secret -Name GITHUB_TOKEN -AsPlainText)"
}
$api = "https://api.github.com/repos/$RepoName/labels"

Expand Down Expand Up @@ -744,7 +744,7 @@ function Get-PrFiles {
)
$hdr = @{
Accept = 'application/vnd.github.VERSION.full+json'
Authorization = "token ${Env:\GITHUB_TOKEN}"
Authorization = "token $(Get-Secret -Name GITHUB_TOKEN -AsPlainText)"
}

$pr = Invoke-RestMethod "https://api.github.com/repos/$repo/pulls/$num" -Method GET -head $hdr -FollowRelLink
Expand All @@ -771,7 +771,7 @@ function Get-PrMerger {

$hdr = @{
Accept = 'application/vnd.github.v3+json'
Authorization = "token ${Env:\GITHUB_TOKEN}"
Authorization = "token $(Get-Secret -Name GITHUB_TOKEN -AsPlainText)"
}
$query = "q=type:pr+is:merged+repo:$RepoName"

Expand Down Expand Up @@ -806,7 +806,7 @@ function Get-Issue {

$hdr = @{
Accept = 'application/vnd.github.v3+json'
Authorization = "token ${Env:\GITHUB_TOKEN}"
Authorization = "token $(Get-Secret -Name GITHUB_TOKEN -AsPlainText)"
}
if ($null -ne $IssueUrl) {
$RepoName = ($IssueUrl.Segments[1..2] -join '').trim('/')
Expand Down Expand Up @@ -840,7 +840,7 @@ function Get-IssueList {
)
$hdr = @{
Accept = 'application/vnd.github.v3.raw+json'
Authorization = "token ${Env:\GITHUB_TOKEN}"
Authorization = "token $(Get-Secret -Name GITHUB_TOKEN -AsPlainText)"
}
$apiurl = "https://api.github.com/repos/$RepoName/issues"
$results = (Invoke-RestMethod $apiurl -Headers $hdr -FollowRelLink)
Expand Down Expand Up @@ -874,7 +874,7 @@ function New-PrFromBranch {
$repo = (Show-RepoData)
$hdr = @{
Accept = 'application/vnd.github.raw+json'
Authorization = "token ${Env:\GITHUB_TOKEN}"
Authorization = "token $(Get-Secret -Name GITHUB_TOKEN -AsPlainText)"
}
$apiurl = "https://api.github.com/repos/$($repo.id)/pulls"

Expand Down Expand Up @@ -960,7 +960,7 @@ function Get-DevOpsWorkItem {
if (-not $Verbose) {$Verbose = $false}

$username = ' '
$password = ConvertTo-SecureString $env:CLDEVOPS_TOKEN -AsPlainText -Force
$password = Get-Secret -Name CLDEVOPS_TOKEN
$cred = [PSCredential]::new($username, $password)

$vsuri = 'https://dev.azure.com'
Expand Down Expand Up @@ -1018,7 +1018,7 @@ function New-DevOpsWorkItem {
if (-not $Verbose) {$Verbose = $false}

$username = ' '
$password = ConvertTo-SecureString $env:CLDEVOPS_TOKEN -AsPlainText -Force
$password = Get-Secret -Name CLDEVOPS_TOKEN
$cred = [PSCredential]::new($username, $password)

$vsuri = 'https://dev.azure.com'
Expand Down Expand Up @@ -1161,7 +1161,7 @@ function Update-DevOpsWorkItem {
if (-not $Verbose) {$Verbose = $false}

$username = ' '
$password = ConvertTo-SecureString $env:CLDEVOPS_TOKEN -AsPlainText -Force
$password = Get-Secret -Name CLDEVOPS_TOKEN
$cred = [PSCredential]::new($username, $password)

$vsuri = 'https://dev.azure.com'
Expand Down Expand Up @@ -1462,7 +1462,7 @@ function New-MergeToLive {
)
$hdr = @{
Accept = 'application/vnd.github.v3+json'
Authorization = "token ${Env:\GITHUB_TOKEN}"
Authorization = "token $(Get-Secret -Name GITHUB_TOKEN -AsPlainText)"
}
$apiurl = "https://api.github.com/repos/$($repo.id)/pulls"
$params = @{
Expand Down