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:
lksz 2021-01-15 01:15:54 -05:00
parent c453e5bdea
commit dcc9113cda
13 changed files with 172 additions and 70 deletions

View file

@ -8,19 +8,34 @@
)
[DockerComposeDirs]::_GetValidValues($wordToComplete,$true)
})]
[string[]]$ProjectPath=@($PWD),
[string[]]$UpCliParams,
[string[]]$ProjectPath,
[switch]$Recurse,
[int]$Depth=1,
[switch]$NoLogs,
[switch]$NoPull,
[array]$PullParams,
[array]$LogsParams,
[array]$UpParams,
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
[string[]]$CliParams
[array]$Containers
)
if( -not $Containers -or ($Containers[0] -is [string]) ) { $Containers = @($Containers,@($null)) }
if( -not $UpParams -or ($UpParams[0] -is [string]) ) { $UpParams = @($UpParams,@($null)) }
if( -not $PullParams -or ($PullParams[0] -is [string]) ) { $PullParams = @($PullParams,@($null)) }
if( -not $LogsParams -or ($LogsParams[0] -is [string]) ) { $LogsParams = @($LogsParams,@($null)) }
$UpParams[0] = @('--force-recreate') + $UpParams[0]
$local:passParams = [ordered]@{
ProjectPath=$ProjectPath
UpCliParams=@('--force-recreate')
Recurse=$Recurse
Depth=$Depth
NoLogs=$NoLogs
NoPull=$NoPull
PullParams=$PullParams
LogsParams=$LogsParams
UpParams=$UpParams
Containers=$Containers
}
if( $UpCliParams ) { $passParams.UpCliParams += $UpCliParams }
if( $CliParams ) { $passParams.CliParams = $CliParams }
dcup @passParams
# docker-compose --file $dcPath up -d --force-recreate --remove-orphans $dcParams && docker-compose logs --follow --tail 10 $dcParams