flnxi-Wu/scripts/check-harbor.ps1
WuYongJie d1c6efc79d
Some checks failed
CI Check / check (push) Has been cancelled
feat: NAS 部署与 Harbor 推送流程
2025-12-03 14:39:06 +08:00

24 lines
916 B
PowerShell

# 检查 Harbor 镜像
$authBody = @{
principal = 'admin'
password = 'Harbor12345'
} | ConvertTo-Json
$token = (Invoke-RestMethod -Uri 'https://harbor.flnxi.com/api/v2.0/users/login' -Method Post -Body $authBody -ContentType 'application/json' -SkipCertificateCheck).token
$headers = @{
Authorization = "Bearer $token"
}
$artifacts = Invoke-RestMethod -Uri 'https://harbor.flnxi.com/api/v2.0/projects/flnxi/repositories/flnxi-material/artifacts' -Method Get -Headers $headers -SkipCertificateCheck
Write-Host "找到 $($artifacts.Count) 个镜像版本" -ForegroundColor Cyan
Write-Host ""
foreach ($artifact in $artifacts) {
$tags = if ($artifact.tags) { ($artifact.tags | ForEach-Object { $_.name }) -join ', ' } else { 'no-tag' }
$sizeMB = [Math]::Round($artifact.size / 1MB, 2)
$timeStr = $artifact.push_time
Write-Host "$tags - ${sizeMB}MB - $timeStr" -ForegroundColor Yellow
}