allow forcing an image removal

This commit is contained in:
Jesse Duffield 2022-05-11 19:38:53 +10:00
parent d3e84881bb
commit 62be3d9924
2 changed files with 116 additions and 99 deletions

View file

@ -212,17 +212,30 @@ func (gui *Gui) handleImagesRemoveMenu(g *gocui.Gui, v *gocui.View) error {
shortSha := Image.ID[7:17] shortSha := Image.ID[7:17]
// TODO: have a way of toggling in a menu instead of showing each permutation as a separate menu item
options := []*removeImageOption{ options := []*removeImageOption{
{ {
description: gui.Tr.Remove, description: gui.Tr.Remove,
command: "docker image rm " + shortSha, command: "docker image rm " + shortSha,
configOptions: types.ImageRemoveOptions{PruneChildren: true}, configOptions: types.ImageRemoveOptions{PruneChildren: true, Force: false},
runCommand: true, runCommand: true,
}, },
{ {
description: gui.Tr.RemoveWithoutPrune, description: gui.Tr.RemoveWithoutPrune,
command: "docker image rm --no-prune " + shortSha, command: "docker image rm --no-prune " + shortSha,
configOptions: types.ImageRemoveOptions{PruneChildren: false}, configOptions: types.ImageRemoveOptions{PruneChildren: false, Force: false},
runCommand: true,
},
{
description: gui.Tr.RemoveWithForce,
command: "docker image rm --force " + shortSha,
configOptions: types.ImageRemoveOptions{PruneChildren: true, Force: true},
runCommand: true,
},
{
description: gui.Tr.RemoveWithoutPruneWithForce,
command: "docker image rm --no-prune --force " + shortSha,
configOptions: types.ImageRemoveOptions{PruneChildren: false, Force: true},
runCommand: true, runCommand: true,
}, },
{ {

View file

@ -26,65 +26,67 @@ type TranslationSet struct {
CannotAccessDockerSocketError string CannotAccessDockerSocketError string
CannotKillChildError string CannotKillChildError string
Donate string Donate string
Cancel string Cancel string
CustomCommandTitle string CustomCommandTitle string
BulkCommandTitle string BulkCommandTitle string
Remove string Remove string
HideStopped string HideStopped string
ForceRemove string ForceRemove string
RemoveWithVolumes string RemoveWithVolumes string
MustForceToRemoveContainer string MustForceToRemoveContainer string
Confirm string Confirm string
Return string Return string
FocusMain string FocusMain string
StopContainer string StopContainer string
RestartingStatus string RestartingStatus string
StoppingStatus string StoppingStatus string
RemovingStatus string RemovingStatus string
RunningCustomCommandStatus string RunningCustomCommandStatus string
RunningBulkCommandStatus string RunningBulkCommandStatus string
RemoveService string RemoveService string
Stop string Stop string
Restart string Restart string
Rebuild string Rebuild string
Recreate string Recreate string
PreviousContext string PreviousContext string
NextContext string NextContext string
Attach string Attach string
ViewLogs string ViewLogs string
ServicesTitle string ServicesTitle string
ContainersTitle string ContainersTitle string
StandaloneContainersTitle string StandaloneContainersTitle string
TopTitle string TopTitle string
ImagesTitle string ImagesTitle string
VolumesTitle string VolumesTitle string
NoContainers string NoContainers string
NoContainer string NoContainer string
NoImages string NoImages string
NoVolumes string NoVolumes string
RemoveImage string RemoveImage string
RemoveVolume string RemoveVolume string
RemoveWithoutPrune string RemoveWithoutPrune string
PruneImages string RemoveWithoutPruneWithForce string
PruneContainers string RemoveWithForce string
PruneVolumes string PruneImages string
ConfirmPruneContainers string PruneContainers string
ConfirmStopContainers string PruneVolumes string
ConfirmRemoveContainers string ConfirmPruneContainers string
ConfirmPruneImages string ConfirmStopContainers string
ConfirmPruneVolumes string ConfirmRemoveContainers string
PruningStatus string ConfirmPruneImages string
StopService string ConfirmPruneVolumes string
PressEnterToReturn string PruningStatus string
StopAllContainers string StopService string
RemoveAllContainers string PressEnterToReturn string
ViewRestartOptions string StopAllContainers string
ExecShell string RemoveAllContainers string
RunCustomCommand string ViewRestartOptions string
ViewBulkCommands string ExecShell string
OpenInBrowser string RunCustomCommand string
SortContainersByState string ViewBulkCommands string
OpenInBrowser string
SortContainersByState string
LogsTitle string LogsTitle string
ConfigTitle string ConfigTitle string
@ -124,44 +126,46 @@ func englishSet() TranslationSet {
Donate: "Donate", Donate: "Donate",
Confirm: "Confirm", Confirm: "Confirm",
Return: "return", Return: "return",
FocusMain: "focus main panel", FocusMain: "focus main panel",
Navigate: "navigate", Navigate: "navigate",
Execute: "execute", Execute: "execute",
Close: "close", Close: "close",
Menu: "menu", Menu: "menu",
MenuTitle: "Menu", MenuTitle: "Menu",
Scroll: "scroll", Scroll: "scroll",
OpenConfig: "open lazydocker config", OpenConfig: "open lazydocker config",
EditConfig: "edit lazydocker config", EditConfig: "edit lazydocker config",
Cancel: "cancel", Cancel: "cancel",
Remove: "remove", Remove: "remove",
HideStopped: "hide/show stopped containers", HideStopped: "hide/show stopped containers",
ForceRemove: "force remove", ForceRemove: "force remove",
RemoveWithVolumes: "remove with volumes", RemoveWithVolumes: "remove with volumes",
RemoveService: "remove containers", RemoveService: "remove containers",
Stop: "stop", Stop: "stop",
Restart: "restart", Restart: "restart",
Rebuild: "rebuild", Rebuild: "rebuild",
Recreate: "recreate", Recreate: "recreate",
PreviousContext: "previous tab", PreviousContext: "previous tab",
NextContext: "next tab", NextContext: "next tab",
Attach: "attach", Attach: "attach",
ViewLogs: "view logs", ViewLogs: "view logs",
RemoveImage: "remove image", RemoveImage: "remove image",
RemoveVolume: "remove volume", RemoveVolume: "remove volume",
RemoveWithoutPrune: "remove without deleting untagged parents", RemoveWithoutPrune: "remove without deleting untagged parents",
PruneContainers: "prune exited containers", RemoveWithoutPruneWithForce: "remove (forced) without deleting untagged parents",
PruneVolumes: "prune unused volumes", RemoveWithForce: "remove (forced)",
PruneImages: "prune unused images", PruneContainers: "prune exited containers",
StopAllContainers: "stop all containers", PruneVolumes: "prune unused volumes",
RemoveAllContainers: "remove all containers (forced)", PruneImages: "prune unused images",
ViewRestartOptions: "view restart options", StopAllContainers: "stop all containers",
ExecShell: "exec shell", RemoveAllContainers: "remove all containers (forced)",
RunCustomCommand: "run predefined custom command", ViewRestartOptions: "view restart options",
ViewBulkCommands: "view bulk commands", ExecShell: "exec shell",
OpenInBrowser: "open in browser (first port is http)", RunCustomCommand: "run predefined custom command",
SortContainersByState: "sort containers by state", ViewBulkCommands: "view bulk commands",
OpenInBrowser: "open in browser (first port is http)",
SortContainersByState: "sort containers by state",
GlobalTitle: "Global", GlobalTitle: "Global",
MainTitle: "Main", MainTitle: "Main",