Linting fixes + disable interfacebloat linter

This commit is contained in:
Juan Font Alonso 2022-11-04 11:41:45 +01:00
parent 9f64ac8a33
commit b3f5af30a4
2 changed files with 18 additions and 4 deletions

View file

@ -33,6 +33,9 @@ linters:
- makezero
- maintidx
# Limits the methods of an interface to 10. We have more in integration tests
- interfacebloat
# We might want to enable this, but it might be a lot of work
- cyclop
- nestif

View file

@ -2,6 +2,7 @@ package integration
import (
"context"
"errors"
"fmt"
"io"
"log"
@ -11,6 +12,8 @@ import (
"testing"
)
var errParseAuthPage = errors.New("failed to parse auth page")
type AuthWebFlowScenario struct {
*Scenario
}
@ -157,8 +160,18 @@ func (s *AuthWebFlowScenario) runHeadscaleRegister(namespaceStr string, loginURL
defer resp.Body.Close()
// see api.go HTML template
code := strings.Split(string(body), "</code>")[0]
key := strings.Split(code, "key ")[1]
codeSep := strings.Split(string(body), "</code>")
if len(codeSep) != 2 {
return errParseAuthPage
}
keySep := strings.Split(codeSep[0], "key ")
if len(keySep) != 2 {
return errParseAuthPage
}
key := keySep[1]
log.Printf("registering node %s", key)
if headscale, ok := s.controlServers["headscale"]; ok {
_, err = headscale.Execute([]string{"headscale", "-n", namespaceStr, "nodes", "register", "--key", key})
if err != nil {
@ -167,8 +180,6 @@ func (s *AuthWebFlowScenario) runHeadscaleRegister(namespaceStr string, loginURL
return err
}
log.Printf("registered node %s", key)
return nil
}