What happened?
The ListPlugins function in backend/pkg/plugins/plugins.go uses 9 raw fmt.Printf / fmt.Println calls to write plugin loading status directly to os.Stdout. Every other file in the backend (helm/, kubeconfig/, etc.) uses Headlamp's structured logger (logger.Log), making plugins.go the only file that bypasses it.
This causes two problems:
- No structured output - Plugin listing output is unstructured plaintext, which cannot be filtered, parsed, or ingested by log aggregation tools (e.g., in Kubernetes pod logs).
- Brittle test - The TestListPlugins unit test uses an
os.Pipe hack (captureOutput) to hijack os.Stdout and parse the plaintext. This technique is fragile, not goroutine-safe, and is the only test in the entire backend that does this.
What did you expect to happen?
ListPlugins should use logger.Log(logger.LevelInfo, ...) with structured key-value metadata (plugin name, type, directory), consistent with the rest of the backend. The test should assert function correctness (no error returned) instead of parsing stdout.
Affected file(s)
- backend/pkg/plugins/plugins.go - ListPlugins function (lines 270–332)
- backend/pkg/plugins/plugins_test.go -
captureOutput helper and TestListPlugins
What happened?
The ListPlugins function in backend/pkg/plugins/plugins.go uses 9 raw
fmt.Printf/fmt.Printlncalls to write plugin loading status directly toos.Stdout. Every other file in the backend (helm/,kubeconfig/, etc.) uses Headlamp's structured logger (logger.Log), making plugins.go the only file that bypasses it.This causes two problems:
os.Pipehack (captureOutput) to hijackos.Stdoutand parse the plaintext. This technique is fragile, not goroutine-safe, and is the only test in the entire backend that does this.What did you expect to happen?
ListPlugins should use
logger.Log(logger.LevelInfo, ...)with structured key-value metadata (plugin name, type, directory), consistent with the rest of the backend. The test should assert function correctness (no error returned) instead of parsing stdout.Affected file(s)
captureOutputhelper and TestListPlugins