PowerShell_Scripts/base/profile.d/Docker.class.ps1
lksz 42b39f4e25 Introducing Packages
Major Overhaul with Breaking Changes
split into packaged, default behavior moved into 'base' package
each package has a json package description file with criteria for
loading

Modified Setup-Profile to refer to 'base' package path for auto loading

moved Linux aliases and command to 'base.linux' package
created 'docker' package to address docker supported systems

modified Get-MyScripts, Edit-MyScripts and Reload-MyScripts accordingly.

Dropped -System and sys.*, package json conditions will take care of it.

Supplied command to create/edit package json files:
  - New-MyPackage
  - Add-PackageCondition
  - Set-MyPackage
2020-11-25 00:46:33 -05:00

32 lines
1.2 KiB
PowerShell

class DockerContainer { #: System.Management.Automation.IValidateSetValuesGenerator {
static [string[]] _GetValidValues([string]$wordToComplete,[bool]$Strict) {
$local:possibleValues = $(
docker ps -a --no-trunc --format "{{.Names}}"
)
return $(Get-PossibleArguments -WordToComplete $wordToComplete -FullValueSet $possibleValues -Strict:$Strict );
}
[String[]] GetValidValues() {
return [DockerContainer]::_GetValidValues('',$true)
}
}
class DockerComposeDirs { #: System.Management.Automation.IValidateSetValuesGenerator {
static [string[]] _GetValidValues([string]$wordToComplete,[bool]$Strict) {
$local:possibleValues = $(
Get-ChildItem -Directory -Depth 3 |
Where-Object { $_ |
Get-ChildItem -Include 'docker-compose.y*l' |
Where-Object Extension -in '.yml','.yaml'
} | ForEach-Object {
$_.FullName.Replace($(Join-Path $PWD ""),'')
}
)
return $(Get-PossibleArguments -WordToComplete $wordToComplete -FullValueSet $possibleValues -Strict:$Strict );
}
[String[]] GetValidValues() {
return [DockerComposeDirs]::_GetValidValues('',$true)
}
}