Skip to content
Snippets Groups Projects
Commit ae15499a authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Generalize NewConfig-IsValid to Config-IsValid.

The updater should also check if an existing configuration that won't be
updated validates correctly with newer service binaries and stop the
process of updating if the check fails.

Refers to #28
parent 4c565f80
No related branches found
No related tags found
No related merge requests found
......@@ -306,7 +306,7 @@ function NewConfig-Available {
}
function NewConfig-IsValid {
function Config-IsValid {
# Check if the new configuration provided at $UpdPathConfig validates with
# the appropriate "AutoTxConfigTest" binary (either the existing one in the
# service installation directory (if the service binaries won't be updated)
......@@ -319,19 +319,23 @@ function NewConfig-IsValid {
Param (
[Parameter(Mandatory=$True)]
[ValidateScript({(Test-Path $_ -PathType Leaf)})]
[String]$ConfigTest
[String]$ConfigTest,
[Parameter(Mandatory=$True)]
[ValidateScript({(Test-Path $_ -PathType Container)})]
[String]$ConfigPath
)
Write-Verbose "Running [$($ConfigTest) $($UpdPathConfig)]..."
$Summary = & $ConfigTest $UpdPathConfig
Write-Verbose "Running [$($ConfigTest) $($ConfigPath)]..."
$Summary = & $ConfigTest $ConfigPath
$Ret = $?
# pipe through Out-String to preserve line breaks:
$Summary = "$("=" * 80)`n$($Summary | Out-String)`n$("=" * 80)"
if ($Ret) {
Log-Debug "Successfully validated new configuration files!`n$($Summary)"
Log-Debug "Validated config files at [$($ConfigPath)]!`n$($Summary)"
Return $Ret, $Summary
}
Log-Error "Config at [$($UpdPathConfig)] failed validation!`n$($Summary)"
Log-Error "Config at [$($ConfigPath)] FAILED VALIDATION!`n$($Summary)"
Return $Ret, $Summary
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment