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

Commit 1adbe3f

Browse files
committed
Improved help for public functions - fixes #7
1 parent 6101769 commit 1adbe3f

File tree

4 files changed

+101
-25
lines changed

4 files changed

+101
-25
lines changed

Functions/Public/Clear-JunctionLinks.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ function Clear-JunctionLinks {
22
<#
33
.Synopsis
44
Simple helper script that removes any discovered junction links from user's $env:TEMP directory.
5+
6+
.EXAMPLE
7+
8+
Clear-JunctionLinks
9+
10+
This will remove any mounted images in the $env:TEMP directory
511
#>
612
[CmdletBinding()]
713
param (

Functions/Public/ConvertTo-Dockerfile.ps1

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,95 @@ function ConvertTo-Dockerfile {
1313
1414
.PARAMETER OutputPath
1515
An optional parameter that specifies the filesystem path where artifacts and the resulting
16-
Dockerfile will be stored. If you do not specify a path, a temporary directory will be created for you.
16+
Dockerfile will be stored. If you do not specify a path, a temporary directory will be created for you within the $env:Temp location.
1717
18+
.PARAMETER MountPath
19+
The filesystem path to the directory where the image will be mounted to for discovery.
20+
The folder will be created if it does not exist.
21+
If you do not specify a path, a temporary directory will be created for you within the $env:Temp location and will be removed
22+
1823
.PARAMETER Artifact
1924
Specify the discovery artifacts that will be scanned during the ConvertTo-Dockerfile command.
2025
21-
You can obtain the supported list of artifacts by running the Get-WindowsArtifacts command in the same module.
26+
You can use tab completion to find all of the supported artifacts that can be discovered.
27+
28+
.PARAMETER ArtifactParam
29+
This paramater is used in conjunction with the artifact paramater and currently is used when specifying a Single IIS Web App.
30+
31+
Please see the examples for how to use this parameter.
32+
33+
.PARAMETER Force
34+
This Parameter is for use when you want to use a folder that you have either already used for creating a Dockerfile from an image
35+
36+
.EXAMPLE
37+
38+
ConvertTo-Dockerfile -ImagePath E:\VMVirtualHardDisks\WebServer.VHDX -OutputPath C:\Docker\IIS\ -MountPath C:\Image\ -Artifact IIS -Verbose
39+
40+
With this example we will be mounting a VHDX for a Virtual Machine called WebServer and the image will be mounted at the C:\Image\ location. We have specified that we want to only return the IIS Artifact from this machine so this will only perform the discovery of IIS related items and will output the required items to the OutputPath directory which in this case we have specified this to be C:\Docker\IIS\ and we will return all verbose output when running this command.
41+
42+
.EXAMPLE
43+
44+
ConvertTo-Dockerfile -ImagePath E:\VMVirtualHardDisks\WebServer.VHDX -OutputPath C:\Docker\WebServer\ -Verbose
45+
46+
With this example we will be mounting a VHDX for a Virtual Machine called WebServer.
47+
As we have not specifiec a MountPath the Image will be mounted into a folder in the Temp path location and will be removed when this command finishes.
48+
As we have not specified a specific Artifact from this machine, this function will return artifacts for all of the available artifacts that this tool can attempt to discover and will output the required items to the OutputPath directory which in this case we have specified this to be C:\Docker\WebServer\
49+
50+
.EXAMPLE
51+
52+
ConvertTo-Dockerfile -ImagePath E:\VMVirtualHardDisks\WebServer.VHDX
53+
54+
With this example we will be mounting a VHDX for a Virtual Machine called WebServer.
55+
As we have not specifiec a MountPath the Image will be mounted into a folder in the Temp path location and will be removed when this command finishes.
56+
57+
As we have not specified a specific Artifact from this machine, this function will return artifacts for all of the available artifacts that this tool can attempt to discover and as we have not specified an OutputPath this command will create a folder in the $env:temp folder where all of the artifacts, required files and the resulting Dockerfile will be output to.
58+
59+
.EXAMPLE
60+
61+
ConvertTo-Dockerfile -ImagePath E:\VMVirtualHardDisks\WebServer.VHDX -OutputPath C:\Docker\IIS_SingleApp\ -MountPath C:\Image\ -Artifact IIS_SingleApp -ArtifactParam 'Default Web Site' -Force -Verbose
62+
63+
With this example we will be mounting a VHDX for a Virtual Machine called WebServer and the image will be mounted at the C:\Image\ location.
64+
We have specified that we want to only return the IIS_SingleApp Artifact and for this we have provided the name of the WebApp that we want to return via the ArtifactParam Parameter, in this case we have specified that we want to return the 'Default Web Site' that is created when the IIS feature is activated on a new server.
65+
66+
We have also specified the Force Parameter which will remove any existing files and folders that are in the OutputPath directory and will reuse this directory for the output from this command.
2267
23-
.PARAMETER MountPath
24-
The filesystem path to the directory where the image will be mounted to for discovery.
25-
The folder will be created if it does not exist.
2668
#>
69+
70+
2771
[CmdletBinding()]
2872
param (
2973
[Parameter(Mandatory = $true)]
30-
[ValidateScript({
31-
if (!(Test-Path -Path $PSItem)) {
32-
return $false
33-
}
34-
else { return $true }
35-
})]
74+
[ValidateScript({if (!(Test-Path -Path $PSItem)) { return $false } else { return $true } })]
3675
[string] $ImagePath,
76+
3777
[Parameter(Mandatory = $false)]
3878
[string] $OutputPath,
79+
3980
[Parameter(Mandatory = $false)]
4081
[string] $MountPath,
82+
83+
[Parameter(Mandatory = $false)]
84+
[string[]] $Artifact,
85+
86+
[Parameter(Mandatory = $false)]
87+
[string[]] $ArtifactParam,
88+
4189
[Parameter(Mandatory = $false)]
42-
[string[]] $Artifact
90+
[Switch] $Force
91+
4392
)
4493

4594
### If the user doesn't specify an output path, then generate one
4695
if (!$PSBoundParameters.Keys.Contains('OutputPath')) {
4796
$OutputPath = GenerateOutputFolder
48-
} else {
97+
}
98+
elseif(($PSBoundParameters.Keys.Contains('OutputPath')) -and ($PSBoundParameters.Keys.Contains('Force')))
99+
{
100+
$OutputPath = GenerateOutputFolder -Path $OutputPath -Force
101+
}
102+
else {
49103
$OutputPath = GenerateOutputFolder -Path $OutputPath
50104
}
51-
52105
Write-Verbose -Message ('Starting conversion process')
53106

54107
### Verify the image type before proceeding
@@ -69,10 +122,20 @@ function ConvertTo-Dockerfile {
69122
if (!$PSBoundParameters.Keys.Contains('Artifact')) {
70123
$Artifact = Get-WindowsArtifacts
71124
}
72-
DiscoverArtifacts -Artifact $Artifact -OutputPath $OutputPath
125+
if (!$PSBoundParameters.Keys.Contains('ArtifactParam')) {
126+
DiscoverArtifacts -Artifact $Artifact -OutputPath $OutputPath
127+
}
128+
else {
129+
DiscoverArtifacts -Artifact $Artifact -OutputPath $OutputPath -ArtifactParam $ArtifactParam
130+
}
73131

74132
### Generate Dockerfile
75-
GenerateDockerfile -ArtifactPath $OutputPath -Artifact $Artifact
133+
if (!$PSBoundParameters.Keys.Contains('ArtifactParam')) {
134+
GenerateDockerfile -ArtifactPath $OutputPath -Artifact $Artifact
135+
}
136+
else {
137+
GenerateDockerfile -ArtifactPath $OutputPath -Artifact $Artifact -ArtifactParam $ArtifactParam
138+
}
76139
Write-Verbose -Message 'Finished generating the Dockerfile'
77140

78141
### Dismount the image when inspection is completed

Functions/Public/Get-WindowsArtifacts.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@ function Get-WindowsArtifacts {
22
<#
33
.SYNOPSIS
44
Returns a list of supported artifacts for discovery in a Windows image.
5+
6+
.EXAMPLE
7+
8+
$Artifacts = Get-WindowsArtifacts
9+
10+
This will return all of the discoverable artifacts and assign the result to the Artifacts Variable
11+
512
#>
613
[CmdletBinding()]
714
param (
815
)
916

10-
$ArtifactList = Get-ChildItem -Path $ModulePath\Artifacts -Directory
17+
$ArtifactList = Get-ChildItem -Path $ModulePath\Functions\Private\Artifacts -Directory
1118
Write-Verbose -Message ('Searching for artifacts in filesystem path: {0}\Artifacts' -f $ModulePath)
1219

1320
foreach ($Artifact in $ArtifactList) {
1421
$ChildItems = (Get-ChildItem -Path $Artifact.FullName).Name
1522
Write-Verbose -Message ('Child items for "{0}" artifact: {1}' -f $Artifact.FullName, ($ChildItems -join ', '))
1623

17-
if ($ChildItems -contains 'Discover.ps1' -and $ChildItems -contains 'Generate.ps1') {
24+
if ($ChildItems -contains "Discover_$Artifact.ps1" -and $ChildItems -contains "Generate_$Artifact.ps1") {
1825
Write-Output -InputObject $Artifact.Name
1926
Write-Verbose -Message ('Valid artifact found: {0}' -f $Artifact.Name)
2027
}

Image2Docker.psd1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
2-
# Module manifest for module 'DockerMigrate'
2+
# Module manifest for module Image2Docker
33
#
4-
# Generated by: TrevorSullivan
4+
# Generated by: Docker
55
#
66
# Generated on: 8/29/2016
77
#
@@ -12,7 +12,7 @@
1212
RootModule = 'Image2Docker.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.5'
15+
ModuleVersion = '1.5.1'
1616

1717
# Supported PSEditions
1818
### NOTE: This module will not work with PowerShell Core.
@@ -25,13 +25,13 @@ ModuleVersion = '1.5'
2525
GUID = '93adf15e-4b53-4f7b-9954-a86011c8ce55'
2626

2727
# Author of this module
28-
Author = 'Trevor Sullivan <trevor@artofshell.com>'
28+
Author = 'Docker'
2929

3030
# Company or vendor of this module
3131
CompanyName = 'Docker Inc.'
3232

3333
# Copyright statement for this module
34-
Copyright = '(c) 2016 TrevorSullivan. All rights reserved.'
34+
Copyright = '(c) 2016 Docker Inc. All rights reserved.'
3535

3636
# Description of the functionality provided by this module
3737
Description = 'Performs inspection of artifacts in a valid Windows Server 2012 or Windows Server 2012 R2 WIM or VHDX image and emit a Dockerfile to build the image with.
@@ -105,13 +105,13 @@ PrivateData = @{
105105
PSData = @{
106106

107107
# Tags applied to this module. These help with module discovery in online galleries.
108-
Tags = @('Docker', 'migration')
108+
Tags = @('Docker', 'Migration','DockerFile','Image Capture')
109109

110110
# A URL to the license for this module.
111111
LicenseUri = 'http://www.apache.org/licenses/LICENSE-2.0'
112112

113113
# A URL to the main website for this project.
114-
ProjectUri = 'https://github.com/docker/dockermigrate'
114+
ProjectUri = 'https://github.com/docker/communitytools-image2docker-win'
115115

116116
# A URL to an icon representing this module.
117117
# IconUri = ''

0 commit comments

Comments
 (0)