暂存提交
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
$env:NACOS_SERVER_ADDR = '127.0.0.1:8848'
|
||||
$env:NACOS_NAMESPACE = 'public'
|
||||
$env:NACOS_GROUP = 'BAIYUE'
|
||||
$env:SPRING_CLOUD_NACOS_CONFIG_ENCODE = 'UTF-8'
|
||||
$env:REDIS_HOST = '127.0.0.1'
|
||||
$env:REDIS_PORT = '6379'
|
||||
$env:SPRING_DATA_REDIS_HOST = '127.0.0.1'
|
||||
|
||||
@@ -12,7 +12,7 @@ $publishUrl = "http://$ServerAddr/nacos/v1/cs/configs"
|
||||
|
||||
$health = Invoke-WebRequest -UseBasicParsing -Uri $healthUrl -TimeoutSec 5
|
||||
if ($health.StatusCode -ne 200 -or $health.Content.Trim() -ne 'OK') {
|
||||
throw "Local Nacos is not ready: $healthUrl"
|
||||
throw "Nacos not ready: $healthUrl"
|
||||
}
|
||||
|
||||
$files = Get-ChildItem -LiteralPath $configRoot -File -Filter '*.yml' | Sort-Object Name
|
||||
@@ -32,9 +32,13 @@ foreach ($file in $files) {
|
||||
$body.tenant = $Namespace
|
||||
}
|
||||
|
||||
$pairs = foreach ($entry in $body.GetEnumerator()) {
|
||||
[uri]::EscapeDataString([string]$entry.Key) + '=' + [uri]::EscapeDataString([string]$entry.Value)
|
||||
}
|
||||
$form = $pairs -join '&'
|
||||
$result = Invoke-RestMethod -Method Post -Uri $publishUrl `
|
||||
-ContentType 'application/x-www-form-urlencoded; charset=UTF-8' `
|
||||
-Body $body -TimeoutSec 10
|
||||
-Body $form -TimeoutSec 10
|
||||
if ([string]$result -ne 'true') {
|
||||
throw "Publish failed: $($file.Name), Nacos response: $result"
|
||||
}
|
||||
@@ -42,4 +46,4 @@ foreach ($file in $files) {
|
||||
Write-Host "Published $($file.Name) -> $Namespace / $Group"
|
||||
}
|
||||
|
||||
Write-Host "Local first-leg Nacos configuration published: $published items."
|
||||
Write-Host "Published local Nacos configuration: $published items."
|
||||
|
||||
Reference in New Issue
Block a user