headscale/hscontrol/types
Kristoffer Dalby 7a20db9f49 types: persist Node JSON slices via named IsZero types
Endpoints, Tags and ApprovedRoutes serialize as JSON on Node. GORM's
struct Updates path skips fields it considers zero, and reflect treats
a nil slice as zero — clearing any of these columns via the State
persist path would leave the previous value in the database.

Introduce Strings, Prefixes and AddrPorts as named slice types whose
IsZero() always reports false, so GORM keeps the column in the UPDATE
regardless of the slice being nil or empty. JSON marshalling is
unchanged: nil serializes to null, empty to []. List() returns the
underlying unnamed slice for callers (mainly testify assertions over
reflect.DeepEqual) that distinguish the named type from its base.

Regenerated types_clone.go and types_view.go follow the field-type
swap. Test assertions across hscontrol/{db,state,servertest} updated
to call .List() where reflect.DeepEqual previously matched the raw
slice type.

Fixes #3110
2026-05-15 11:21:58 +02:00
..
change change: document PingRequest merge first-wins foot-gun 2026-04-17 16:31:49 +01:00
testcapture policy/v2: SaaS-derived compat tests for nodeAttrs 2026-05-13 14:22:30 +02:00
testdata Restore support for "Override local DNS" (#2438) 2025-04-17 17:16:59 +02:00
api_key.go types: add MarshalZerologObject to domain types 2026-02-06 07:40:29 +01:00
common.go oidc: add confirmation page for node registration 2026-04-10 14:09:57 +01:00
common_test.go oidc: add confirmation page for node registration 2026-04-10 14:09:57 +01:00
config.go types/config, types/node: model default-auto-update from auto_update.enabled 2026-05-13 14:22:30 +02:00
config_test.go types: omit secret fields from JSON marshalling 2026-04-10 14:09:57 +01:00
const.go improve testing of route failover logic 2024-04-15 12:31:53 +02:00
debug_routes.go types: move DebugRoutes from routes to types 2026-04-29 18:08:39 +01:00
main_test.go all: fix test flakiness and improve test infrastructure 2026-03-14 02:52:28 -07:00
node.go types: persist Node JSON slices via named IsZero types 2026-05-15 11:21:58 +02:00
node_benchmark_test.go types: avoid NodeView clone in CanAccess 2026-02-26 19:15:07 -08:00
node_tags_test.go all: upgrade to Go 1.26rc2 and modernize codebase 2026-02-08 12:35:23 +01:00
node_test.go hscontrol: route hostname handling through dnsname and NodeStore 2026-04-18 15:12:21 +01:00
policy.go feat: implements apis for managing headscale policy (#1792) 2024-07-18 07:38:25 +02:00
preauth_key.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
preauth_key_test.go all: upgrade to Go 1.26rc2 and modernize codebase 2026-02-08 12:35:23 +01:00
registration.go state: replace zcache with bounded LRU for auth cache 2026-04-10 14:09:57 +01:00
routes.go Redo route code (#2422) 2025-02-26 16:22:55 +01:00
slices.go types: persist Node JSON slices via named IsZero types 2026-05-15 11:21:58 +02:00
testlog.go hscontrol/types: silence zerolog by default in tests 2026-04-17 16:31:49 +01:00
types_clone.go types: persist Node JSON slices via named IsZero types 2026-05-15 11:21:58 +02:00
types_view.go types: persist Node JSON slices via named IsZero types 2026-05-15 11:21:58 +02:00
users.go oidc: handle groups claim as string or array (FlexibleStringSlice) 2026-05-04 15:26:53 +02:00
users_test.go oidc: handle groups claim as string or array (FlexibleStringSlice) 2026-05-04 15:26:53 +02:00
version.go all: apply formatter changes 2026-04-13 17:23:47 +01:00