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 {
|
class DockerComposeDirs { #: System.Management.Automation.IValidateSetValuesGenerator {
|
||||||
static [string[]] _GetValidValues([string]$wordToComplete,[bool]$Strict) {
|
static [string[]] _GetValidValues([string]$wordToComplete,[string]$Path,[bool]$Strict) {
|
||||||
$local:possibleValues = $(
|
$local:possibleValues = $(
|
||||||
Get-ChildItem -Directory -Depth 3 |
|
Get-ChildItem -LiteralPath $Path -Directory -Depth 3 |
|
||||||
Where-Object { $_ |
|
Where-Object { $_ |
|
||||||
Get-ChildItem -Include 'docker-compose.y*l' |
|
Get-ChildItem -Include 'docker-compose.y*l' |
|
||||||
Where-Object Extension -in '.yml','.yaml'
|
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 );
|
return $(Get-PossibleArguments -WordToComplete $wordToComplete -FullValueSet $possibleValues -Strict:$Strict );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static [string[]] _GetValidValues([string]$wordToComplete,[bool]$Strict) {
|
||||||
|
return [DockerComposeDirs]::_GetValidValues($wordToComplete,'.',$true)
|
||||||
|
}
|
||||||
|
|
||||||
[String[]] GetValidValues() {
|
[String[]] GetValidValues() {
|
||||||
return [DockerComposeDirs]::_GetValidValues('',$true)
|
return [DockerComposeDirs]::_GetValidValues('',$true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,12 @@ if( $CliParams[0] -is [string] ) {
|
||||||
$CliParams = @($CliParams,@($null))
|
$CliParams = @($CliParams,@($null))
|
||||||
}
|
}
|
||||||
|
|
||||||
$local:dcPathList = $ProjectPath | ForEach-Object {
|
$local:ext = ".yml"
|
||||||
if( (Test-Path (Join-Path $_ 'docker-compose.yml')) -and -not $Recurse ) {
|
$local:dcPathList = @()
|
||||||
Resolve-Path $_
|
$ProjectPath | ForEach-Object {
|
||||||
|
while( $true ) {
|
||||||
|
if( (Test-Path (Join-Path $_ "docker-compose$ext")) -and -not $Recurse ) {
|
||||||
|
$dcPathList += Resolve-Path $_
|
||||||
} elseif( $Recurse ) {
|
} elseif( $Recurse ) {
|
||||||
$local:gciParams = [ordered]@{
|
$local:gciParams = [ordered]@{
|
||||||
Recurse = $true
|
Recurse = $true
|
||||||
|
@ -74,10 +77,15 @@ $local:dcPathList = $ProjectPath | ForEach-Object {
|
||||||
if( $Depth ) {
|
if( $Depth ) {
|
||||||
$gciParams.Depth = $Depth
|
$gciParams.Depth = $Depth
|
||||||
}
|
}
|
||||||
Get-ChildItem -Path $_ -Include 'docker-compose.yml' @gciParams |
|
$dcPathList += Get-ChildItem -Path $_ -Include "docker-compose$ext" @gciParams |
|
||||||
Select-Object -ExpandProperty Directory |
|
Select-Object -ExpandProperty Directory |
|
||||||
Where-Object { $Force -or -not (Test-Path $(Join-Path $_ .noauto.all)) }
|
Where-Object { $Force -or -not (Test-Path $(Join-Path $_ .noauto.all)) }
|
||||||
}
|
}
|
||||||
|
if( ($dcPathList -and -not $Recure) -or $ext -eq '.yaml' ) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
$ext = '.yaml'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( -not $dcPathList ) { return }
|
if( -not $dcPathList ) { return }
|
||||||
|
|
||||||
|
@ -106,7 +114,10 @@ foreach( $local:p in $CliParams ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$dcPathList | ForEach-Object {
|
$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( -not (Test-Path $dcPath) ) {
|
||||||
if( $Recurse ) { return }
|
if( $Recurse ) { return }
|
||||||
else { throw "ERROR: dcPath ($dcPath) does not exists" }
|
else { throw "ERROR: dcPath ($dcPath) does not exists" }
|
||||||
|
|
Loading…
Reference in New Issue