Skip to content

Commit

Permalink
Refactor deprecated code. Fix linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
lexbritvin committed Oct 23, 2024
1 parent 72a4078 commit e76960a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ web stop`,
}

if url, _ := getExistingWeb(webPidFile, webRunFlags.PluginDir); url != "" {
return fmt.Errorf("Another web UI is already running at %s\nPlease stop the existing server before starting a new one.", url)
return fmt.Errorf("another web UI is already running at %s\nPlease stop the existing server before starting a new one", url)
}

if foreground {
Expand Down
4 changes: 2 additions & 2 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (l *launchrServer) basePath() string {
}

func (l *launchrServer) GetActions(w http.ResponseWriter, _ *http.Request) {
actions := l.actionMngr.AllRef()
actions := l.actionMngr.All()
var result = make([]ActionShort, 0, len(actions))
for _, a := range actions {
ab, err := apiActionShort(a)
Expand All @@ -142,7 +142,7 @@ func (l *launchrServer) GetActions(w http.ResponseWriter, _ *http.Request) {

func (l *launchrServer) GetActionByID(w http.ResponseWriter, _ *http.Request, id string) {
// @todo return executing actions for a show page.
a, ok := l.actionMngr.GetRef(id)
a, ok := l.actionMngr.Get(id)
if !ok {
sendError(w, http.StatusNotFound, fmt.Sprintf("action with id %q is not found", id))
return
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type RunOptions struct {
ProxyClient string
}

// BaseURL returns base url for run options.
func (o RunOptions) BaseURL() string {
return "http://localhost:" + strings.Split(o.Addr, ":")[1]
}
Expand Down
4 changes: 2 additions & 2 deletions web_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func stopWeb(pidFile, pluginDir string) (err error) {
}

if checkHealth(serverRunInfo.URL) {
return fmt.Errorf("The web UI is currently running at %s\nPlease stop it through the user interface or terminate the process.", serverRunInfo.URL)
return fmt.Errorf("the web UI is currently running at %s\nPlease stop it through the user interface or terminate the process", serverRunInfo.URL)
}

launchr.Term().Success().Println(onSuccess)
Expand Down Expand Up @@ -226,7 +226,7 @@ func cleanupPluginTemp(dir string) {

// checkHealth helper to check if server is available by request.
func checkHealth(url string) bool {
resp, err := http.Head(url)
resp, err := http.Head(url) //nolint G107 // @todo URL may come from user input, potential vulnerability.
if err != nil {
// Error is thrown on an incorrect url.
panic(err)
Expand Down

0 comments on commit e76960a

Please sign in to comment.