1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-25 08:19:40 +02:00

refactor(edge): move edge deploy script to react [EE-2689] (#6747)

This commit is contained in:
Chaim Lev-Ari 2022-04-14 13:14:23 +03:00 committed by GitHub
parent 328ce2f995
commit 85a7b7e0fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 1079 additions and 342 deletions

28
api/internal/edge/url.go Normal file
View file

@ -0,0 +1,28 @@
package edge
import (
"net"
"net/url"
"github.com/pkg/errors"
)
// ParseHostForEdge returns the hostname of the given URL, will fail if host is localhost
func ParseHostForEdge(portainerURL string) (string, error) {
parsedURL, err := url.Parse(portainerURL)
if err != nil {
return "", errors.Wrap(err, "Unable to parse Portainer URL")
}
portainerHost, _, err := net.SplitHostPort(parsedURL.Host)
if err != nil {
portainerHost = parsedURL.Host
}
if portainerHost == "localhost" {
return "", errors.New("cannot use localhost as environment URL")
}
return portainerHost, nil
}