forked from wangbo/easyai
fix(release): 按服务核验 Compose 固定镜像并保留线上修复
This commit is contained in:
@@ -52,10 +52,17 @@ function Test-ApplicationVersionImages {
|
||||
param([object[]]$Plan, [string[]]$ComposeCommand)
|
||||
foreach ($item in $Plan) {
|
||||
if (-not $item.Service) { continue }
|
||||
$args = @($ComposeCommand | Select-Object -Skip 1) + @('config','--images',$item.Service)
|
||||
$args = @($ComposeCommand | Select-Object -Skip 1) + @('config','--format','json',$item.Service)
|
||||
$executable = $ComposeCommand[0]
|
||||
$actual = & $executable @args
|
||||
if ($LASTEXITCODE -ne 0 -or "$actual".Trim() -ne "$($item.Image):$($item.Version)") {
|
||||
$configuration = & $executable @args
|
||||
if ($LASTEXITCODE -ne 0) { throw '无法读取应用的有效镜像定义;尚未拉取或重建服务' }
|
||||
try {
|
||||
# Compose includes dependencies even when a service is selected.
|
||||
# Keep the configuration in memory; do not log its environment.
|
||||
$resolved = ($configuration -join "`n") | ConvertFrom-Json -ErrorAction Stop
|
||||
$actual = $resolved.services.PSObject.Properties[$item.Service].Value.image
|
||||
} catch { throw '无法读取应用的有效镜像定义;尚未拉取或重建服务' }
|
||||
if ("$actual".Trim() -ne "$($item.Image):$($item.Version)") {
|
||||
throw "$($item.Service) 的有效镜像未使用环境中的固定版本;请通过部署仓库的受控迁移恢复镜像定义,尚未拉取或重建服务"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user