Skip to content

backend/plugins: use structured logging in ListPlugins#5072

Open
NAME-ASHWANIYADAV wants to merge 1 commit intokubernetes-sigs:mainfrom
NAME-ASHWANIYADAV:refactor/plugins-structured-logging
Open

backend/plugins: use structured logging in ListPlugins#5072
NAME-ASHWANIYADAV wants to merge 1 commit intokubernetes-sigs:mainfrom
NAME-ASHWANIYADAV:refactor/plugins-structured-logging

Conversation

@NAME-ASHWANIYADAV
Copy link
Copy Markdown
Contributor

Fixes #5069

What this PR does

Refactors ListPlugins to replace raw fmt.Printf / fmt.Println calls with Headlamp's structured logger.Log, and removes the brittle os.Pipe stdout-capture technique from the test.

Changes

File Change
backend/pkg/plugins/plugins.go Replace 9 fmt.Printf/fmt.Println calls with logger.Log(logger.LevelInfo, ...) using structured key-value maps (plugin, type, directory)
backend/pkg/plugins/plugins_test.go Delete captureOutput (os.Pipe hack), add t.Helper() to createPlugin, rewrite TestListPlugins to assert no-error directly

Why

  • plugins.go was the only file in the entire backend still using fmt.Println for output - every other package uses the structured logger.
  • The captureOutput test helper hijacked os.Stdout via os.Pipe, which is fragile and not goroutine-safe.
  • Structured logs enable proper filtering and ingestion in Kubernetes pod log pipelines.

Testing

  • go vet ./pkg/plugins/... - Clean
  • go fmt ./pkg/plugins/... - No changes
  • go test ./pkg/plugins/... -v - All tests pass

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 7, 2026
@NAME-ASHWANIYADAV
Copy link
Copy Markdown
Contributor Author

/assign @sniok

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV force-pushed the refactor/plugins-structured-logging branch from a6a62c8 to af1a4d1 Compare April 7, 2026 06:10
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: NAME-ASHWANIYADAV
Once this PR has been reviewed and has the lgtm label, please ask for approval from sniok. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 7, 2026
@sniok sniok removed their assignment Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugins: ListPlugins uses fmt.Println instead of structured logger

3 participants