ipn/ipnlocal: simplify a test with a new simpler syspolicy client test type
Less indirection. Updates #16998 Updates #12614 Change-Id: I5a3a3c3f3b195486b2731ec002d2532337b3d211 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
1ca4ae598a
commit
0d23490e1a
@@ -59,6 +59,7 @@ type System struct {
|
||||
Netstack SubSystem[NetstackImpl] // actually a *netstack.Impl
|
||||
DriveForLocal SubSystem[drive.FileSystemForLocal]
|
||||
DriveForRemote SubSystem[drive.FileSystemForRemote]
|
||||
PolicyClient SubSystem[policyclient.Client]
|
||||
|
||||
// InitialConfig is initial server config, if any.
|
||||
// It is nil if the node is not in declarative mode.
|
||||
@@ -127,6 +128,8 @@ func (s *System) Set(v any) {
|
||||
s.DriveForLocal.Set(v)
|
||||
case drive.FileSystemForRemote:
|
||||
s.DriveForRemote.Set(v)
|
||||
case policyclient.Client:
|
||||
s.PolicyClient.Set(v)
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown type %T", v))
|
||||
}
|
||||
@@ -169,6 +172,9 @@ func (s *System) UserMetricsRegistry() *usermetric.Registry {
|
||||
// PolicyClientOrDefault returns the policy client if set or a no-op default
|
||||
// otherwise. It always returns a non-nil value.
|
||||
func (s *System) PolicyClientOrDefault() policyclient.Client {
|
||||
if client, ok := s.PolicyClient.GetOK(); ok {
|
||||
return client
|
||||
}
|
||||
return getPolicyClient()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user