Skip to content
This repository was archived by the owner on Mar 11, 2020. It is now read-only.

Commit 43a89cd

Browse files
committed
Module Overhaul + Added Arguement Completion
Small Simplifaction in arguement completers
1 parent 1adbe3f commit 43a89cd

22 files changed

+93
-15
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
function Completion_Artifact {
3+
4+
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
5+
6+
Function Get-Artifacts {
7+
$artifacts = Get-ChildItem -Path $modulepath\Functions\Private\Artifacts -Directory | Select-Object -ExpandProperty BaseName
8+
$artifacts
9+
}
10+
11+
### Create fresh completion results for Artifacts
12+
Get-Artifacts | Where-Object { $PSItem -match $wordToComplete } | ForEach-Object {
13+
$CompletionText = $PSItem;
14+
$ToolTip = $PSItem;
15+
$ListItemText = $PSItem;
16+
$CompletionResultType = [System.Management.Automation.CompletionResultType]::ParameterValue;
17+
18+
New-Object -TypeName System.Management.Automation.CompletionResult -ArgumentList @($CompletionText, $ListItemText, $CompletionResultType, $ToolTip);
19+
}
20+
21+
}
22+
23+
Microsoft.PowerShell.Core\Register-ArgumentCompleter -CommandName ConvertTo-DockerFile -ParameterName Artifact -ScriptBlock $Function:Completion_Artifact
24+

Artifacts/AddRemovePrograms/Discover.ps1 renamed to Functions/Private/Artifacts/AddRemovePrograms/Discover_AddRemovePrograms.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function Discover_AddRemovePrograms {
12
<#
23
.SYNOPSIS
34
Scans for Add/Remove Programs entries
@@ -64,3 +65,6 @@ Write-Verbose -Message 'Finished unmounting the registry hive'
6465
### Write out the discovery results to the manifest file
6566
$SoftwareList | ConvertTo-Json | Set-Content -Path $ManifestPath
6667
Write-Verbose -Message ('Finished discovery for {0} artifact' -f (Split-Path -Path $PSScriptRoot -Leaf))
68+
69+
}
70+

Artifacts/AddRemovePrograms/Generate.ps1 renamed to Functions/Private/Artifacts/AddRemovePrograms/Generate_AddRemovePrograms.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function Generate_AddRemovePrograms {
12
<#
23
.SYNOPSIS
34
Generate Dockerfile contents for Add/Remove Programs entries
@@ -24,3 +25,6 @@ foreach ($Item in $Artifact) {
2425
}
2526

2627
Write-Output -InputObject $Result
28+
29+
}
30+

Artifacts/AllWindowsFeatures/DefaultFeatures.txt renamed to Functions/Private/Artifacts/AllWindowsFeatures/DefaultFeatures.txt

File renamed without changes.

Artifacts/AllWindowsFeatures/Discover.ps1 renamed to Functions/Private/Artifacts/AllWindowsFeatures/Discover_AllWindowsFeatures.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function Discover_AllWindowsFeatures {
12
<#
23
.SYNOPSIS
34
Scans for presence of DHCP Server component in a Windows Server image.
@@ -42,4 +43,6 @@ $ManifestResult.Status = 'Enabled'
4243
### Write the result to the manifest file
4344
$ManifestResult | ConvertTo-Json | Set-Content -Path $Manifest
4445

45-
Write-Verbose -Message ('Finished discovering {0} artifact' -f $ArtifactName)
46+
Write-Verbose -Message ('Finished discovering {0} artifact' -f $ArtifactName)
47+
}
48+

Artifacts/AllWindowsFeatures/Generate.ps1 renamed to Functions/Private/Artifacts/AllWindowsFeatures/Generate_AllWindowsFeatures.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function Generate_AllWindowsFeatures {
12
<#
23
.SYNOPSIS
34
Generates Dockerfile contents for DHCP Server component
@@ -25,4 +26,6 @@ $FeatureNames = $Artifact.FeatureName.replace(';',',')
2526
$Result += "RUN powershell.exe -ExecutionPolicy Bypass -Command Enable-WindowsOptionalFeature -Online -FeatureName $FeatureNames -All `r`n"
2627

2728

28-
Write-Output -InputObject $Result
29+
Write-Output -InputObject $Result
30+
}
31+

Artifacts/Apache/Discover.ps1 renamed to Functions/Private/Artifacts/Apache/Discover_Apache.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function Discover_Apache {
12
<#
23
.SYNOPSIS
34
Scans for the Apache Web Server
@@ -46,4 +47,6 @@ else {
4647
### Write the result to the manifest file
4748
$ManifestResult | ConvertTo-Json | Set-Content -Path $Manifest
4849

49-
Write-Verbose -Message ('Finished discovering {0} artifact' -f $ArtifactName)
50+
Write-Verbose -Message ('Finished discovering {0} artifact' -f $ArtifactName)
51+
}
52+

Artifacts/Apache/Generate.ps1 renamed to Functions/Private/Artifacts/Apache/Generate_Apache.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function Generate_Apache {
12
<#
23
.SYNOPSIS
34
Generates Dockerfile contents for Apache Web Server component
@@ -32,4 +33,6 @@ if ($Artifact.Status -eq 'Present') {
3233
Write-Verbose -Message ('Artifact is present: {0}. Adding text to Dockerfile {1}.' -f $ArtifactName, $Result)
3334
}
3435

35-
Write-Output -InputObject $Result
36+
Write-Output -InputObject $Result
37+
}
38+

Artifacts/DHCPServer/Discover.ps1 renamed to Functions/Private/Artifacts/DHCPServer/Discover_DHCPServer.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function Discover_DHCPServer {
12
<#
23
.SYNOPSIS
34
Scans for presence of DHCP Server component in a Windows Server image.
@@ -40,4 +41,6 @@ else {
4041
### Write the result to the manifest file
4142
$ManifestResult | ConvertTo-Json | Set-Content -Path $Manifest
4243

43-
Write-Verbose -Message ('Finished discovering {0} artifact' -f $ArtifactName)
44+
Write-Verbose -Message ('Finished discovering {0} artifact' -f $ArtifactName)
45+
}
46+

Artifacts/DHCPServer/Generate.ps1 renamed to Functions/Private/Artifacts/DHCPServer/Generate_DHCPServer.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
function Generate_DHCPServer {
12
<#
23
.SYNOPSIS
34
Generates Dockerfile contents for DHCP Server component
@@ -22,4 +23,6 @@ if ($Artifact.Status -eq 'Present') {
2223
$Result = 'RUN powershell.exe -ExecutionPolicy Bypass -Command Enable-WindowsOptionalFeature -Online -FeatureName DHCPServer'
2324
}
2425

25-
Write-Output -InputObject $Result
26+
Write-Output -InputObject $Result
27+
}
28+

0 commit comments

Comments
 (0)