1
0
mirror of https://github.com/juanfont/headscale.git synced 2024-12-20 19:09:07 +01:00

chore: apply format and lint

This commit is contained in:
Adrien Raffin-Caboisse 2022-04-15 18:27:57 +02:00
parent cd1d10761f
commit 98f54c9f7f
No known key found for this signature in database
GPG Key ID: 7FB60532DEBEAD6A
8 changed files with 51 additions and 18 deletions

View File

@ -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 {

View File

@ -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,
)
}
},
}

View File

@ -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")

View File

@ -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
}

View File

@ -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 {

View File

@ -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(

View File

@ -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: ,

View File

@ -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;