mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-27 19:43:01 +00:00
all: update the tsd.System constructor name (#15372)
Replace NewSystemWithEventBus with plain NewSystem, and update all usage. See https://github.com/tailscale/tailscale/pull/15355#discussion_r2003910766 Updates #15160 Change-Id: I64d337f09576b41d9ad78eba301a74b9a9d6ebf4 Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
This commit is contained in:
parent
a268076347
commit
67fafe69ac
@ -341,7 +341,7 @@ func run() (err error) {
|
||||
|
||||
// Install an event bus as early as possible, so that it's
|
||||
// available universally when setting up everything else.
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
|
||||
// Parse config, if specified, to fail early if it's invalid.
|
||||
var conf *conffile.Config
|
||||
|
@ -327,7 +327,7 @@ func beWindowsSubprocess() bool {
|
||||
log.Printf("Error pre-loading \"%s\": %v", fqWintunPath, err)
|
||||
}
|
||||
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
netMon, err := netmon.New(log.Printf)
|
||||
if err != nil {
|
||||
log.Fatalf("Could not create netMon: %v", err)
|
||||
|
@ -100,7 +100,7 @@ func newIPN(jsConfig js.Value) map[string]any {
|
||||
logtail := logtail.NewLogger(c, log.Printf)
|
||||
logf := logtail.Logf
|
||||
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
sys.Set(store)
|
||||
dialer := &tsdial.Dialer{Logf: logf}
|
||||
eng, err := wgengine.NewUserspaceEngine(logf, wgengine.Config{
|
||||
|
@ -436,7 +436,7 @@ func (panicOnUseTransport) RoundTrip(*http.Request) (*http.Response, error) {
|
||||
}
|
||||
|
||||
func newTestLocalBackend(t testing.TB) *LocalBackend {
|
||||
return newTestLocalBackendWithSys(t, tsd.NewSystemWithEventBus())
|
||||
return newTestLocalBackendWithSys(t, tsd.NewSystem())
|
||||
}
|
||||
|
||||
// newTestLocalBackendWithSys creates a new LocalBackend with the given tsd.System.
|
||||
@ -4411,7 +4411,7 @@ func newLocalBackendWithTestControl(t *testing.T, enableLogging bool, newControl
|
||||
if enableLogging {
|
||||
logf = tstest.WhileTestRunningLogger(t)
|
||||
}
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
store := new(mem.Store)
|
||||
sys.Set(store)
|
||||
e, err := wgengine.NewFakeUserspaceEngine(logf, sys.Set, sys.HealthTracker(), sys.UserMetricsRegistry())
|
||||
@ -4859,7 +4859,7 @@ func TestConfigFileReload(t *testing.T) {
|
||||
// Create backend with initial config
|
||||
tc.initial.Path = path
|
||||
tc.initial.Raw = initialJSON
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
sys.InitialConfig = tc.initial
|
||||
b := newTestLocalBackendWithSys(t, sys)
|
||||
|
||||
|
@ -47,7 +47,7 @@ func TestLocalLogLines(t *testing.T) {
|
||||
idA := logid(0xaa)
|
||||
|
||||
// set up a LocalBackend, super bare bones. No functional data.
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
store := new(mem.Store)
|
||||
sys.Set(store)
|
||||
e, err := wgengine.NewFakeUserspaceEngine(logf, sys.Set, sys.HealthTracker(), sys.UserMetricsRegistry())
|
||||
|
@ -877,7 +877,7 @@ func newTestBackend(t *testing.T) *LocalBackend {
|
||||
logf = logger.WithPrefix(tstest.WhileTestRunningLogger(t), "... ")
|
||||
}
|
||||
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
e, err := wgengine.NewUserspaceEngine(logf, wgengine.Config{
|
||||
SetSubsystem: sys.Set,
|
||||
HealthTracker: sys.HealthTracker(),
|
||||
|
@ -295,7 +295,7 @@ func TestStateMachine(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
logf := tstest.WhileTestRunningLogger(t)
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
store := new(testStateStorage)
|
||||
sys.Set(store)
|
||||
e, err := wgengine.NewFakeUserspaceEngine(logf, sys.Set, sys.HealthTracker(), sys.UserMetricsRegistry())
|
||||
@ -934,7 +934,7 @@ func TestStateMachine(t *testing.T) {
|
||||
|
||||
func TestEditPrefsHasNoKeys(t *testing.T) {
|
||||
logf := tstest.WhileTestRunningLogger(t)
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
sys.Set(new(mem.Store))
|
||||
e, err := wgengine.NewFakeUserspaceEngine(logf, sys.Set, sys.HealthTracker(), sys.UserMetricsRegistry())
|
||||
if err != nil {
|
||||
@ -1014,7 +1014,7 @@ func TestWGEngineStatusRace(t *testing.T) {
|
||||
t.Skip("test fails")
|
||||
c := qt.New(t)
|
||||
logf := tstest.WhileTestRunningLogger(t)
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
sys.Set(new(mem.Store))
|
||||
|
||||
eng, err := wgengine.NewFakeUserspaceEngine(logf, sys.Set)
|
||||
|
@ -517,7 +517,7 @@ type newControlClientFn func(tb testing.TB, opts controlclient.Options) controlc
|
||||
func newLocalBackendWithTestControl(tb testing.TB, newControl newControlClientFn, enableLogging bool) *ipnlocal.LocalBackend {
|
||||
tb.Helper()
|
||||
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
store := &mem.Store{}
|
||||
sys.Set(store)
|
||||
|
||||
|
@ -336,7 +336,7 @@ func TestServeWatchIPNBus(t *testing.T) {
|
||||
|
||||
func newTestLocalBackend(t testing.TB) *ipnlocal.LocalBackend {
|
||||
var logf logger.Logf = logger.Discard
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
store := new(mem.Store)
|
||||
sys.Set(store)
|
||||
eng, err := wgengine.NewFakeUserspaceEngine(logf, sys.Set, sys.HealthTracker(), sys.UserMetricsRegistry())
|
||||
|
@ -1037,7 +1037,7 @@ func TestSSHAuthFlow(t *testing.T) {
|
||||
|
||||
func TestSSH(t *testing.T) {
|
||||
var logf logger.Logf = t.Logf
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
eng, err := wgengine.NewFakeUserspaceEngine(logf, sys.Set, sys.HealthTracker(), sys.UserMetricsRegistry())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -42,6 +42,10 @@ import (
|
||||
)
|
||||
|
||||
// System contains all the subsystems of a Tailscale node (tailscaled, etc.)
|
||||
//
|
||||
// A valid System value must always have a non-nil Bus populated. Callers must
|
||||
// ensure this before using the value further. Call [NewSystem] to obtain a
|
||||
// value ready to use.
|
||||
type System struct {
|
||||
Bus SubSystem[*eventbus.Bus]
|
||||
Dialer SubSystem[*tsdial.Dialer]
|
||||
@ -76,9 +80,9 @@ type System struct {
|
||||
userMetricsRegistry usermetric.Registry
|
||||
}
|
||||
|
||||
// NewSystemWithEventBus constructs a new otherwise-empty system with a
|
||||
// NewSystem constructs a new otherwise-empty [System] with a
|
||||
// freshly-constructed event bus populated.
|
||||
func NewSystemWithEventBus() *System {
|
||||
func NewSystem() *System {
|
||||
sys := new(System)
|
||||
sys.Set(eventbus.New())
|
||||
return sys
|
||||
|
@ -556,7 +556,7 @@ func (s *Server) start() (reterr error) {
|
||||
s.Logf(format, a...)
|
||||
}
|
||||
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
s.sys = sys
|
||||
if err := s.startLogger(&closePool, sys.HealthTracker(), tsLogf); err != nil {
|
||||
return err
|
||||
|
@ -46,7 +46,7 @@ func setupWGTest(b *testing.B, logf logger.Logf, traf *TrafficGen, a1, a2 netip.
|
||||
logf: logger.WithPrefix(logf, "tun1: "),
|
||||
traf: traf,
|
||||
}
|
||||
s1 := tsd.NewSystemWithEventBus()
|
||||
s1 := tsd.NewSystem()
|
||||
e1, err := wgengine.NewUserspaceEngine(l1, wgengine.Config{
|
||||
Router: router.NewFake(l1),
|
||||
NetMon: nil,
|
||||
@ -73,7 +73,7 @@ func setupWGTest(b *testing.B, logf logger.Logf, traf *TrafficGen, a1, a2 netip.
|
||||
logf: logger.WithPrefix(logf, "tun2: "),
|
||||
traf: traf,
|
||||
}
|
||||
s2 := tsd.NewSystemWithEventBus()
|
||||
s2 := tsd.NewSystem()
|
||||
e2, err := wgengine.NewUserspaceEngine(l2, wgengine.Config{
|
||||
Router: router.NewFake(l2),
|
||||
NetMon: nil,
|
||||
|
@ -44,7 +44,7 @@ func TestInjectInboundLeak(t *testing.T) {
|
||||
t.Logf(format, args...)
|
||||
}
|
||||
}
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
eng, err := wgengine.NewUserspaceEngine(logf, wgengine.Config{
|
||||
Tun: tunDev,
|
||||
Dialer: dialer,
|
||||
@ -100,7 +100,7 @@ func getMemStats() (ms runtime.MemStats) {
|
||||
|
||||
func makeNetstack(tb testing.TB, config func(*Impl)) *Impl {
|
||||
tunDev := tstun.NewFake()
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
sys.Set(new(mem.Store))
|
||||
dialer := new(tsdial.Dialer)
|
||||
logf := tstest.WhileTestRunningLogger(tb)
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func TestIsNetstack(t *testing.T) {
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
e, err := wgengine.NewUserspaceEngine(
|
||||
tstest.WhileTestRunningLogger(t),
|
||||
wgengine.Config{
|
||||
@ -66,7 +66,7 @@ func TestIsNetstackRouter(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
sys := tsd.NewSystemWithEventBus()
|
||||
sys := tsd.NewSystem()
|
||||
if tt.setNetstackRouter {
|
||||
sys.NetstackRouter.Set(true)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user