Open service in browser - #252
Merged
Merged
Conversation
jtraub
force-pushed
the
browser-services
branch
from
March 26, 2021 21:15
7e2e5c2 to
6c27cf3
Compare
mjarkk
suggested changes
Mar 27, 2021
Comment on lines
+424
to
+438
| // skip if no any ports | ||
| if len(container.Container.Ports) == 0 { | ||
| return nil | ||
| } | ||
| // skip if the first port is not published | ||
| port := container.Container.Ports[0] | ||
| if port.IP == "" { | ||
| return nil | ||
| } | ||
| ip := port.IP | ||
| if ip == "0.0.0.0" { | ||
| ip = "localhost" | ||
| } | ||
| link := fmt.Sprintf("http://%s:%d/", ip, port.PublicPort) | ||
| return gui.OSCommand.OpenLink(link) |
Contributor
There was a problem hiding this comment.
This seems to be the same code as in container_panel.go > handleContainersOpenInBrowserCommand
Can you abstract this code so we don't have duplicated code?
As you are a bit new to go this is what i would do:
- In
pkg/commands/container.goadd this functionfunc (c *Container) OpenInBrowser() error { - Move the code above to the function created in step 1 (make sure to rename the
containervar toc) - You can now replace the code above to
return container.OpenInBrowser() - Repeat step 3 for
container_panel.go>handleContainersOpenInBrowserCommand
jesseduffield
force-pushed
the
browser-services
branch
from
November 26, 2021 10:38
26c5530 to
5668e58
Compare
jesseduffield
force-pushed
the
browser-services
branch
from
November 26, 2021 10:38
5668e58 to
52fb944
Compare
Owner
|
Given this PR was a little stale I've taken the liberty of doing the refactoring :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I really liked new features in 0.12 but unfortunately Open in browser doesn't work in services panel.
This PR merely creates the same function for services panel. I took a quick look at
pkg/gui/service_panel.goandpkg/gui/containers_panel.goand used copy-paste with slight adoption like I saw in other functions. Sorry if it was bad approach but I have no prior Go experience