From 98f54c9f7f9044f1d309c5ee26562e1e22bcca7f Mon Sep 17 00:00:00 2001 From: Adrien Raffin-Caboisse Date: Fri, 15 Apr 2022 18:27:57 +0200 Subject: [PATCH] chore: apply format and lint --- acls.go | 6 +++++- cmd/headscale/cli/tags.go | 12 ++++++------ cmd/headscale/cli/utils.go | 3 ++- derp_server.go | 15 ++++++++++++--- integration_common_test.go | 11 ++++++++++- integration_embedded_derp_test.go | 19 +++++++++++++++---- machine.go | 2 +- proto/headscale/v1/machine.proto | 1 - 8 files changed, 51 insertions(+), 18 deletions(-) diff --git a/acls.go b/acls.go index 6446b67..2fa2e4f 100644 --- a/acls.go +++ b/acls.go @@ -261,7 +261,11 @@ func expandAlias( } } if len(ips) == 0 { - return ips, fmt.Errorf("%w. %v isn't owned by a TagOwner and no forced tags are defined.", errInvalidTag, alias) + return ips, fmt.Errorf( + "%w. %v isn't owned by a TagOwner and no forced tags are defined.", + errInvalidTag, + alias, + ) } return ips, nil } else { diff --git a/cmd/headscale/cli/tags.go b/cmd/headscale/cli/tags.go index c40b639..ec42c9a 100644 --- a/cmd/headscale/cli/tags.go +++ b/cmd/headscale/cli/tags.go @@ -16,7 +16,8 @@ func init() { if err != nil { log.Fatalf(err.Error()) } - addTagCmd.Flags().StringSliceP("tags", "t", []string{}, "List of tags to add to the node") + addTagCmd.Flags(). + StringSliceP("tags", "t", []string{}, "List of tags to add to the node") tagCmd.AddCommand(addTagCmd) delTagCmd.Flags().Uint64P("identifier", "i", 0, "Node identifier (ID)") @@ -24,7 +25,8 @@ func init() { if err != nil { log.Fatalf(err.Error()) } - delTagCmd.Flags().StringSliceP("tags", "t", []string{}, "List of tags to remove from the node") + delTagCmd.Flags(). + StringSliceP("tags", "t", []string{}, "List of tags to remove from the node") tagCmd.AddCommand(delTagCmd) } @@ -58,7 +60,7 @@ var addTagCmd = &cobra.Command{ if err != nil { ErrorOutput( err, - fmt.Sprintf("Error retrieving list of tags to add to machine", err), + fmt.Sprintf("Error retrieving list of tags to add to machine, %v", err), output, ) @@ -110,7 +112,6 @@ var addTagCmd = &cobra.Command{ output, ) } - }, } @@ -139,7 +140,7 @@ var delTagCmd = &cobra.Command{ if err != nil { ErrorOutput( err, - fmt.Sprintf("Error retrieving list of tags to add to machine", err), + fmt.Sprintf("Error retrieving list of tags to add to machine: %v", err), output, ) @@ -193,7 +194,6 @@ var delTagCmd = &cobra.Command{ output, ) } - }, } diff --git a/cmd/headscale/cli/utils.go b/cmd/headscale/cli/utils.go index 992d125..5c72459 100644 --- a/cmd/headscale/cli/utils.go +++ b/cmd/headscale/cli/utils.go @@ -127,7 +127,8 @@ func GetDERPConfig() headscale.DERPConfig { stunAddr := viper.GetString("derp.server.stun_listen_addr") if serverEnabled && stunAddr == "" { - log.Fatal().Msg("derp.server.stun_listen_addr must be set if derp.server.enabled is true") + log.Fatal(). + Msg("derp.server.stun_listen_addr must be set if derp.server.enabled is true") } urlStrs := viper.GetStringSlice("derp.urls") diff --git a/derp_server.go b/derp_server.go index 6580419..d6fb47d 100644 --- a/derp_server.go +++ b/derp_server.go @@ -107,7 +107,10 @@ func (h *Headscale) DERPHandler(ctx *gin.Context) { hijacker, ok := ctx.Writer.(http.Hijacker) if !ok { log.Error().Caller().Msg("DERP requires Hijacker interface from Gin") - ctx.String(http.StatusInternalServerError, "HTTP does not support general TCP support") + ctx.String( + http.StatusInternalServerError, + "HTTP does not support general TCP support", + ) return } @@ -115,7 +118,10 @@ func (h *Headscale) DERPHandler(ctx *gin.Context) { netConn, conn, err := hijacker.Hijack() if err != nil { log.Error().Caller().Err(err).Msgf("Hijack failed") - ctx.String(http.StatusInternalServerError, "HTTP does not support general TCP support") + ctx.String( + http.StatusInternalServerError, + "HTTP does not support general TCP support", + ) return } @@ -163,7 +169,10 @@ func (h *Headscale) DERPBootstrapDNSHandler(ctx *gin.Context) { for _, node := range region.Nodes { // we don't care if we override some nodes addrs, err := r.LookupIP(resolvCtx, "ip", node.HostName) if err != nil { - log.Trace().Caller().Err(err).Msgf("bootstrap DNS lookup failed %q", node.HostName) + log.Trace(). + Caller(). + Err(err). + Msgf("bootstrap DNS lookup failed %q", node.HostName) continue } diff --git a/integration_common_test.go b/integration_common_test.go index f7afb80..04285fb 100644 --- a/integration_common_test.go +++ b/integration_common_test.go @@ -20,7 +20,16 @@ var ( IpPrefix4 = netaddr.MustParseIPPrefix("100.64.0.0/10") IpPrefix6 = netaddr.MustParseIPPrefix("fd7a:115c:a1e0::/48") - tailscaleVersions = []string{"head", "unstable", "1.22.2", "1.20.4", "1.18.2", "1.16.2", "1.14.3", "1.12.3"} + tailscaleVersions = []string{ + "head", + "unstable", + "1.22.2", + "1.20.4", + "1.18.2", + "1.16.2", + "1.14.3", + "1.12.3", + } ) type TestNamespace struct { diff --git a/integration_embedded_derp_test.go b/integration_embedded_derp_test.go index 54eec80..5e42fd7 100644 --- a/integration_embedded_derp_test.go +++ b/integration_embedded_derp_test.go @@ -107,7 +107,10 @@ func (s *IntegrationDERPTestSuite) SetupSuite() { headscaleOptions := &dockertest.RunOptions{ Name: headscaleHostname, Mounts: []string{ - fmt.Sprintf("%s/integration_test/etc_embedded_derp:/etc/headscale", currentPath), + fmt.Sprintf( + "%s/integration_test/etc_embedded_derp:/etc/headscale", + currentPath, + ), }, Cmd: []string{"headscale", "serve"}, ExposedPorts: []string{"8443/tcp", "3478/udp"}, @@ -197,7 +200,10 @@ func (s *IntegrationDERPTestSuite) SetupSuite() { assert.Nil(s.T(), err) assert.True(s.T(), preAuthKey.Reusable) - headscaleEndpoint := fmt.Sprintf("https://headscale:%s", s.headscale.GetPort("8443/tcp")) + headscaleEndpoint := fmt.Sprintf( + "https://headscale:%s", + s.headscale.GetPort("8443/tcp"), + ) log.Printf( "Joining tailscale containers to headscale at %s\n", @@ -243,7 +249,9 @@ func (s *IntegrationDERPTestSuite) Join( log.Printf("%s joined\n", hostname) } -func (s *IntegrationDERPTestSuite) tailscaleContainer(identifier, version string, network dockertest.Network, +func (s *IntegrationDERPTestSuite) tailscaleContainer( + identifier, version string, + network dockertest.Network, ) (string, *dockertest.Resource) { tailscaleBuildOptions := getDockerBuildOptions(version) @@ -260,7 +268,10 @@ func (s *IntegrationDERPTestSuite) tailscaleContainer(identifier, version string }, // expose the host IP address, so we can access it from inside the container - ExtraHosts: []string{"host.docker.internal:host-gateway", "headscale:host-gateway"}, + ExtraHosts: []string{ + "host.docker.internal:host-gateway", + "headscale:host-gateway", + }, } pts, err := s.pool.BuildAndRunWithBuildOptions( diff --git a/machine.go b/machine.go index a776d90..43325c9 100644 --- a/machine.go +++ b/machine.go @@ -631,7 +631,7 @@ func (machine *Machine) toProto() *v1.Machine { IpAddresses: machine.IPAddresses.ToStringSlice(), Name: machine.Name, Namespace: machine.Namespace.toProto(), - ForcedTags: machine.ForcedTags, + ForcedTags: machine.ForcedTags, // TODO(kradalby): Implement register method enum converter // RegisterMethod: , diff --git a/proto/headscale/v1/machine.proto b/proto/headscale/v1/machine.proto index 32b4be3..fedf595 100644 --- a/proto/headscale/v1/machine.proto +++ b/proto/headscale/v1/machine.proto @@ -22,7 +22,6 @@ message Machine { string name = 6; Namespace namespace = 7; - google.protobuf.Timestamp last_seen = 8; google.protobuf.Timestamp last_successful_update = 9; google.protobuf.Timestamp expiry = 10;