Skip to content

plugins: ListPlugins uses fmt.Println instead of structured logger #5069

@NAME-ASHWANIYADAV

Description

@NAME-ASHWANIYADAV

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:

  1. 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).
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendIssues related to the backenddxkind/bugCategorizes issue or PR as related to a bug.plugins

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions