golangci-lint --fix

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2022-10-18 12:09:10 +02:00
parent 4cb7d63e8b
commit 36ad0003a9
No known key found for this signature in database
4 changed files with 41 additions and 34 deletions

View file

@ -15,8 +15,10 @@ import (
"github.com/ory/dockertest/v3" "github.com/ory/dockertest/v3"
) )
const hsicHashLength = 6 const (
const dockerContextPath = "../." hsicHashLength = 6
dockerContextPath = "../."
)
var errHeadscaleStatusCodeNotOk = errors.New("headscale status code not ok") var errHeadscaleStatusCodeNotOk = errors.New("headscale status code not ok")
@ -32,7 +34,8 @@ type HeadscaleInContainer struct {
func New( func New(
pool *dockertest.Pool, pool *dockertest.Pool,
port int, port int,
network *dockertest.Network) (*HeadscaleInContainer, error) { network *dockertest.Network,
) (*HeadscaleInContainer, error) {
hash, err := headscale.GenerateRandomStringDNSSafe(hsicHashLength) hash, err := headscale.GenerateRandomStringDNSSafe(hsicHashLength)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -19,27 +19,29 @@ import (
const scenarioHashLength = 6 const scenarioHashLength = 6
var errNoHeadscaleAvailable = errors.New("no headscale available") var (
var errNoNamespaceAvailable = errors.New("no namespace available") errNoHeadscaleAvailable = errors.New("no headscale available")
var TailscaleVersions = []string{ errNoNamespaceAvailable = errors.New("no namespace available")
"head", TailscaleVersions = []string{
"unstable", "head",
"1.32.0", "unstable",
"1.30.2", "1.32.0",
"1.28.0", "1.30.2",
"1.26.2", "1.28.0",
"1.24.2", "1.26.2",
"1.22.2", "1.24.2",
"1.20.4", "1.22.2",
"1.18.2", "1.20.4",
"1.16.2", "1.18.2",
"1.16.2",
// These versions seem to fail when fetching from apt. // These versions seem to fail when fetching from apt.
// "1.14.6", // "1.14.6",
// "1.12.4", // "1.12.4",
// "1.10.2", // "1.10.2",
// "1.8.7", // "1.8.7",
} }
)
type Namespace struct { type Namespace struct {
Clients map[string]*tsic.TailscaleInContainer Clients map[string]*tsic.TailscaleInContainer
@ -272,7 +274,7 @@ func (s *Scenario) WaitForTailscaleSync() error {
// CreateHeadscaleEnv is a conventient method returning a set up Headcale // CreateHeadscaleEnv is a conventient method returning a set up Headcale
// test environment with nodes of all versions, joined to the server with X // test environment with nodes of all versions, joined to the server with X
// namespaces // namespaces.
func (s *Scenario) CreateHeadscaleEnv(namespaces map[string]int) error { func (s *Scenario) CreateHeadscaleEnv(namespaces map[string]int) error {
err := s.StartHeadscale() err := s.StartHeadscale()
if err != nil { if err != nil {

View file

@ -44,7 +44,6 @@ func TestHeadscale(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("headscale failed to become ready: %s", err) t.Errorf("headscale failed to become ready: %s", err)
} }
}) })
t.Run("create-namespace", func(t *testing.T) { t.Run("create-namespace", func(t *testing.T) {
@ -129,7 +128,6 @@ func TestTailscaleNodesJoiningHeadcale(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("headscale failed to become ready: %s", err) t.Errorf("headscale failed to become ready: %s", err)
} }
}) })
t.Run("create-namespace", func(t *testing.T) { t.Run("create-namespace", func(t *testing.T) {

View file

@ -16,11 +16,15 @@ import (
"tailscale.com/ipn/ipnstate" "tailscale.com/ipn/ipnstate"
) )
const tsicHashLength = 6 const (
const dockerContextPath = "../." tsicHashLength = 6
dockerContextPath = "../."
)
var errTailscalePingFailed = errors.New("ping failed") var (
var errTailscaleNotLoggedIn = errors.New("tailscale not logged in") errTailscalePingFailed = errors.New("ping failed")
errTailscaleNotLoggedIn = errors.New("tailscale not logged in")
)
type TailscaleInContainer struct { type TailscaleInContainer struct {
version string version string
@ -34,7 +38,8 @@ type TailscaleInContainer struct {
func New( func New(
pool *dockertest.Pool, pool *dockertest.Pool,
version string, version string,
network *dockertest.Network) (*TailscaleInContainer, error) { network *dockertest.Network,
) (*TailscaleInContainer, error) {
hash, err := headscale.GenerateRandomStringDNSSafe(tsicHashLength) hash, err := headscale.GenerateRandomStringDNSSafe(tsicHashLength)
if err != nil { if err != nil {
return nil, err return nil, err
@ -130,7 +135,7 @@ func (t *TailscaleInContainer) Up(
return nil return nil
} }
// TODO(kradalby): Make cached/lazy // TODO(kradalby): Make cached/lazy.
func (t *TailscaleInContainer) IPs() ([]netip.Addr, error) { func (t *TailscaleInContainer) IPs() ([]netip.Addr, error) {
ips := make([]netip.Addr, 0) ips := make([]netip.Addr, 0)
@ -213,7 +218,7 @@ func (t *TailscaleInContainer) WaitForPeers(expected int) error {
}) })
} }
// TODO(kradalby): Make multiping, go routine magic // TODO(kradalby): Make multiping, go routine magic.
func (t *TailscaleInContainer) Ping(ip netip.Addr) error { func (t *TailscaleInContainer) Ping(ip netip.Addr) error {
return t.pool.Retry(func() error { return t.pool.Retry(func() error {
command := []string{ command := []string{
@ -245,7 +250,6 @@ func (t *TailscaleInContainer) Ping(ip netip.Addr) error {
return nil return nil
}) })
} }
func createTailscaleBuildOptions(version string) *dockertest.BuildOptions { func createTailscaleBuildOptions(version string) *dockertest.BuildOptions {