-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support bulk commands in each of the panels #107
Conversation
@@ -259,3 +259,18 @@ func (gui *Gui) handlePruneImages(g *gocui.Gui, v *gocui.View) error { | |||
}) | |||
}, nil) | |||
} | |||
|
|||
func (gui *Gui) handleImagesCustomCommand(g *gocui.Gui, v *gocui.View) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
U1000: func (*Gui).handleImagesCustomCommand
is unused (from unused
)
pkg/gui/volumes_panel.go
Outdated
@@ -250,3 +250,18 @@ func (gui *Gui) handlePruneVolumes(g *gocui.Gui, v *gocui.View) error { | |||
}) | |||
}, nil) | |||
} | |||
|
|||
func (gui *Gui) handleVolumesCustomCommand(g *gocui.Gui, v *gocui.View) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
U1000: func (*Gui).handleVolumesCustomCommand
is unused (from unused
)
Codecov Report
@@ Coverage Diff @@
## master #107 +/- ##
==========================================
+ Coverage 23.71% 25.97% +2.25%
==========================================
Files 13 13
Lines 1088 1132 +44
==========================================
+ Hits 258 294 +36
- Misses 817 825 +8
Partials 13 13
Continue to review full report at Codecov.
|
772d0f6
to
b6a97ce
Compare
Nice one! I really like the use of a separate key to open bulk shortcuts, looks like it'll work much better than combining with the x shortcuts since it's being applied to all panels. Also good shout to expand to all side panels :)
Looks really good to me - definitely got the ones I'd be looking for there.
Probably, using the bulk menu seems clearer IMO.
I wasn't aware of that, do you know where it was discussed? Agree this adds tech debt if that was a goal, not sure how else we'd do it though. Is there a go lib for docker-compose like there is for docker (assuming that's what docker CLI would be replaced with)?
Seems pretty minor, but maybe we could customise it per panel? 'running bulk container command' / 'running bulk volume command' etc.? A few thoughts from running this locally at work:
|
3c0ca75
to
667911c
Compare
pkg/gui/containers_panel.go
Outdated
return gui.WithWaitingStatus(gui.Tr.StoppingStatus, func() error { | ||
|
||
for _, container := range gui.DockerCommand.Containers { | ||
container.Stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error return value of container.Stop
is not checked (from errcheck
)
pkg/gui/containers_panel.go
Outdated
return gui.WithWaitingStatus(gui.Tr.RemovingStatus, func() error { | ||
|
||
for _, container := range gui.DockerCommand.Containers { | ||
container.Remove(types.ContainerRemoveOptions{Force: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error return value of container.Remove
is not checked (from errcheck
)
Alright I've made some changes. Now we're not using the docker CLI directly for anything, we're using the docker SDK. I've added a new key on our custom command struct called InternalFunction which is the name of a whitelisted internal function e.g. 'pruneContainers'. This is so that we can have custom commands that point to internal functions sitting alongside custom commands that have their own CLI commands. I am a little concerned about the fact that I'm introducing a concept that's not only not type safe, but is spread across a few files. The mapping of whitelisted functions is in custom_commands.go, but referenced in app_config.go, and the actual functions themselves are in the corresponding _panels file. I can't move the mapping into app_config.go because that file has no concept of the gui struct. An alternative would be to have some stock standard custom commands that are not configurable, and those are for the internal functions. Then the remaining custom commands are configurable. I'm leaning towards this approach, but it's going to be a bit messier than what we have now. Any thoughts @mcintyre94 ? |
Unfortunately I'm not very well positioned to do Go code review! I can see what you're refering to though, it looks like it could get a bit tricky to maintain. I wonder if it'd make sense to add a struct for the valid keys of that map, which could (I think?) be available to Or is that what you meant by having some stock commands that aren't configurable? I think I would lean toward something a bit safer but not sure what the best way of achieving that would be. |
Yeah it seems like the right way to do this is to have some bulk commands that are there by default, which aren't configurable and just reference internal functions, and then allow the user to add some extra bulk commands on top which can't reference internal functions. Then we don't need to worry about type safety or keeping things synced up or anything. I'll try to make that happen this week. |
14a5cd9
to
82aba25
Compare
It would be also a good idea to update README if you bumped API version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, seems like I need to update the custom keybindings a lot :D
update api version in readme
2ccb394
to
bd3ce66
Compare
This PR:
docker-compose up -d
anddocker container prune
for the side panels.