Skip to content

Conversation

@salmanmkc
Copy link

@salmanmkc salmanmkc commented Mar 20, 2024

DRAFT state, but just creating it early.

Changes

  • Cleanup
  • Timestamp for logs
  • work in progress for Virtual Box support
  • shows QEMU works

$Version = $Version.TrimStart('v')
Write-Output "* Downloading and installing Containerd v$version at $InstallPath"
"Downloading and installing Containerd v$version at $InstallPath" >> logs
"{0} - Downloading and installing Containerd v$version at $InstallPath" -f (Get-Date) >> logs
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timestamp is a good addition. However, we do not need to redirect each message to a logger, since we can do this: Install-Containerd >> logs.txt. This way, the code will be much cleaner and we'll not need to remember to add >> logs to every log.

$dirPath = "C:\Users\$env:USERNAME\VirtualBox VMs\$VMName"
& VBoxManage controlvm $VMName poweroff --type headless
& VBoxManage unregistervm $VMName --delete
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log message for success and if the plaform is not supported

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a validated set to this file too

}
}
else {
Write-Warning "The $dirPath directory doesn't exist."
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya good point

if ($VMName) {
try{
if ($Platform -eq "Hyper-V") {
$dirPath = "C:\Users\$env:USERNAME\.minikube\machines\$VMName"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split HyperV and Virtual box to seperate functions to make it easier to mange each of them

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, eventually will do, this is in draft state, not finished

if($Platform -eq "Hyper-V"){
# set the vm switch first
$Switch = Set-VmSwitch -SwitchName $SwitchName
$VM = @{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split HyperV and Virtual box to seperate functions to make it easier to mange each of them

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya will do eventually, wanted to push code a bit earlier, will clean up eventually when finished with everything else on this PR

# Add-VMDvdDrive -VMName $VMName -Path "$PSScriptRoot\auto-install.iso" -ControllerNumber 1 -ControllerLocation 1
Start-VM -Name $VMName | Out-Null
if($Platform -eq "Hyper-V"){
$VM = @{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split HyperV and Virtual box to seperate functions to make it easier to mange each of them

Copy link
Author

@salmanmkc salmanmkc Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants