Skip to content
Draft
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
22 changes: 12 additions & 10 deletions containers-toolkit/Public/AllToolsUtilities.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
###########################################################################


using module "..\Private\logger.psm1"

$ModuleParentPath = Split-Path -Parent $PSScriptRoot
Import-Module -Name "$ModuleParentPath\Private\CommonToolUtilities.psm1" -Force

Expand All @@ -30,7 +32,7 @@ function Show-ContainerTools {

$registerCommands = (Get-Command -Name "*-*Service" -Module 'Containers-Toolkit').Name -join ', '
$message = "For unregistered services/daemons, check the tool's help or register the service using `n`t$registerCommands"
Write-Information -MessageData $message -Tags "Instructions" -InformationAction Continue
[Logger]::Info($message)
return $installedTools
}

Expand Down Expand Up @@ -89,10 +91,10 @@ function Install-ContainerTools {

process {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) {
Write-Output "The following tools will be installed: $toInstallString"
[Logger]::Info("The following tools will be installed: $toInstallString")

Write-Debug "Downloading files to $DownloadPath"
Write-Debug "Installing files to $InstallPath"
[Logger]::Debug("Downloading files to $DownloadPath")
[Logger]::Debug("Installing files to $InstallPath")

$completedInstalls = @()
$failedInstalls = @()
Expand Down Expand Up @@ -135,25 +137,25 @@ function Install-ContainerTools {
$completedInstalls += $task.Name
}
catch {
Write-Error "$($task.Name) installation failed. $_"
[Logger]::Error("$($task.Name) installation failed. $_")
$failedInstalls += $task.Name
}
}

if ($completedInstalls) {
Write-Output "$($completedInstalls -join ', ') installed successfully.`n"
[Logger]::Info("$($completedInstalls -join ', ') installed successfully.`n")
}

if ($failedInstalls) {
Write-Warning "Installation failed for $($failedInstalls -join ', ')`n"
[Logger]::Warning("Installation failed for $($failedInstalls -join ', ')`n")
}

if ($RegisterServices) {
try {
Initialize-NatNetwork -Force:$force -Confirm:$false
}
catch {
Write-Error "Failed to initialize NAT network. $_"
[Logger]::Error("Failed to initialize NAT network. $_")
}
}
else {
Expand All @@ -163,10 +165,10 @@ To register containerd and buildkitd services and create a NAT network, see help
Get-Help Register-BuildkitdService
Get-Help Initialize-NatNetwork
"@
Write-Information -MessageData $message -Tags "Instructions" -InformationAction Continue
[Logger]::Info($message)
}

Write-Output "Installation complete. See logs for more details"
[Logger]::Info("Installation complete. See logs for more details")
}
else {
# Code that should be processed if doing a WhatIf operation
Expand Down