mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-26 08:53:05 +00:00
remove the need to bind host port
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
84f9f604b0
commit
c90d0dd843
1 changed files with 6 additions and 9 deletions
|
@ -13,7 +13,6 @@ import (
|
||||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||||
"github.com/juanfont/headscale/integration/dockertestutil"
|
"github.com/juanfont/headscale/integration/dockertestutil"
|
||||||
"github.com/ory/dockertest/v3"
|
"github.com/ory/dockertest/v3"
|
||||||
"github.com/ory/dockertest/v3/docker"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const hsicHashLength = 6
|
const hsicHashLength = 6
|
||||||
|
@ -46,7 +45,6 @@ func New(
|
||||||
|
|
||||||
hostname := fmt.Sprintf("hs-%s", hash)
|
hostname := fmt.Sprintf("hs-%s", hash)
|
||||||
portProto := fmt.Sprintf("%d/tcp", port)
|
portProto := fmt.Sprintf("%d/tcp", port)
|
||||||
dockerPort := docker.Port(portProto)
|
|
||||||
|
|
||||||
currentPath, err := os.Getwd()
|
currentPath, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -64,9 +62,6 @@ func New(
|
||||||
},
|
},
|
||||||
ExposedPorts: []string{portProto},
|
ExposedPorts: []string{portProto},
|
||||||
// TODO(kradalby): WHY do we need to bind these now that we run fully in docker?
|
// TODO(kradalby): WHY do we need to bind these now that we run fully in docker?
|
||||||
PortBindings: map[docker.Port][]docker.PortBinding{
|
|
||||||
dockerPort: {{HostPort: fmt.Sprintf("%d", port)}},
|
|
||||||
},
|
|
||||||
Networks: []*dockertest.Network{network},
|
Networks: []*dockertest.Network{network},
|
||||||
Cmd: []string{"headscale", "serve"},
|
Cmd: []string{"headscale", "serve"},
|
||||||
}
|
}
|
||||||
|
@ -116,17 +111,17 @@ func (t *HeadscaleInContainer) GetPort() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *HeadscaleInContainer) GetHealthEndpoint() string {
|
func (t *HeadscaleInContainer) GetHealthEndpoint() string {
|
||||||
hostEndpoint := fmt.Sprintf("%s:%s",
|
hostEndpoint := fmt.Sprintf("%s:%d",
|
||||||
t.GetIP(),
|
t.GetIP(),
|
||||||
t.GetPort())
|
t.port)
|
||||||
|
|
||||||
return fmt.Sprintf("http://%s/health", hostEndpoint)
|
return fmt.Sprintf("http://%s/health", hostEndpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *HeadscaleInContainer) GetEndpoint() string {
|
func (t *HeadscaleInContainer) GetEndpoint() string {
|
||||||
hostEndpoint := fmt.Sprintf("%s:%s",
|
hostEndpoint := fmt.Sprintf("%s:%d",
|
||||||
t.GetIP(),
|
t.GetIP(),
|
||||||
t.GetPort())
|
t.port)
|
||||||
|
|
||||||
return fmt.Sprintf("http://%s", hostEndpoint)
|
return fmt.Sprintf("http://%s", hostEndpoint)
|
||||||
}
|
}
|
||||||
|
@ -134,6 +129,8 @@ func (t *HeadscaleInContainer) GetEndpoint() string {
|
||||||
func (t *HeadscaleInContainer) WaitForReady() error {
|
func (t *HeadscaleInContainer) WaitForReady() error {
|
||||||
url := t.GetHealthEndpoint()
|
url := t.GetHealthEndpoint()
|
||||||
|
|
||||||
|
log.Printf("waiting for headscale to be ready at %s", url)
|
||||||
|
|
||||||
return t.pool.Retry(func() error {
|
return t.pool.Retry(func() error {
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue