headscale/hscontrol/db
Shourya Gautam 4e1834adaf
db: use PolicyManager for RequestTags migration
Refactor the RequestTags migration (202601121700-migrate-hostinfo-request-tags)
to use PolicyManager.NodeCanHaveTag() instead of reimplementing tag validation.

Changes:
- NewHeadscaleDatabase now accepts *types.Config to allow migrations
  access to policy configuration
- Add loadPolicyBytes helper to load policy from file or DB based on config
- Add standalone GetPolicy(tx *gorm.DB) for use during migrations
- Replace custom tag validation logic with PolicyManager

Benefits:
- Full HuJSON parsing support (not just JSON)
- Proper group expansion via PolicyManager
- Support for nested tags and autogroups
- Works with both file and database policy modes
- Single source of truth for tag validation


Co-Authored-By: Shourya Gautam <shouryamgautam@gmail.com>
2026-01-21 15:10:29 +01:00
..
sqliteconfig sqliteconfig: add config opt for tx locking 2025-12-22 14:01:40 +01:00
testdata/sqlite db: use PolicyManager for RequestTags migration 2026-01-21 15:10:29 +01:00
api_key.go types: make pre auth key use bcrypt (#2853) 2025-11-12 16:36:36 +01:00
api_key_test.go grpc: support expire/delete API keys by ID 2026-01-20 17:13:38 +01:00
db.go db: use PolicyManager for RequestTags migration 2026-01-21 15:10:29 +01:00
db_test.go db: use PolicyManager for RequestTags migration 2026-01-21 15:10:29 +01:00
ephemeral_garbage_collector_test.go golangci-lint: use forbidigo to block time.Sleep (#2946) 2025-12-10 16:45:59 +00:00
ip.go fix: free ips from usedIps ipset on DeleteNode 2025-11-11 17:27:00 -06:00
ip_test.go make tags first class node owner (#2885) 2025-12-02 12:01:25 +01:00
node.go make tags first class node owner (#2885) 2025-12-02 12:01:25 +01:00
node_test.go db: migrate tests from check.v1 to testify 2026-01-20 15:41:33 +01:00
policy.go db: use PolicyManager for RequestTags migration 2026-01-21 15:10:29 +01:00
preauth_keys.go hscontrol: allow CreatePreAuthKey without user when tags provided 2026-01-20 12:53:20 +01:00
preauth_keys_test.go cli,hscontrol: use ID-based preauthkey operations 2026-01-20 12:53:20 +01:00
schema.sql make tags first class node owner (#2885) 2025-12-02 12:01:25 +01:00
suite_test.go db: use PolicyManager for RequestTags migration 2026-01-21 15:10:29 +01:00
text_serialiser.go modernize: run gopls modernize to bring up to 1.25 (#2920) 2025-12-01 19:40:25 +01:00
user_update_test.go hscontrol: use Updates() instead of Save() for partial updates 2025-11-11 12:47:48 -06:00
users.go cli,hscontrol: use ID-based preauthkey operations 2026-01-20 12:53:20 +01:00
users_test.go make tags first class node owner (#2885) 2025-12-02 12:01:25 +01:00