1
0
mirror of https://github.com/juanfont/headscale.git synced 2026-02-07 20:04:00 +01:00

all: fix errchkjson, contextcheck, containedctx, embeddedstructfieldcheck

- Add nolint:errchkjson comments to test json.Marshal calls
- Add nolint:contextcheck comments to intentional context patterns
- Add nolint:containedctx comment to mapSession struct (context stored for session lifecycle)
- Add nolint:embeddedstructfieldcheck to User struct (intentional formatting)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Kristoffer Dalby 2026-02-06 08:15:01 +00:00
parent 7e1d0289fd
commit 215030b570
7 changed files with 10 additions and 10 deletions

View File

@ -299,7 +299,7 @@ func (h *Headscale) scheduledTasks(ctx context.Context) {
case <-derpTickerChan:
log.Info().Msg("fetching DERPMap updates")
derpMap, err := backoff.Retry(ctx, func() (*tailcfg.DERPMap, error) {
derpMap, err := backoff.Retry(ctx, func() (*tailcfg.DERPMap, error) { //nolint:contextcheck
derpMap, err := derp.GetDERPMap(h.cfg.DERP)
if err != nil {
return nil, err

View File

@ -248,7 +248,7 @@ func (ns *noiseServer) NoiseRegistrationHandler(
return
}
registerRequest, registerResponse := func() (*tailcfg.RegisterRequest, *tailcfg.RegisterResponse) {
registerRequest, registerResponse := func() (*tailcfg.RegisterRequest, *tailcfg.RegisterResponse) { //nolint:contextcheck
var resp *tailcfg.RegisterResponse
body, err := io.ReadAll(req.Body)

View File

@ -68,7 +68,7 @@ func NewAuthProviderOIDC(
) (*AuthProviderOIDC, error) {
var err error
// grab oidc config if it hasn't been already
oidcProvider, err := oidc.NewProvider(context.Background(), cfg.Issuer)
oidcProvider, err := oidc.NewProvider(context.Background(), cfg.Issuer) //nolint:contextcheck
if err != nil {
return nil, fmt.Errorf("creating OIDC provider from issuer config: %w", err)
}

View File

@ -30,7 +30,7 @@ const nodeNameContextKey = contextKey("nodeName")
type mapSession struct {
h *Headscale
req tailcfg.MapRequest
ctx context.Context
ctx context.Context //nolint:containedctx
capVer tailcfg.CapabilityVersion
cancelChMu deadlock.Mutex

View File

@ -61,7 +61,7 @@ func (u Users) String() string {
// At the end of the day, users in Tailscale are some kind of 'bubbles' or users
// that contain our machines.
type User struct {
gorm.Model
gorm.Model //nolint:embeddedstructfieldcheck
// The index `idx_name_provider_identifier` is to enforce uniqueness
// between Name and ProviderIdentifier. This ensures that

View File

@ -1658,7 +1658,7 @@ func TestPolicyCommand(t *testing.T) {
},
}
pBytes, _ := json.Marshal(p)
pBytes, _ := json.Marshal(p) //nolint:errchkjson
policyFilePath := "/etc/headscale/policy.json"
@ -1745,7 +1745,7 @@ func TestPolicyBrokenConfigCommand(t *testing.T) {
},
}
pBytes, _ := json.Marshal(p)
pBytes, _ := json.Marshal(p) //nolint:errchkjson
policyFilePath := "/etc/headscale/policy.json"

View File

@ -93,7 +93,7 @@ func TestResolveMagicDNSExtraRecordsPath(t *testing.T) {
Value: "6.6.6.6",
},
}
b, _ := json.Marshal(extraRecords)
b, _ := json.Marshal(extraRecords) //nolint:errchkjson
err = scenario.CreateHeadscaleEnv([]tsic.Option{
tsic.WithPackages("python3", "curl", "bind-tools"),
@ -133,7 +133,7 @@ func TestResolveMagicDNSExtraRecordsPath(t *testing.T) {
require.NoError(t, err)
// Write the file directly into place from the docker API.
b0, _ := json.Marshal([]tailcfg.DNSRecord{
b0, _ := json.Marshal([]tailcfg.DNSRecord{ //nolint:errchkjson
{
Name: "docker.myvpn.example.com",
Type: "A",
@ -155,7 +155,7 @@ func TestResolveMagicDNSExtraRecordsPath(t *testing.T) {
Type: "A",
Value: "7.7.7.7",
})
b2, _ := json.Marshal(extraRecords)
b2, _ := json.Marshal(extraRecords) //nolint:errchkjson
err = hs.WriteFile(erPath+"2", b2)
require.NoError(t, err)