DockerCompose commands refactoring
All dc... commands are now based on Invoke-DockerCompose. dco is aliased to Invoke-DockerCompose. dco_ is aliased to the docker-compose binary. '&' and '!' shorthand introduced to dco to execut in bg as job and wait for all bg jobs to complete respectively.
This commit is contained in:
parent
c453e5bdea
commit
dcc9113cda
13 changed files with 172 additions and 70 deletions
|
@ -51,9 +51,6 @@ $local:dcPathList = $ProjectPath | ForEach-Object {
|
|||
Get-ChildItem -Path $_ -Include 'docker-compose.yml' @gciParams |
|
||||
Select-Object -ExpandProperty Directory |
|
||||
Where-Object { $Force -or -not (Test-Path $(Join-Path $_ .noauto.all)) }
|
||||
|
||||
# _DIRS_=$( find . -mindepth 1 -maxdepth 1 -type d -exec test -f {}/docker-compose.yml \; -exec test -f {}/.ask.all \; -print | sort )
|
||||
# _DIRS_="$_DIRS_ $( find . -mindepth 1 -maxdepth 1 -type d -exec test -f {}/docker-compose.yml \; -not -exec test -f {}/.ask.all \; -not -exec test -f {}/.noauto.all \; -print | sort )"
|
||||
}
|
||||
}
|
||||
if( -not $dcPathList ) { return }
|
||||
|
@ -75,7 +72,7 @@ foreach( $local:p in $CliParams ) {
|
|||
if( $skipFirst ) { $p = $p | Select-Object -Skip 1 }
|
||||
}
|
||||
|
||||
$dcParams = $p | ForEach-Object {
|
||||
$dcParams = $p | Where-Object { $_ } | ForEach-Object {
|
||||
if( $_ -match "(?:^'[^']+'$)|(?:^`"[^`"]+`"$)|(?:^[^\s]+$)" ) { $_ }
|
||||
else { "'$($_.Replace( "'", "''" ))'" }
|
||||
}
|
||||
|
@ -85,13 +82,15 @@ foreach( $local:p in $CliParams ) {
|
|||
if( -not (Test-Path $dcPath) ) { if( $Recurse ) { return } else { throw "ERROR: dcPath ($dcPath) does not exists" } }
|
||||
|
||||
Write-Verbose "& docker-compose --file $dcPath $dcParams"
|
||||
if( $Wait ) {
|
||||
if( $Wait -and -not $WhatIfPreference ) {
|
||||
CompleteJobs
|
||||
}
|
||||
|
||||
if( -not $dcParams ) { continue }
|
||||
|
||||
if( $AsJob ) {
|
||||
if( $WhatIfPreference ) {
|
||||
Write-Host "In $dcPath Run $(if($AsJob){"(bg) "})with: $dcParams"
|
||||
} elseif( $AsJob ) {
|
||||
$JobQueue += Start-Job -ArgumentList @($dcPath,$dcParams) -ScriptBlock {
|
||||
param($dcPath,$dcParams)
|
||||
[PSCustomObject] $([ordered]@{
|
||||
|
@ -107,6 +106,7 @@ foreach( $local:p in $CliParams ) {
|
|||
}
|
||||
}
|
||||
|
||||
# if( $WhatIfPreference ) { return }
|
||||
|
||||
CompleteJobs
|
||||
if( $CleanupJobQueue ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue