24 lines
916 B
PowerShell
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
|
|
}
|
|
|