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
This commit is contained in:
parent
80a488484b
commit
1792bb23a1
84 changed files with 509 additions and 134 deletions
28
docker/Edit-DockerCompose.ps1
Normal file
28
docker/Edit-DockerCompose.ps1
Normal file
|
@ -0,0 +1,28 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[ArgumentCompleter({ param (
|
||||
$commandName,
|
||||
$parameterName,
|
||||
$wordToComplete,
|
||||
$commandAst,
|
||||
$fakeBoundParameters
|
||||
)
|
||||
[DockerComposeDirs]::_GetValidValues($wordToComplete,$true)
|
||||
})]
|
||||
[string[]]$ProjectPath=@($PWD),
|
||||
[switch]$Force,
|
||||
[string[]]$AdditionalFiles
|
||||
|
||||
)
|
||||
|
||||
$local:editCandidates = @('docker-compose.yml','.base.docker-compose.yml')
|
||||
$local:editFiles = @()
|
||||
foreach( $local:fileName in $EditCandidates ) {
|
||||
foreach( $local:path in $ProjectPath ) {
|
||||
$local:testPath = Join-Path $path $fileName
|
||||
if( $Force -or $(Test-Path $testPath) ) { $editFiles += $testPath }
|
||||
}
|
||||
}
|
||||
|
||||
Edit-TextFile ($($editFiles | Sort-Object) + $AdditionalFiles)
|
||||
|
||||
$editFiles | Select-Object -First 1 | ForEach-Object { docker-compose --file $(Resolve-Path $_) config -q }
|
24
docker/Get-DockerProcess.ps1
Normal file
24
docker/Get-DockerProcess.ps1
Normal file
|
@ -0,0 +1,24 @@
|
|||
#[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[CmdletBinding()]param([string[]]$MatchName,[string[]]$OrderBy,[switch]$PassThru,[string[]]$MatchAny)
|
||||
|
||||
$local:result = $(docker ps --format='{{ .Image }}\t{{ .Names }}\t{{ .Status }}\t{{ .Ports }}' |
|
||||
ForEach-Object {
|
||||
$local:l = $_ -split '\t';
|
||||
[PSCustomObject]([ordered]@{Image=$l[0];Name=$l[1];Status=$l[2];Ports=$l[3] -replace ', ',"`n"})
|
||||
} ) | Sort-Object Name
|
||||
|
||||
if( $MatchName ) {
|
||||
$result = $result | Where-Object Name -match $($MatchName -join '|')
|
||||
}
|
||||
|
||||
if( $MatchAny ) {
|
||||
$result = $result | Where-Object { $_ | Out-String | Where-Object { $_ -match $($MatchAny -join '|') } }
|
||||
}
|
||||
|
||||
if( $OrderBy ) {
|
||||
$result = $result | Sort-Object $OrderBy
|
||||
}
|
||||
|
||||
if( $PassThru ) { return $result }
|
||||
$result | Format-Table -Wrap
|
||||
|
14
docker/_.package.json
Normal file
14
docker/_.package.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"package": {
|
||||
"Condition": [
|
||||
{
|
||||
"custom": "Get-Command docker -Type Application",
|
||||
"System": null,
|
||||
"Hostname": null,
|
||||
"Username": null,
|
||||
"Logic": 0
|
||||
}
|
||||
],
|
||||
"Name": "docker"
|
||||
}
|
||||
}
|
14
docker/dcc.ps1
Normal file
14
docker/dcc.ps1
Normal file
|
@ -0,0 +1,14 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[ArgumentCompleter({ param (
|
||||
$commandName,
|
||||
$parameterName,
|
||||
$wordToComplete,
|
||||
$commandAst,
|
||||
$fakeBoundParameters
|
||||
)
|
||||
[DockerComposeDirs]::_GetValidValues($wordToComplete,$true)
|
||||
})]
|
||||
[string[]]$ProjectPath=@($PWD)
|
||||
)
|
||||
|
||||
$ProjectPath | ForEach-Object { docker-compose --file $(Resolve-Path $(Join-Path $_ docker-compose.yml)) config | less }
|
18
docker/dcdown.ps1
Normal file
18
docker/dcdown.ps1
Normal file
|
@ -0,0 +1,18 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[ArgumentCompleter({ param (
|
||||
$commandName,
|
||||
$parameterName,
|
||||
$wordToComplete,
|
||||
$commandAst,
|
||||
$fakeBoundParameters
|
||||
)
|
||||
[DockerComposeDirs]::_GetValidValues($wordToComplete,$true)
|
||||
})]
|
||||
[string[]]$ProjectPath=@($PWD),
|
||||
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
|
||||
[string[]]$CliParams
|
||||
)
|
||||
|
||||
$ProjectPath | ForEach-Object {
|
||||
docker-compose --file $(Resolve-Path $(Join-Path $_ docker-compose.yml)) down --timeout=3 --volumes --remove-orphans "$CliParams"
|
||||
}
|
1
docker/dcl.ps1
Normal file
1
docker/dcl.ps1
Normal file
|
@ -0,0 +1 @@
|
|||
docker-compose logs --tail=40 --follow "$args"
|
1
docker/dcll.ps1
Normal file
1
docker/dcll.ps1
Normal file
|
@ -0,0 +1 @@
|
|||
docker-compose logs "$args"
|
1
docker/dcr.ps1
Normal file
1
docker/dcr.ps1
Normal file
|
@ -0,0 +1 @@
|
|||
docker-compose run --rm "$args"
|
1
docker/dcre.ps1
Normal file
1
docker/dcre.ps1
Normal file
|
@ -0,0 +1 @@
|
|||
docker-compose restart "$args"
|
11
docker/dcreup.ps1
Normal file
11
docker/dcreup.ps1
Normal file
|
@ -0,0 +1,11 @@
|
|||
#[CmdletBinding(SupportsShouldProcess)]param()
|
||||
|
||||
$local:dcParams = [string]::Empty
|
||||
if( $args ) {
|
||||
$dcParams = $args | ForEach-Object {
|
||||
if( $_ -match "(?:^'[^']+'$)|(?:^`"[^`"]+`"$)|(?:^[^\s]+$)" ) { $_ }
|
||||
else { "'$($_.Replace( "'", "''" ))'" }
|
||||
}
|
||||
}
|
||||
docker-compose up -d --force-recreate --remove-orphans $dcParams && docker-compose logs --follow --tail 10 $dcParams
|
||||
|
28
docker/dcup.ps1
Normal file
28
docker/dcup.ps1
Normal file
|
@ -0,0 +1,28 @@
|
|||
[CmdletBinding(SupportsShouldProcess)]param(
|
||||
[ArgumentCompleter({ param (
|
||||
$commandName,
|
||||
$parameterName,
|
||||
$wordToComplete,
|
||||
$commandAst,
|
||||
$fakeBoundParameters
|
||||
)
|
||||
[DockerComposeDirs]::_GetValidValues($wordToComplete,$true)
|
||||
})]
|
||||
[string[]]$ProjectPath=@($PWD),
|
||||
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
|
||||
[string[]]$CliParams
|
||||
)
|
||||
|
||||
$local:dcParams = [string]::Empty
|
||||
if( $CliParams ) {
|
||||
$dcParams = $CliParams | ForEach-Object {
|
||||
if( $_ -match "(?:^'[^']+'$)|(?:^`"[^`"]+`"$)|(?:^[^\s]+$)" ) { $_ }
|
||||
else { "'$($_.Replace( "'", "''" ))'" }
|
||||
}
|
||||
}
|
||||
$ProjectPath | ForEach-Object {
|
||||
$local:dcPath = $(Resolve-Path $(Join-Path $_ docker-compose.yml))
|
||||
Write-Verbose "docker-compose --file $dcPath up -d --remove-orphans $dcParams && docker-compose --file $dcPath logs --follow --tail 10 $dcParams"
|
||||
docker-compose --file $dcPath up -d --remove-orphans $dcParams && docker-compose --file $dcPath logs --follow --tail 10 $dcParams
|
||||
}
|
||||
|
1
docker/dcx.ps1
Normal file
1
docker/dcx.ps1
Normal file
|
@ -0,0 +1 @@
|
|||
docker-compose exec "$args"
|
1
docker/di.ps1
Normal file
1
docker/di.ps1
Normal file
|
@ -0,0 +1 @@
|
|||
docker inspect "$args"
|
1
docker/dll.ps1
Normal file
1
docker/dll.ps1
Normal file
|
@ -0,0 +1 @@
|
|||
docker logs "$args"
|
1
docker/dlogs.ps1
Normal file
1
docker/dlogs.ps1
Normal file
|
@ -0,0 +1 @@
|
|||
docker logs --tail=40 --follow "$args"
|
1
docker/dx.ps1
Normal file
1
docker/dx.ps1
Normal file
|
@ -0,0 +1 @@
|
|||
docker exec "$args"
|
Loading…
Add table
Add a link
Reference in a new issue