util/syspolicy: finish plumbing policyclient, add feature/syspolicy, move global impl
This is step 4 of making syspolicy a build-time feature. This adds a policyclient.Get() accessor to return the correct implementation to use: either the real one, or the no-op one. (A third type, a static one for testing, also exists, so in general a policyclient.Client should be plumbed around and not always fetched via policyclient.Get whenever possible, especially if tests need to use alternate syspolicy) Updates #16998 Updates #12614 Change-Id: Iaf19670744a596d5918acfa744f5db4564272978 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
9e9bf13063
commit
2b3e533048
@@ -51,8 +51,8 @@ import (
|
||||
"tailscale.com/util/clientmetric"
|
||||
"tailscale.com/util/must"
|
||||
"tailscale.com/util/racebuild"
|
||||
"tailscale.com/util/syspolicy"
|
||||
"tailscale.com/util/syspolicy/pkey"
|
||||
"tailscale.com/util/syspolicy/policyclient"
|
||||
"tailscale.com/util/testenv"
|
||||
"tailscale.com/version"
|
||||
"tailscale.com/version/distro"
|
||||
@@ -66,7 +66,7 @@ var getLogTargetOnce struct {
|
||||
func getLogTarget() string {
|
||||
getLogTargetOnce.Do(func() {
|
||||
envTarget, _ := os.LookupEnv("TS_LOG_TARGET")
|
||||
getLogTargetOnce.v, _ = syspolicy.GetString(pkey.LogTarget, envTarget)
|
||||
getLogTargetOnce.v, _ = policyclient.Get().GetString(pkey.LogTarget, envTarget)
|
||||
})
|
||||
|
||||
return getLogTargetOnce.v
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_syspolicy
|
||||
|
||||
package logpolicy
|
||||
|
||||
import _ "tailscale.com/feature/syspolicy"
|
||||
Reference in New Issue
Block a user