# this file checks the status of the Windows Docker package using the DockerProvider powershell provider
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$dockerProviderName="DockerProvider"

Write-Information "Checking Package Provider"
$module = Get-PackageProvider NuGet -ErrorAction SilentlyContinue
If ($module -eq $null) {
    Write-Error "NuGet PackagePrivider is not installed."
    Exit 1
}

<% if $nuget_package_provider_version { -%>
Write-Information "Checking Package provider version"
if ($module.Version.ToString() -ne "<%= $nuget_package_provider_version %>" ) {
    Write-Error "Incorrect Microsoft Nuget provider version installed"
    Exit 1
}
<% } -%>

Write-Information "Checking Docker Provider"
$provider = Get-Module -ListAvailable -Name $dockerProviderName -ErrorAction SilentlyContinue
If ($provider -eq $null) {
    Write-Error "Docker Microsoft Docker provider is not installed."
    Exit 1
}

<% if $docker_msft_provider_version { -%>
Write-Information "Checking Docker provider version"
if ($provider.Version.ToString() -ne "<%= $docker_msft_provider_version %>" ) {
    Write-Error "Incorrect Microsoft Docker Provider version installed."
    Exit 1
}
<% } -%>

Write-Information "Checking Docker package."
$package=Get-Package <%= $docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction SilentlyContinue
If ($package -eq $null) { 
    Write-Error "Docker package is not installed."
    Exit 1
}

<% if $version { -%>
Write-Information "Checking Docker package version"
if ($package.Version.ToString() -notmatch  "<%= $version %>"){
    Write-Error "Incorrect Docker package version installed."
    Exit 1
}
<% } %>
