FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore(go.d/pkg/logs): make CSVConfig.CheckField unexported by ilyam8 · Pull Request #21525 · netdata/netdata · GitHub

chore(go.d/pkg/logs): make CSVConfig.CheckField unexported - #21525

Closed
ilyam8 wants to merge 1 commit into
netdata:masterfrom
ilyam8:fix-go.d-csvconfig-checkfield
Closed

chore(go.d/pkg/logs): make CSVConfig.CheckField unexported#21525
ilyam8 wants to merge 1 commit into
netdata:masterfrom
ilyam8:fix-go.d-csvconfig-checkfield

Conversation

ilyam8 commented Jan 8, 2026
edited by cubic-dev-ai Bot
Loading

Copy link
Copy Markdown
Member

The CSVConfig struct was always being marshaled as csv_config: {} in YAML output, even when all configuration fields were empty. This prevented the omitempty tag on the parent ParserConfig.CSV field from working correctly.

The issue was caused by the exported CheckField function field, which cannot be marshaled to YAML but still prevented the struct from being considered "empty" for omitempty purposes.

Summary
Test Plan
Additional Information
For users: How does this change affect me?

Summary by cubic

Fix YAML marshaling of CSVConfig so empty configs are omitted from output. Made the function field internal and added a setter to keep it out of serialization.

  • Bug Fixes
    • Unexported CheckField and added CSVConfig.SetCheckField to store the runtime-only function without affecting YAML.
    • Updated squidlog and weblog collectors and tests to use the setter. ParserConfig.CSV now respects omitempty and skips csv_config when empty.

Written for commit e7ed7a2. Summary will update on new commits.

cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No issues found across 6 files

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This PR refactors the CSVConfig struct by making its CheckField field unexported (renamed to checkField) and introducing a SetCheckField setter method. This change allows the omitempty YAML tag on the parent ParserConfig.CSV field to work correctly, preventing empty csv_config: {} from appearing in YAML output when all configuration fields are empty.

Key Changes:

  • Made CSVConfig.CheckField unexported (checkField)
  • Added SetCheckField() setter method for external configuration
  • Updated all usages across test files and collectors to use the setter method

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/go/plugin/go.d/pkg/logs/csv.go Renamed CheckField to checkField and added SetCheckField setter method
src/go/plugin/go.d/pkg/logs/csv_test.go Updated test to directly assign to unexported checkField
src/go/plugin/go.d/collector/weblog/collector.go Refactored to use SetCheckField after struct initialization
src/go/plugin/go.d/collector/weblog/parser_test.go Updated test to use SetCheckField method
src/go/plugin/go.d/collector/weblog/collector_test.go Updated multiple test functions to use SetCheckField method
src/go/plugin/go.d/collector/squidlog/collector.go Refactored to use SetCheckField after struct initialization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ilyam8 commented Jan 8, 2026

Copy link
Copy Markdown
Member Author

Closing in favour of #21526

ilyam8 closed this Jan 8, 2026
ilyam8 deleted the fix-go.d-csvconfig-checkfield branch January 8, 2026 21:34
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

Labels

area/collectors Everything related to data collection area/go collectors/go.d

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL