Skip to content

Commit 8571513

Browse files
authored
reformat code (#2019)
* reformat code This is mostly an automated change with `make lint`. I had to manually please golangci-lint in routes_test because of a short variable name. * fix start -> strategy which was wrongly corrected by linter
1 parent ca47d6f commit 8571513

23 files changed

Lines changed: 56 additions & 65 deletions

File tree

cmd/headscale/cli/policy.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import (
44
"io"
55
"os"
66

7+
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
78
"github.com/rs/zerolog/log"
89
"github.com/spf13/cobra"
9-
10-
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
1110
)
1211

1312
func init() {

cmd/headscale/cli/utils.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ import (
77
"fmt"
88
"os"
99

10+
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
11+
"github.com/juanfont/headscale/hscontrol"
12+
"github.com/juanfont/headscale/hscontrol/types"
13+
"github.com/juanfont/headscale/hscontrol/util"
1014
"github.com/rs/zerolog/log"
1115
"google.golang.org/grpc"
1216
"google.golang.org/grpc/credentials"
1317
"google.golang.org/grpc/credentials/insecure"
1418
"gopkg.in/yaml.v3"
15-
16-
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
17-
"github.com/juanfont/headscale/hscontrol"
18-
"github.com/juanfont/headscale/hscontrol/types"
19-
"github.com/juanfont/headscale/hscontrol/util"
2019
)
2120

2221
const (

hscontrol/app.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ import (
2323
"github.com/gorilla/mux"
2424
grpcMiddleware "github.com/grpc-ecosystem/go-grpc-middleware"
2525
grpcRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
26+
"github.com/juanfont/headscale"
27+
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
28+
"github.com/juanfont/headscale/hscontrol/db"
29+
"github.com/juanfont/headscale/hscontrol/derp"
30+
derpServer "github.com/juanfont/headscale/hscontrol/derp/server"
31+
"github.com/juanfont/headscale/hscontrol/mapper"
32+
"github.com/juanfont/headscale/hscontrol/notifier"
33+
"github.com/juanfont/headscale/hscontrol/policy"
34+
"github.com/juanfont/headscale/hscontrol/types"
35+
"github.com/juanfont/headscale/hscontrol/util"
2636
"github.com/patrickmn/go-cache"
2737
zerolog "github.com/philip-bui/grpc-zerolog"
2838
"github.com/pkg/profile"
@@ -47,17 +57,6 @@ import (
4757
"tailscale.com/types/dnstype"
4858
"tailscale.com/types/key"
4959
"tailscale.com/util/dnsname"
50-
51-
"github.com/juanfont/headscale"
52-
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
53-
"github.com/juanfont/headscale/hscontrol/db"
54-
"github.com/juanfont/headscale/hscontrol/derp"
55-
derpServer "github.com/juanfont/headscale/hscontrol/derp/server"
56-
"github.com/juanfont/headscale/hscontrol/mapper"
57-
"github.com/juanfont/headscale/hscontrol/notifier"
58-
"github.com/juanfont/headscale/hscontrol/policy"
59-
"github.com/juanfont/headscale/hscontrol/types"
60-
"github.com/juanfont/headscale/hscontrol/util"
6160
)
6261

6362
var (
@@ -680,7 +679,7 @@ func (h *Headscale) Serve() error {
680679
Handler: router,
681680
ReadTimeout: types.HTTPTimeout,
682681

683-
// Long polling should not have any timeout, this is overriden
682+
// Long polling should not have any timeout, this is overridden
684683
// further down the chain
685684
WriteTimeout: types.HTTPTimeout,
686685
}

hscontrol/auth.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ func (h *Headscale) handleAuthKey(
337337
if len(aclTags) > 0 {
338338
// This conditional preserves the existing behaviour, although SaaS would reset the tags on auth-key login
339339
err = h.db.SetTags(node.ID, aclTags)
340-
341340
if err != nil {
342341
log.Error().
343342
Caller().

hscontrol/db/db.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ import (
1313

1414
"github.com/glebarez/sqlite"
1515
"github.com/go-gormigrate/gormigrate/v2"
16+
"github.com/juanfont/headscale/hscontrol/types"
17+
"github.com/juanfont/headscale/hscontrol/util"
1618
"github.com/rs/zerolog/log"
1719
"gorm.io/driver/postgres"
1820
"gorm.io/gorm"
1921
"gorm.io/gorm/logger"
20-
21-
"github.com/juanfont/headscale/hscontrol/types"
22-
"github.com/juanfont/headscale/hscontrol/util"
2322
)
2423

2524
var errDatabaseNotSupported = errors.New("database type not supported")
@@ -331,7 +330,7 @@ func NewHeadscaleDatabase(
331330
// IP v4 and v6 column.
332331
// Note that previously, the list _could_ contain more
333332
// than two addresses, which should not really happen.
334-
// In that case, the first occurence of each type will
333+
// In that case, the first occurrence of each type will
335334
// be kept.
336335
ID: "2024041121742",
337336
Migrate: func(tx *gorm.DB) error {

hscontrol/db/ip.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ func NewIPAllocator(
7676
if err != nil {
7777
return nil, fmt.Errorf("reading IPv6 addresses from database: %w", err)
7878
}
79-
8079
}
8180

8281
var ips netipx.IPSetBuilder

hscontrol/db/ip_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ var mpp = func(pref string) *netip.Prefix {
1818
p := netip.MustParsePrefix(pref)
1919
return &p
2020
}
21+
2122
var na = func(pref string) netip.Addr {
2223
return netip.MustParseAddr(pref)
2324
}
25+
2426
var nap = func(pref string) *netip.Addr {
2527
n := na(pref)
2628
return &n

hscontrol/db/node_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ import (
1212
"time"
1313

1414
"github.com/google/go-cmp/cmp"
15+
"github.com/juanfont/headscale/hscontrol/policy"
16+
"github.com/juanfont/headscale/hscontrol/types"
17+
"github.com/juanfont/headscale/hscontrol/util"
1518
"github.com/puzpuzpuz/xsync/v3"
1619
"github.com/stretchr/testify/assert"
1720
"gopkg.in/check.v1"
1821
"tailscale.com/tailcfg"
1922
"tailscale.com/types/key"
2023
"tailscale.com/types/ptr"
21-
22-
"github.com/juanfont/headscale/hscontrol/policy"
23-
"github.com/juanfont/headscale/hscontrol/types"
24-
"github.com/juanfont/headscale/hscontrol/util"
2524
)
2625

2726
func (s *Suite) TestGetNode(c *check.C) {

hscontrol/db/policy.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package db
22

33
import (
4-
"gorm.io/gorm"
5-
"gorm.io/gorm/clause"
6-
74
"errors"
85

96
"github.com/juanfont/headscale/hscontrol/types"
7+
"gorm.io/gorm"
8+
"gorm.io/gorm/clause"
109
)
1110

1211
// SetPolicy sets the policy in the database.

hscontrol/db/routes.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,6 @@ func failoverRoute(
542542
isLikelyConnected *xsync.MapOf[types.NodeID, bool],
543543
routeToReplace *types.Route,
544544
altRoutes types.Routes,
545-
546545
) *failover {
547546
if routeToReplace == nil {
548547
return nil

0 commit comments

Comments
 (0)