util/syspolicy/*: move syspolicy keys to new const leaf "pkey" package
This is step 1 of ~3, breaking up #14720 into reviewable chunks, with the aim to make syspolicy be a build-time configurable feature. In this first (very noisy) step, all the syspolicy string key constants move to a new constant-only (code-free) package. This will make future steps more reviewable, without this movement noise. There are no code or behavior changes here. The future steps of this series can be seen in #14720: removing global funcs from syspolicy resolution and using an interface that's plumbed around instead. Then adding build tags. Updates #12614 Change-Id: If73bf2c28b9c9b1a408fe868b0b6a25b03eeabd1 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
6d45fcfc93
commit
cc532efc20
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"tailscale.com/util/set"
|
||||
"tailscale.com/util/syspolicy/internal/loggerx"
|
||||
"tailscale.com/util/syspolicy/pkey"
|
||||
"tailscale.com/util/syspolicy/setting"
|
||||
)
|
||||
|
||||
@@ -37,8 +38,8 @@ func (c PolicyChange) Old() *setting.Snapshot {
|
||||
return c.snapshots.Old
|
||||
}
|
||||
|
||||
// HasChanged reports whether a policy setting with the specified [setting.Key], has changed.
|
||||
func (c PolicyChange) HasChanged(key setting.Key) bool {
|
||||
// HasChanged reports whether a policy setting with the specified [pkey.Key], has changed.
|
||||
func (c PolicyChange) HasChanged(key pkey.Key) bool {
|
||||
new, newErr := c.snapshots.New.GetErr(key)
|
||||
old, oldErr := c.snapshots.Old.GetErr(key)
|
||||
if newErr != nil && oldErr != nil {
|
||||
@@ -60,7 +61,7 @@ func (c PolicyChange) HasChanged(key setting.Key) bool {
|
||||
}
|
||||
|
||||
// HasChangedAnyOf reports whether any of the specified policy settings has changed.
|
||||
func (c PolicyChange) HasChangedAnyOf(keys ...setting.Key) bool {
|
||||
func (c PolicyChange) HasChangedAnyOf(keys ...pkey.Key) bool {
|
||||
return slices.ContainsFunc(keys, c.HasChanged)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user