Skip to content

Commit

Permalink
Update 'Whatif' messages (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaMor authored Aug 12, 2024
1 parent cb4ebee commit 68e6958
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion containers-toolkit/Private/UpdateEnvironmentPath.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function Update-EnvironmentPath {
)

process {
if ($PSCmdlet.ShouldProcess($InstallPath, "$path will be added to environment path")) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, "$path will be added to environment path")) {
# Get current environment path
$parsedPathString = switch ($PathType) {
"System" {
Expand Down
2 changes: 1 addition & 1 deletion containers-toolkit/Public/AllToolsUtilities.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function Install-ContainerTools {
}

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

Write-Debug "Downloading files to $DownloadPath"
Expand Down
10 changes: 5 additions & 5 deletions containers-toolkit/Public/BuildkitTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ function Install-Buildkit {
# Check if Buildkit is alread installed
$isInstalled = -not (Test-EmptyDirectory -Path $InstallPath)

$WhatIfMessage = "Buildkit will be installed"
$WhatIfMessage = "Buildkit will be installed at $InstallPath"
if ($isInstalled) {
$WhatIfMessage = "Buildkit will be uninstalled and reinstalled"
$WhatIfMessage = "Buildkit will be uninstalled from and reinstalled at $InstallPath"
}
if ($Setup) {
<# Action when this condition is true #>
$WhatIfMessage = "Buildkit will be installed and buildkitd service will be registered and started"
$WhatIfMessage = "Buildkit will be installed at $InstallPath and buildkitd service will be registered and started"
}
}

process {
if ($PSCmdlet.ShouldProcess($InstallPath, $WhatIfMessage)) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) {
# Check if tool already exists at specified location
if ($isInstalled) {
$errMsg = "Buildkit already exists at $InstallPath or the directory is not empty"
Expand Down Expand Up @@ -241,7 +241,7 @@ function Register-BuildkitdService {
}

process {
if ($PSCmdlet.ShouldProcess("$BuildKitPath\bin\buildkitd.exe", $WhatIfMessage)) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) {
if (Test-EmptyDirectory -Path $BuildKitPath) {
Throw "Buildkit does not exist at $BuildKitPath or the directory is empty"
}
Expand Down
10 changes: 5 additions & 5 deletions containers-toolkit/Public/ContainerNetworkTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ function Install-WinCNIPlugin {

$plugin = "Windows CNI plugins"

$WhatIfMessage = "$plugin will be installed"
$WhatIfMessage = "$plugin will be installed at $WINCNIPath"
if ($isInstalled) {
$WhatIfMessage = "$plugin will be uninstalled and reinstalled"
$WhatIfMessage = "$plugin will be uninstalled from and reinstalled at $WINCNIPath"
}
}

process {
if ($PSCmdlet.ShouldProcess($WinCNIPath, $WhatIfMessage)) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) {
# Check if tool already exists at specified location
if ($isInstalled) {
$errMsg = "Windows CNI plugins already exists at $WinCNIPath or the directory is not empty"
Expand Down Expand Up @@ -275,11 +275,11 @@ function Uninstall-WinCNIPlugin {

$Path = $Path -replace '(\\bin\\?)$', ''

$WhatIfMessage = "Windows CNI plugins will be uninstalled"
$WhatIfMessage = "Windows CNI plugins will be uninstalled from $path"
}

process {
if ($PSCmdlet.ShouldProcess($Path, $WhatIfMessage)) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) {
if (Test-EmptyDirectory -Path $path) {
Write-Output "Windows CNI plugins does not exist at $Path or the directory is empty"
return
Expand Down
18 changes: 9 additions & 9 deletions containers-toolkit/Public/ContainerdTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ function Install-Containerd {
# Check if Containerd is alread installed
$isInstalled = -not (Test-EmptyDirectory -Path $InstallPath)

$WhatIfMessage = "Containerd will be installed"
$WhatIfMessage = "Containerd will be installed at $InstallPath"
if ($isInstalled) {
$WhatIfMessage = "Containerd will be uninstalled and reinstalled"
$WhatIfMessage = "Containerd will be uninstalled from and reinstalled at $InstallPath"
}
if ($Setup) {
<# Action when this condition is true #>
$WhatIfMessage = "Containerd will be installed and containerd service will be registered and started"
$WhatIfMessage = "Containerd will be installed at $InstallPath and containerd service will be registered and started"
}
}

process {
if ($PSCmdlet.ShouldProcess($InstallPath, $WhatIfMessage)) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) {
# Check if tool already exists at specified location
if ($isInstalled) {
$errMsg = "Containerd already exists at $InstallPath or the directory is not empty"
Expand Down Expand Up @@ -157,7 +157,7 @@ function Start-ContainerdService {
param()

process {
if ($PSCmdlet.ShouldProcess($InstallPath, "")) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, "Starts containerd service")) {
Invoke-ServiceAction -Service 'Containerd' -Action 'Start'
}
else {
Expand All @@ -175,7 +175,7 @@ function Stop-ContainerdService {
param()

process {
if ($PSCmdlet.ShouldProcess($InstallPath, "")) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, "Stop containerd service")) {
Invoke-ServiceAction -Service 'Containerd' -Action 'Stop'
}
else {
Expand Down Expand Up @@ -215,7 +215,7 @@ function Register-ContainerdService {
}

process {
if ($PSCmdlet.ShouldProcess($containerdExecutable, $WhatIfMessage)) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) {
if (Test-EmptyDirectory -Path $ContainerdPath) {
Throw "Containerd does not exist at $ContainerdPath or the directory is empty"
}
Expand Down Expand Up @@ -309,11 +309,11 @@ function Uninstall-Containerd {
$Path = Get-DefaultInstallPath -Tool $tool
}

$WhatIfMessage = "Containerd will be uninstalled and containerd service will be stopped and unregistered"
$WhatIfMessage = "Containerd will be uninstalled from $path and containerd service will be stopped and unregistered"
}

process {
if ($PSCmdlet.ShouldProcess($Path, $WhatIfMessage)) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) {
if (Test-EmptyDirectory -Path $path) {
Write-Output "$tool does not exist at $Path or the directory is empty"
return
Expand Down
10 changes: 5 additions & 5 deletions containers-toolkit/Public/NerdctlTools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ function Install-Nerdctl {
$toInstall += $dependencies
}

$WhatIfMessage = "nerdctl will be installed"
$WhatIfMessage = "nerdctl will be installed at $installPath"
if ($isInstalled) {
$WhatIfMessage = "nerdctl will be uninstalled and reinstalled"
$WhatIfMessage = "nerdctl will be uninstalled from and reinstalled at $installPath"
}
if ($dependencies) {
<# Action when this condition is true #>
Expand All @@ -100,7 +100,7 @@ function Install-Nerdctl {
}

process {
if ($PSCmdlet.ShouldProcess($InstallPath, $WhatIfMessage)) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) {
# Check if tool already exists at specified location
if ($isInstalled) {
$errMsg = "nerdctl already exists at $InstallPath or the directory is not empty"
Expand Down Expand Up @@ -212,11 +212,11 @@ function Uninstall-Nerdctl {
$Path = Get-DefaultInstallPath -Tool "nerdctl"
}

$WhatIfMessage = "nerdctl will be uninstalled"
$WhatIfMessage = "nerdctl will be uninstalled from $Path"
}

process {
if ($PSCmdlet.ShouldProcess($Path, $WhatIfMessage)) {
if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) {
if (Test-EmptyDirectory -Path $path) {
Write-Output "$tool does not exist at $Path or the directory is empty"
return
Expand Down

0 comments on commit 68e6958

Please sign in to comment.