Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Sep 19, 2023
1 parent e55fe06 commit 13a7285
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 114 deletions.
2 changes: 1 addition & 1 deletion cmd/headscale/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func initConfig() {

cfg, err := types.GetHeadscaleConfig()
if err != nil {
log.Fatal().Caller().Err(err)
log.Fatal().Caller().Err(err).Msg("Failed to get headscale configuration")
}

machineOutput := HasMachineOutputFlag()
Expand Down
6 changes: 3 additions & 3 deletions cmd/headscale/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ func SuccessOutput(result interface{}, override string, outputFormat string) {
case "json":
jsonBytes, err = json.MarshalIndent(result, "", "\t")
if err != nil {
log.Fatal().Err(err)
log.Fatal().Err(err).Msg("failed to unmarshal output")
}
case "json-line":
jsonBytes, err = json.Marshal(result)
if err != nil {
log.Fatal().Err(err)
log.Fatal().Err(err).Msg("failed to unmarshal output")
}
case "yaml":
jsonBytes, err = yaml.Marshal(result)
if err != nil {
log.Fatal().Err(err)
log.Fatal().Err(err).Msg("failed to unmarshal output")
}
default:
//nolint
Expand Down
6 changes: 4 additions & 2 deletions hscontrol/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func (h *Headscale) handleRegister(
Caller().
Str("func", "RegistrationHandler").
Str("hostinfo.name", registerRequest.Hostinfo.Hostname).
Err(err)
Err(err).
Msg("Failed to generate given name for node")

return
}
Expand Down Expand Up @@ -348,7 +349,8 @@ func (h *Headscale) handleAuthKey(
Bool("noise", isNoise).
Str("func", "RegistrationHandler").
Str("hostinfo.name", registerRequest.Hostinfo.Hostname).
Err(err)
Err(err).
Msg("Failed to generate given name for node")

return
}
Expand Down
4 changes: 2 additions & 2 deletions hscontrol/db/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ func (hsdb *HSDatabase) getPrimaryRoute(prefix netip.Prefix) (*types.Route, erro

// getMachinePrimaryRoutes returns the routes that are enabled and marked as primary (for subnet failover)
// Exit nodes are not considered for this, as they are never marked as Primary.
func (hsdb *HSDatabase) GetMachinePrimaryRoutes(m *types.Machine) (types.Routes, error) {
func (hsdb *HSDatabase) GetMachinePrimaryRoutes(machine *types.Machine) (types.Routes, error) {
hsdb.mu.RLock()
defer hsdb.mu.RUnlock()

var routes types.Routes
err := hsdb.db.
Preload("Machine").
Where("machine_id = ? AND advertised = ? AND enabled = ? AND is_primary = ?", m.ID, true, true, true).
Where("machine_id = ? AND advertised = ? AND enabled = ? AND is_primary = ?", machine.ID, true, true, true).
Find(&routes).Error
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion hscontrol/derp/server/derp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewDERPServer(
cfg *types.DERPConfig,
) (*DERPServer, error) {
log.Trace().Caller().Msg("Creating new embedded DERP server")
server := derp.NewServer(derpKey, log.Debug().Msgf)
server := derp.NewServer(derpKey, log.Debug().Msgf) // nolint // zerolinter complains

return &DERPServer{
serverURL: serverURL,
Expand Down
6 changes: 4 additions & 2 deletions hscontrol/mapper/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
const (
nextDNSDoHPrefix = "https://dns.nextdns.io"
reservedResponseHeaderSize = 4
mapperIDLength = 8
debugMapResponsePerm = 0o755
)

var debugDumpMapResponsePath = envknob.String("HEADSCALE_DEBUG_DUMP_MAPRESPONSE_PATH")
Expand Down Expand Up @@ -72,7 +74,7 @@ func NewMapper(
Str("machine", machine.Hostname).
Msg("creating new mapper")

uid, _ := util.GenerateRandomStringDNSSafe(8)
uid, _ := util.GenerateRandomStringDNSSafe(mapperIDLength)

return &Mapper{
db: db,
Expand Down Expand Up @@ -579,7 +581,7 @@ var zstdEncoderPool = &sync.Pool{
},
}

func (m *Mapper) baseMapResponse(machine *types.Machine) tailcfg.MapResponse {
func (m *Mapper) baseMapResponse(_ *types.Machine) tailcfg.MapResponse {
now := time.Now()

resp := tailcfg.MapResponse{
Expand Down
Loading

0 comments on commit 13a7285

Please sign in to comment.