policy,types: skip recompile when the user list is unchanged

SetUsers now also reports whether user-derived peer adjacency moved.

Updates #3417
This commit is contained in:
Kristoffer Dalby
2026-09-09 14:36:20 +00:00
parent 1bbe59b98d
commit be322e8ea7
6 changed files with 159 additions and 20 deletions
+10
View File
@@ -105,6 +105,16 @@ func (u *User) StringID() string {
return strconv.FormatUint(uint64(u.ID), 10)
}
// PolicyEqual reports whether the policy would resolve both users the same
// way: the same row, and the same name, email, and provider identity that
// user aliases match on.
func (u *User) PolicyEqual(o *User) bool {
return u.ID == o.ID &&
u.Name == o.Name &&
u.Email == o.Email &&
u.ProviderIdentifier == o.ProviderIdentifier
}
// TypedID returns a pointer to the user's ID as a [UserID] type.
// This is a convenience method to avoid ugly casting like ptr.To(types.UserID(user.ID)).
func (u *User) TypedID() *UserID {