fixed host set to localhost even on remote docker, fixed one error in provider causing all routes not to load

This commit is contained in:
yusing
2024-09-21 18:23:20 +08:00
parent 26e2154c64
commit 69361aea1b
8 changed files with 92 additions and 40 deletions

View File

@@ -20,9 +20,23 @@ type Client struct {
l logrus.FieldLogger
}
func ParseDockerHostname(host string) (string, E.NestedError) {
if host == common.DockerHostFromEnv {
return host, nil
} else if host == "" {
return "localhost", nil
}
url, err := E.Check(client.ParseHostURL(host))
if err != nil {
return "", E.Invalid("host", host).With(err)
}
return url.Hostname(), nil
}
func (c Client) DaemonHostname() string {
url, _ := client.ParseHostURL(c.DaemonHost())
return url.Hostname()
// DaemonHost should always return a valid host
hostname, _ := ParseDockerHostname(c.DaemonHost())
return hostname
}
func (c Client) Connected() bool {