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:
parent
328ce2f995
commit
85a7b7e0fc
38 changed files with 1079 additions and 342 deletions
28
api/internal/edge/url.go
Normal file
28
api/internal/edge/url.go
Normal 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
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue