headscale/hscontrol/state
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
..
auth_cache_test.go state: replace zcache with bounded LRU for auth cache 2026-04-10 14:09:57 +01:00
debug.go state: switch consumers to NodeStore primary routes 2026-04-29 18:08:39 +01:00
debug_test.go hscontrol/state: make NodeStore batch configuration tunable (#2886) 2025-11-28 16:38:29 +01:00
endpoint_test.go hscontrol/state: make NodeStore batch configuration tunable (#2886) 2025-11-28 16:38:29 +01:00
ephemeral_test.go all: upgrade to Go 1.26rc2 and modernize codebase 2026-02-08 12:35:23 +01:00
ha_health.go state: per-goroutine deadline in HA probe cycle 2026-04-30 12:52:05 +01:00
maprequest.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
maprequest_test.go all: fix golangci-lint issues (#3064) 2026-02-06 21:45:32 +01:00
node_store.go state: preserve previous primary when all HA advertisers unhealthy 2026-04-29 18:08:39 +01:00
node_store_hostname_test.go state: auto-bump GivenName on collision and add SetGivenName 2026-04-18 15:12:21 +01:00
node_store_test.go types: persist Node JSON slices via named IsZero types 2026-05-15 11:21:58 +02:00
ping.go state: drain pending pings on Close 2026-04-17 16:31:49 +01:00
ping_test.go state: drain pending pings on Close 2026-04-17 16:31:49 +01:00
primaries_property_test.go state: preserve previous primary when all HA advertisers unhealthy 2026-04-29 18:08:39 +01:00
primaries_test.go state: preserve previous primary when all HA advertisers unhealthy 2026-04-29 18:08:39 +01:00
ssh_check_test.go state, policy, noise: implement SSH check period auto-approval 2026-02-25 21:28:05 +01:00
state.go mapper, state: deliver nodeAttrs through MapResponse and harden nextdns DoH rewrite 2026-05-13 14:22:30 +02:00
tags.go hscontrol: enforce that tagged nodes never have user_id 2026-02-20 21:51:00 +01:00
test_helpers.go hscontrol/state: make NodeStore batch configuration tunable (#2886) 2025-11-28 16:38:29 +01:00