Initial working demo

Signed-off-by: Dowideit, Sven (O&A, St. Lucia) <Sven.Dowideit@csiro.au>
This commit is contained in:
Dowideit, Sven (O&A, St. Lucia) 2019-07-08 17:01:15 +10:00
parent cca69e64f3
commit cdf075b00d
5 changed files with 56 additions and 0 deletions

View file

@ -51,6 +51,8 @@ type CommandObject struct {
DockerCompose string
Service *Service
Container *Container
Image *Image
Volume *Volume
}
// NewCommandObject takes a command object and returns a default command object with the passed command object merged in

View file

@ -258,6 +258,12 @@ type CustomCommands struct {
// Services contains the custom commands for services
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
@ -335,6 +341,8 @@ func GetDefaultConfig() UserConfig {
},
},
Services: []CustomCommand{},
Images: []CustomCommand{},
Volumes: []CustomCommand{},
},
OS: GetPlatformDefaultConfig(),
Update: UpdateConfig{

View file

@ -259,3 +259,19 @@ func (gui *Gui) handlePruneImages(g *gocui.Gui, v *gocui.View) error {
})
}, 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)
}

View file

@ -337,6 +337,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.handleImagesNextContext,
Description: gui.Tr.NextContext,
},
{
ViewName: "images",
Key: 'c',
Modifier: gocui.ModNone,
Handler: gui.handleImagesCustomCommand,
Description: gui.Tr.RunCustomCommand,
},
{
ViewName: "images",
Key: 'd',
@ -365,6 +372,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.handleVolumesNextContext,
Description: gui.Tr.NextContext,
},
{
ViewName: "volumes",
Key: 'c',
Modifier: gocui.ModNone,
Handler: gui.handleVolumesCustomCommand,
Description: gui.Tr.RunCustomCommand,
},
{
ViewName: "volumes",
Key: 'd',

View file

@ -250,3 +250,19 @@ func (gui *Gui) handlePruneVolumes(g *gocui.Gui, v *gocui.View) error {
})
}, 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)
}