fix: reorder wsl checks on windows docker installation to reduce executation if elevated privileges
This commit is contained in:
parent
18dccf9fb8
commit
acf4e95e08
7 changed files with 119 additions and 75 deletions
|
|
@ -105,8 +105,10 @@ func InstallDependency(index int, sudoPassword string, dependencies []Dependency
|
|||
}
|
||||
case "darwin":
|
||||
cmd, err = installDarwinDependencies(index, cmd, &mainWindow)
|
||||
dialog.ShowError(err, mainWindow)
|
||||
log.Error(err.Error())
|
||||
if err != nil {
|
||||
dialog.ShowError(err, mainWindow)
|
||||
log.Error(err.Error())
|
||||
}
|
||||
case "linux":
|
||||
err = installLinuxDependencies(index, sudoPassword, cmd, dependencies, &mainWindow)
|
||||
if err != nil {
|
||||
|
|
@ -126,34 +128,31 @@ func installWindowsDependencies(index int, cmd *exec.Cmd, mainWindow *fyne.Windo
|
|||
cmd = tools.CommandInShell("winget", "install", "-e", "--id",
|
||||
"Microsoft.VisualStudioCode")
|
||||
case 1: // Docker Desktop
|
||||
wslEnabled, err := checkWslFeaturesEnabled()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error checking WSL features: %v", err)
|
||||
}
|
||||
|
||||
if !wslEnabled {
|
||||
dialog.ShowInformation("activate wsl", "WSL has to be activated. Please confirm to active necessary features.", *mainWindow)
|
||||
err = enableWslFeatures()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error enabling WSL features: %v", err)
|
||||
}
|
||||
dialog.ShowInformation("reboot required", "Please reboot your PC to finish wsl activation and reopen 'jws'.", *mainWindow)
|
||||
return nil, fmt.Errorf("reboot required")
|
||||
}
|
||||
|
||||
wslCheckCmd := tools.CommandInShell("wsl", "--status")
|
||||
err = wslCheckCmd.Run()
|
||||
err := wslCheckCmd.Run()
|
||||
if err != nil {
|
||||
wslInstallCmd := tools.CommandInShell("wsl", "--install", "ubuntu")
|
||||
dialog.ShowInformation("installing wsl", "WSL will be installed. Please wait untill installation is finished and reopen 'jws'.", *mainWindow)
|
||||
err = wslInstallCmd.Run()
|
||||
if err != nil {
|
||||
wslEnabled, err := checkWslFeaturesEnabled()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error checking WSL features: %v", err)
|
||||
}
|
||||
if !wslEnabled {
|
||||
dialog.ShowInformation("activate wsl", "WSL has to be activated. Please confirm to active necessary features.", *mainWindow)
|
||||
err = enableWslFeatures()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error enabling WSL features: %v", err)
|
||||
}
|
||||
dialog.ShowInformation("reboot required", "Please reboot your PC to finish wsl activation and reopen 'jws'.", *mainWindow)
|
||||
return nil, fmt.Errorf("reboot required")
|
||||
}
|
||||
errMsg := fmt.Errorf("error: installing WSL: %v", err)
|
||||
return nil, errMsg
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cmd = tools.CommandInShell("winget", "install", "-e", "--id",
|
||||
"Docker.DockerDesktop")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue