Repository navigation
refactor(spored): extract OS-specific surface behind build tags (#77 stage 1) - #84
Merged
Merged
Conversation
…stage 1)
Foundation for Windows spored: spored's only platform-dependent operations
(idle/metrics data sources, user-notify, pre-stop shell, log path) are split
into build-tagged files so the agent core stays OS-agnostic. This is a no-op on
Linux — the existing /proc readers and wall/who/pgrep/last execs move verbatim
into pkg/agent/sys_linux.go behind //go:build linux.
- pkg/agent/sys_{linux,windows,other}.go: leaf functions sysReadCPUTimes,
sysReadNetworkBytes, sysReadDiskIOBytes, sysIsProcessRunning,
sysCountActiveSessions, sysCountActivePortConnections, sysHasActiveTerminals,
sysHasRecentUserActivity, sysWarnUsers, sysShellCommand. Linux = real impls;
windows = conservative stubs (Stage 2 fills in WMI/perf-counter sources) +
msg.exe / powershell shims; other(darwin) = stubs that never report idle so
dev builds compile and `make check` stays green.
- agent.go now calls those leaves; warning/spot-notification files use
os.TempDir() instead of hardcoded /tmp.
- cmd/spored log path is platform-specific (/var/log on Unix, %PROGRAMDATA% on
Windows) via paths_{windows,other}.go.
GOOS=linux, GOOS=windows, and host (darwin) all `go build ./...` clean;
agent tests + make check pass on Linux/darwin (behavior unchanged). Windows
idle/metrics bodies are intentionally stubbed here — real implementations land
in Stage 2.
Refs #77.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 1 of Windows spored (#77): a no-op-on-Linux refactor that isolates spored's platform-dependent operations behind build tags, so the agent core becomes OS-agnostic and a Windows build can compile. Landed separately to make any Linux regression easy to spot before the Windows implementation arrives.
What moved
pkg/agent/sys_{linux,windows,other}.go— leaf functions for the OS surface: CPU times, network/disk bytes, process check, active sessions, port connections, active terminals, recent-user-activity, user-notify, and the pre-stop shell invocation./procreaders +w/who/pgrep/last/wallexecs, moved verbatim (//go:build linux).msg.exe/powershellshims (Stage 2 fills in the real WMI/perf-counter sources).make checkstays green on a dev Mac.agent.gocalls those leaves; warning + spot-notification files now useos.TempDir()instead of hardcoded/tmp.cmd/sporedlog path is platform-specific (/var/logUnix,%PROGRAMDATA%\sporedWindows).Verification
GOOS=linux,GOOS=windows GOARCH=amd64, and host (darwin) allgo build ./...clean.make checkpass on Linux/darwin — behavior unchanged (Linux code is byte-for-byte the same, just relocated).Refs #77. First of a staged series (Stage 2: WMI idle/metrics; Stage 3: Windows Service; Stage 4: installer + GoReleaser + launch wiring).