fix(go.d/pkg/logs): fix ParserConfig.CSV omitempty behavior #21526
+9
−5
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
Problem:
The
CSVConfigstruct was always being marshaled ascsv_config: {}in YAML output, even when all configuration fields were empty. This prevented theomitemptytag on the parentParserConfig.CSVfield from working correctly.Solution:
Created a custom
CSVCheckFieldFunctype that implements theIsZeroerinterface from the yaml package. By havingIsZero()always returntrue, the function field is treated as empty foromitemptyevaluation purposes.Test Plan
Additional Information
For users: How does this change affect me?
Summary by cubic
Fixed CSVConfig YAML omitempty so empty config no longer outputs csv_config: {}. Added CSVCheckFieldFunc with IsZero() to mark CheckField as empty during omitempty evaluation.
Written for commit 7210c07. Summary will update on new commits.