Skip to content

Commit

Permalink
Return rename container response to output stream directly
Browse files Browse the repository at this point in the history
  • Loading branch information
cksapp committed Jan 1, 2025
1 parent f3043a2 commit a1e99a7
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/Public/Containers/Containers/Rename-DBPoolContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ function Rename-DBPoolContainer {

process {

$response = foreach ($n in $Id) {
foreach ($n in $Id) {
$requestResponse = $null
$requestPath = "/api/v2/containers/$n"

# Try to get the container name to output for the ID when using the Verbose preference
if ($VerbosePreference -eq 'Continue') {
try {
$containerName = (Get-DBPoolContainer -Id $n -ErrorAction Stop).name
$containerName = (Get-DBPoolContainer -Id $n -WarningAction SilentlyContinue -ErrorAction Stop -Verbose:$false).name
} catch {
Write-Warning "Failed to get the container name for ID $n. $_"
$containerName = '## FailedToGetContainerName ##'
Expand All @@ -88,20 +88,15 @@ function Rename-DBPoolContainer {
if ($requestResponse.StatusCode -eq 200) {
Write-Information "Successfully updated Container [ ID: $n ]"
}
}
catch {
if ($null -ne $requestResponse) {
$requestResponse | ConvertFrom-Json -ErrorAction Stop
}
} catch {
Write-Error $_
}

if ($null -ne $requestResponse) {
$requestResponse | ConvertFrom-Json
}

}

# Return the response
$response

}

end {}
Expand Down

0 comments on commit a1e99a7

Please sign in to comment.