diff --git a/base/profile.d/Docker.class.ps1 b/base/profile.d/Docker.class.ps1 index 11d3132..4b00cdb 100644 --- a/base/profile.d/Docker.class.ps1 +++ b/base/profile.d/Docker.class.ps1 @@ -12,9 +12,9 @@ class DockerContainer { #: System.Management.Automation.IValidateSetValuesGenera } class DockerComposeDirs { #: System.Management.Automation.IValidateSetValuesGenerator { - static [string[]] _GetValidValues([string]$wordToComplete,[bool]$Strict) { + static [string[]] _GetValidValues([string]$wordToComplete,[string]$Path,[bool]$Strict) { $local:possibleValues = $( - Get-ChildItem -Directory -Depth 3 | + Get-ChildItem -LiteralPath $Path -Directory -Depth 3 | Where-Object { $_ | Get-ChildItem -Include 'docker-compose.y*l' | Where-Object Extension -in '.yml','.yaml' @@ -24,6 +24,10 @@ class DockerComposeDirs { #: System.Management.Automation.IValidateSetValuesGene ) return $(Get-PossibleArguments -WordToComplete $wordToComplete -FullValueSet $possibleValues -Strict:$Strict ); } + + static [string[]] _GetValidValues([string]$wordToComplete,[bool]$Strict) { + return [DockerComposeDirs]::_GetValidValues($wordToComplete,'.',$true) + } [String[]] GetValidValues() { return [DockerComposeDirs]::_GetValidValues('',$true) diff --git a/docker/Invoke-DockerCompose.ps1 b/docker/Invoke-DockerCompose.ps1 index 8c6d96f..a67849e 100644 --- a/docker/Invoke-DockerCompose.ps1 +++ b/docker/Invoke-DockerCompose.ps1 @@ -64,19 +64,27 @@ if( $CliParams[0] -is [string] ) { $CliParams = @($CliParams,@($null)) } -$local:dcPathList = $ProjectPath | ForEach-Object { - if( (Test-Path (Join-Path $_ 'docker-compose.yml')) -and -not $Recurse ) { - Resolve-Path $_ - } elseif( $Recurse ) { - $local:gciParams = [ordered]@{ - Recurse = $true +$local:ext = ".yml" +$local:dcPathList = @() +$ProjectPath | ForEach-Object { + while( $true ) { + if( (Test-Path (Join-Path $_ "docker-compose$ext")) -and -not $Recurse ) { + $dcPathList += Resolve-Path $_ + } elseif( $Recurse ) { + $local:gciParams = [ordered]@{ + Recurse = $true + } + if( $Depth ) { + $gciParams.Depth = $Depth + } + $dcPathList += Get-ChildItem -Path $_ -Include "docker-compose$ext" @gciParams | + Select-Object -ExpandProperty Directory | + Where-Object { $Force -or -not (Test-Path $(Join-Path $_ .noauto.all)) } } - if( $Depth ) { - $gciParams.Depth = $Depth + if( ($dcPathList -and -not $Recure) -or $ext -eq '.yaml' ) { + break } - Get-ChildItem -Path $_ -Include 'docker-compose.yml' @gciParams | - Select-Object -ExpandProperty Directory | - Where-Object { $Force -or -not (Test-Path $(Join-Path $_ .noauto.all)) } + $ext = '.yaml' } } if( -not $dcPathList ) { return } @@ -106,7 +114,10 @@ foreach( $local:p in $CliParams ) { } $dcPathList | ForEach-Object { - $local:dcPath = Join-Path $_ 'docker-compose.yml' + $local:dcPath = Join-Path $_ 'docker-compose.yaml' + if( -not (Test-Path $dcPath) ) { + $dcPath = Join-Path $_ 'docker-compose.yml' + } if( -not (Test-Path $dcPath) ) { if( $Recurse ) { return } else { throw "ERROR: dcPath ($dcPath) does not exists" }