mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-23 23:51:03 +00:00
Merge pull request #120 from SvenDowideit/add-image-and-volume-custom-commands
custom commands for images and volumes
This commit is contained in:
commit
06c80ec36f
5 changed files with 56 additions and 0 deletions
|
|
@ -51,6 +51,8 @@ type CommandObject struct {
|
||||||
DockerCompose string
|
DockerCompose string
|
||||||
Service *Service
|
Service *Service
|
||||||
Container *Container
|
Container *Container
|
||||||
|
Image *Image
|
||||||
|
Volume *Volume
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCommandObject takes a command object and returns a default command object with the passed command object merged in
|
// NewCommandObject takes a command object and returns a default command object with the passed command object merged in
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,12 @@ type CustomCommands struct {
|
||||||
|
|
||||||
// Services contains the custom commands for services
|
// Services contains the custom commands for services
|
||||||
Services []CustomCommand `yaml:"services,omitempty"`
|
Services []CustomCommand `yaml:"services,omitempty"`
|
||||||
|
|
||||||
|
// Services contains the custom commands for services
|
||||||
|
Images []CustomCommand `yaml:"images,omitempty"`
|
||||||
|
|
||||||
|
// Services contains the custom commands for services
|
||||||
|
Volumes []CustomCommand `yaml:"volumes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CustomCommand is a template for a command we want to run against a service or
|
// CustomCommand is a template for a command we want to run against a service or
|
||||||
|
|
@ -335,6 +341,8 @@ func GetDefaultConfig() UserConfig {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Services: []CustomCommand{},
|
Services: []CustomCommand{},
|
||||||
|
Images: []CustomCommand{},
|
||||||
|
Volumes: []CustomCommand{},
|
||||||
},
|
},
|
||||||
OS: GetPlatformDefaultConfig(),
|
OS: GetPlatformDefaultConfig(),
|
||||||
Update: UpdateConfig{
|
Update: UpdateConfig{
|
||||||
|
|
|
||||||
|
|
@ -259,3 +259,19 @@ func (gui *Gui) handlePruneImages(g *gocui.Gui, v *gocui.View) error {
|
||||||
})
|
})
|
||||||
}, nil)
|
}, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) handleImagesCustomCommand(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
image, err := gui.getSelectedImage(g)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
commandObject := gui.DockerCommand.NewCommandObject(
|
||||||
|
commands.CommandObject{
|
||||||
|
Image: image,
|
||||||
|
})
|
||||||
|
|
||||||
|
customCommands := gui.Config.UserConfig.CustomCommands.Images
|
||||||
|
|
||||||
|
return gui.createCustomCommandMenu(customCommands, commandObject)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -337,6 +337,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||||
Handler: gui.handleImagesNextContext,
|
Handler: gui.handleImagesNextContext,
|
||||||
Description: gui.Tr.NextContext,
|
Description: gui.Tr.NextContext,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "images",
|
||||||
|
Key: 'c',
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.handleImagesCustomCommand,
|
||||||
|
Description: gui.Tr.RunCustomCommand,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "images",
|
ViewName: "images",
|
||||||
Key: 'd',
|
Key: 'd',
|
||||||
|
|
@ -365,6 +372,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||||
Handler: gui.handleVolumesNextContext,
|
Handler: gui.handleVolumesNextContext,
|
||||||
Description: gui.Tr.NextContext,
|
Description: gui.Tr.NextContext,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "volumes",
|
||||||
|
Key: 'c',
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.handleVolumesCustomCommand,
|
||||||
|
Description: gui.Tr.RunCustomCommand,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "volumes",
|
ViewName: "volumes",
|
||||||
Key: 'd',
|
Key: 'd',
|
||||||
|
|
|
||||||
|
|
@ -250,3 +250,19 @@ func (gui *Gui) handlePruneVolumes(g *gocui.Gui, v *gocui.View) error {
|
||||||
})
|
})
|
||||||
}, nil)
|
}, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) handleVolumesCustomCommand(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
volume, err := gui.getSelectedVolume()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
commandObject := gui.DockerCommand.NewCommandObject(
|
||||||
|
commands.CommandObject{
|
||||||
|
Volume: volume,
|
||||||
|
})
|
||||||
|
|
||||||
|
customCommands := gui.Config.UserConfig.CustomCommands.Volumes
|
||||||
|
|
||||||
|
return gui.createCustomCommandMenu(customCommands, commandObject)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue