infracloud/scripts/auto-organized/check_oke2.ps1

25 lines
1.4 KiB
PowerShell

$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' }
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'
$repoId = 'ae7542f8-d76e-4a45-b8b2-745e18cd2f26'
# Ler config/oke-clusters.json (mencionado no script)
Write-Host "=== config/oke-clusters.json ===" -ForegroundColor Cyan
try {
$content = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?path=/config/oke-clusters.json`&versionDescriptor.version=main`&api-version=7.0" -Headers $h
Write-Host ($content | ConvertTo-Json -Depth 10)
} catch {
Write-Host " Arquivo nao encontrado, tentando /cd/config/..." -ForegroundColor Yellow
try {
$content2 = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?path=/cd/config/oke-clusters.json`&versionDescriptor.version=main`&api-version=7.0" -Headers $h
Write-Host ($content2 | ConvertTo-Json -Depth 10)
} catch {
Write-Host " Nao encontrado tambem em /cd/config/" -ForegroundColor Yellow
}
}
# Mostrar toda a estrutura do repo
Write-Host "`n=== Estrutura raiz do repo ===" -ForegroundColor Cyan
$root = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?scopePath=/`&recursionLevel=OneLevel`&api-version=7.0" -Headers $h
$root.value | Select-Object path, gitObjectType | Format-Table