infracloud/scripts/auto-organized/check_templates.ps1

29 lines
1.3 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'
# Listar todos os templates na pasta cd/
$tree = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?scopePath=/cd`&recursionLevel=OneLevel`&api-version=7.0" -Headers $h
Write-Host "=== Templates em /cd ===" -ForegroundColor Cyan
$tree.value | Where-Object { $_.gitObjectType -eq 'blob' } | Select-Object -ExpandProperty path
# Ler os templates OCI mais importantes
$cdTemplates = @(
'/cd/oci-kubeconfig.yml',
'/cd/argocd-apply-app.yml',
'/cd/argocd-repo-secret.yml',
'/cd/push-ocir-template.yaml',
'/ci/push-ocir-template.yaml'
)
foreach ($tmpl in $cdTemplates) {
Write-Host "`n=== $tmpl ===" -ForegroundColor Cyan
try {
$content = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/items?path=$tmpl`&versionDescriptor.version=main`&api-version=7.0" -Headers $h -ErrorAction Stop
Write-Host $content
} catch {
Write-Host " NAO ENCONTRADO" -ForegroundColor Yellow
}
}