Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add install option to only install docker client cli #82

Open
wants to merge 1 commit into
base: developer
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 51 additions & 38 deletions DockerMsftProvider.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ function Install-Package
$options = $request.Options
$update = $false
$force = $false
$cliOnly = $false

if($options)
{
Expand All @@ -234,43 +235,51 @@ function Install-Package
{
$force = $true
}
}

if(Test-Path $script:pathDockerD)
{
if($update -or $force)
if($options.ContainsKey("CliOnly"))
{
# Uninstall if another installation exists
UninstallHelper
$cliOnly = $true
}
elseif(-not $force)
{
$dockerVersion = & "$script:pathDockerClient" --version
$resultArr = $dockerVersion -split ","
$version = ($resultArr[0].Trim() -split " ")[2]
}

Write-Verbose "Docker $version already exists. Skipping install. Use -force to install anyway."
return
}
}
else
if(-not $cliOnly)
{
# Install WindowsFeature containers
try
if(Test-Path $script:pathDockerD)
{
InstallContainer
}
catch
if($update -or $force)
{
# Uninstall if another installation exists
UninstallHelper
}
elseif(-not $force)
{
$dockerVersion = & "$script:pathDockerClient" --version
$resultArr = $dockerVersion -split ","
$version = ($resultArr[0].Trim() -split " ")[2]

Write-Verbose "Docker $version already exists. Skipping install. Use -force to install anyway."
return
}
}
else
{
$ErrorMessage = $_.Exception.Message
ThrowError -CallerPSCmdlet $PSCmdlet `
-ExceptionName $_.Exception.GetType().FullName `
-ExceptionMessage $ErrorMessage `
-ErrorId FailedToDownload `
-ErrorCategory InvalidOperation
# Install WindowsFeature containers
try
{
InstallContainer
}
catch
{
$ErrorMessage = $_.Exception.Message
ThrowError -CallerPSCmdlet $PSCmdlet `
-ExceptionName $_.Exception.GetType().FullName `
-ExceptionMessage $ErrorMessage `
-ErrorId FailedToDownload `
-ErrorCategory InvalidOperation

return
}
return
}
}
}

$splitterArray = @("$separator")
Expand Down Expand Up @@ -317,18 +326,21 @@ function Install-Package
$null = Rename-Item -Path $script:pathDockerRoot -NewName $env:ProgramFiles\$dummyName
$null = Rename-Item -Path $env:ProgramFiles\$dummyName -NewName $script:pathDockerRoot

if(Test-Path $script:pathDockerD)
if(-not $cliOnly)
{
Write-Verbose "Trying to enable the docker service..."
$service = get-service -Name Docker -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
if(-not $service)
if(Test-Path $script:pathDockerD)
{
& "$script:pathDockerD" --register-service
Write-Verbose "Trying to enable the docker service..."
$service = get-service -Name Docker -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
if(-not $service)
{
& "$script:pathDockerD" --register-service
}
}
else
{
Write-Error "Unable to expand docker to Program Files."
}
}
else
{
Write-Error "Unable to expand docker to Program Files."
}
}
catch
Expand Down Expand Up @@ -1256,6 +1268,7 @@ function Get-DynamicOptions
Install
{
Write-Output -InputObject (New-DynamicOption -Category $category -Name "Update" -ExpectedType Switch -IsRequired $false)
Write-Output -InputObject (New-DynamicOption -Category $category -Name "CliOnly" -ExpectedType Switch -IsRequired $false)
}
}
}
Expand Down