Linting fixes

This commit is contained in:
Juan Font Alonso 2022-11-04 00:23:20 +01:00
parent 825e88311e
commit c70f5696dc
2 changed files with 15 additions and 16 deletions

View File

@ -1,15 +1,14 @@
package integration
import (
"crypto/tls"
"fmt"
"io"
"log"
"net/http"
"net/url"
"strings"
"testing"
"log"
"time"
)
type AuthWebFlowScenario struct {
@ -127,7 +126,6 @@ func (s *AuthWebFlowScenario) runTailscaleUp(
if err != nil {
log.Printf("failed to register client: %s", err)
}
}(client)
}
namespace.joinWaitGroup.Wait()
@ -143,10 +141,9 @@ func (s *AuthWebFlowScenario) runHeadscaleRegister(namespaceStr string, loginURL
loginURL.Host = fmt.Sprintf("%s:8080", s.Headscale().GetIP())
loginURL.Scheme = "http"
insecureTransport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
httpClient := &http.Client{
Timeout: time.Second * 10,
}
httpClient := &http.Client{Transport: insecureTransport}
resp, err := httpClient.Get(loginURL.String())
if err != nil {
@ -158,21 +155,23 @@ func (s *AuthWebFlowScenario) runHeadscaleRegister(namespaceStr string, loginURL
return err
}
defer resp.Body.Close()
// see api.go HTML template
code := strings.Split(string(body), "</code>")[0]
key := strings.Split(code, "key ")[1]
if headscale, ok := s.controlServers["headscale"]; ok {
_, err = headscale.Execute([]string{
"headscale", "-n", namespaceStr, "nodes", "register", "--key", key})
_, err = headscale.Execute([]string{"headscale", "-n", namespaceStr, "nodes", "register", "--key", key})
if err != nil {
log.Printf("failed to register node: %s", err)
return err
}
log.Printf("registered node %s", key)
return nil
}
return fmt.Errorf("failed to find headscale: %w", errNoHeadscaleAvailable)
}

View File

@ -26,7 +26,6 @@ var (
errTailscalePingFailed = errors.New("ping failed")
errTailscaleNotLoggedIn = errors.New("tailscale not logged in")
errTailscaleWrongPeerCount = errors.New("wrong peer count")
errTailscaleCannotUpWithoutAuthkey = errors.New("cannot up without authkey")
)
type TailscaleInContainer struct {
@ -176,14 +175,15 @@ func (t *TailscaleInContainer) UpWithLoginURL(
urlStr = strings.TrimSpace(urlStr)
// parse URL
loginUrl, err := url.Parse(urlStr)
loginURL, err := url.Parse(urlStr)
if err != nil {
log.Printf("Could not parse login URL: %s", err)
log.Printf("Original join command result: %s", stderr)
return nil, err
}
return loginUrl, nil
return loginURL, nil
}
func (t *TailscaleInContainer) IPs() ([]netip.Addr, error) {