dco should handle yaml extensions on top of yml
This commit is contained in:
parent
22d1b7a1bc
commit
c8869ae393
|
@ -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'
|
||||
|
@ -25,6 +25,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)
|
||||
}
|
||||
|
|
|
@ -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" }
|
||||
|
|
Loading…
Reference in New Issue