1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 15:29:42 +02:00

fix(swarm): fixed issue parsing url with no scheme [EE-4017] (#7502)

This commit is contained in:
Matt Hook 2022-08-26 11:55:55 +12:00 committed by GitHub
parent 27095ede22
commit a54c54ef24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 67 additions and 50 deletions

View file

@ -5,18 +5,17 @@ import (
"errors"
"fmt"
"net/http"
netUrl "net/url"
"strconv"
"strings"
"time"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/internal/url"
)
// GetAgentVersionAndPlatform returns the agent version and platform
//
// it sends a ping to the agent and parses the version and platform from the headers
func GetAgentVersionAndPlatform(url string, tlsConfig *tls.Config) (portainer.AgentPlatform, string, error) {
func GetAgentVersionAndPlatform(endpointUrl string, tlsConfig *tls.Config) (portainer.AgentPlatform, string, error) {
httpCli := &http.Client{
Timeout: 3 * time.Second,
}
@ -27,11 +26,7 @@ func GetAgentVersionAndPlatform(url string, tlsConfig *tls.Config) (portainer.Ag
}
}
if !strings.Contains(url, "://") {
url = "https://" + url
}
parsedURL, err := netUrl.Parse(fmt.Sprintf("%s/ping", url))
parsedURL, err := url.ParseURL(endpointUrl + "/ping")
if err != nil {
return 0, "", err
}