[PR #2671] [MERGED] all: use immutable node view in read path #2792

Closed
opened 2025-12-29 04:19:00 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/2671
Author: @kradalby
Created: 7/6/2025
Status: Merged
Merged: 7/7/2025
Merged by: @kradalby

Base: mainHead: kradalby/nodeview


📝 Commits (2)

  • 75bc38c all: use immutable node view in read path
  • 34444fb golangci: disable varnamelen

📊 Changes

25 files changed (+867 additions, -196 deletions)

View changed files

📝 .golangci.yaml (+1 -0)
📝 cmd/headscale/cli/policy.go (+3 -1)
📝 hscontrol/db/node_test.go (+1 -1)
📝 hscontrol/debug.go (+1 -1)
📝 hscontrol/grpcv1.go (+2 -2)
📝 hscontrol/mapper/mapper.go (+41 -34)
📝 hscontrol/mapper/mapper_test.go (+3 -3)
📝 hscontrol/mapper/tail.go (+36 -29)
📝 hscontrol/mapper/tail_test.go (+4 -4)
📝 hscontrol/policy/pm.go (+10 -9)
📝 hscontrol/policy/policy.go (+46 -15)
📝 hscontrol/policy/policy_test.go (+13 -8)
📝 hscontrol/policy/route_approval_test.go (+2 -2)
📝 hscontrol/policy/v2/filter.go (+4 -3)
📝 hscontrol/policy/v2/filter_test.go (+1 -1)
📝 hscontrol/policy/v2/policy.go (+15 -10)
📝 hscontrol/policy/v2/policy_test.go (+1 -1)
📝 hscontrol/policy/v2/types.go (+36 -32)
📝 hscontrol/policy/v2/types_test.go (+7 -7)
📝 hscontrol/poll.go (+31 -23)

...and 5 more files

📄 Description

This commit changes most of our (*)types.Node to
types.NodeView, which is a readonly version of the
underlying node ensuring that there is no mutations
happening in the read path.

Based on the migration, there didnt seem to be any, but the
idea here is to prevent it in the future and simplify other
new implementations.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/2671 **Author:** [@kradalby](https://github.com/kradalby) **Created:** 7/6/2025 **Status:** ✅ Merged **Merged:** 7/7/2025 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `kradalby/nodeview` --- ### 📝 Commits (2) - [`75bc38c`](https://github.com/juanfont/headscale/commit/75bc38c6a791bac49ecee0528439a25df535c6a2) all: use immutable node view in read path - [`34444fb`](https://github.com/juanfont/headscale/commit/34444fb8425d4a97e534fae5d6e0bbf0d05c52db) golangci: disable varnamelen ### 📊 Changes **25 files changed** (+867 additions, -196 deletions) <details> <summary>View changed files</summary> 📝 `.golangci.yaml` (+1 -0) 📝 `cmd/headscale/cli/policy.go` (+3 -1) 📝 `hscontrol/db/node_test.go` (+1 -1) 📝 `hscontrol/debug.go` (+1 -1) 📝 `hscontrol/grpcv1.go` (+2 -2) 📝 `hscontrol/mapper/mapper.go` (+41 -34) 📝 `hscontrol/mapper/mapper_test.go` (+3 -3) 📝 `hscontrol/mapper/tail.go` (+36 -29) 📝 `hscontrol/mapper/tail_test.go` (+4 -4) 📝 `hscontrol/policy/pm.go` (+10 -9) 📝 `hscontrol/policy/policy.go` (+46 -15) 📝 `hscontrol/policy/policy_test.go` (+13 -8) 📝 `hscontrol/policy/route_approval_test.go` (+2 -2) 📝 `hscontrol/policy/v2/filter.go` (+4 -3) 📝 `hscontrol/policy/v2/filter_test.go` (+1 -1) 📝 `hscontrol/policy/v2/policy.go` (+15 -10) 📝 `hscontrol/policy/v2/policy_test.go` (+1 -1) 📝 `hscontrol/policy/v2/types.go` (+36 -32) 📝 `hscontrol/policy/v2/types_test.go` (+7 -7) 📝 `hscontrol/poll.go` (+31 -23) _...and 5 more files_ </details> ### 📄 Description This commit changes most of our (*)types.Node to types.NodeView, which is a readonly version of the underlying node ensuring that there is no mutations happening in the read path. Based on the migration, there didnt seem to be any, but the idea here is to prevent it in the future and simplify other new implementations. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 04:19:00 +01:00
adam closed this issue 2025-12-29 04:19:00 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#2792