-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow transform_generic to keep existing fields #156
Conversation
Codecov Report
@@ Coverage Diff @@
## main #156 +/- ##
==========================================
+ Coverage 58.47% 58.95% +0.47%
==========================================
Files 51 54 +3
Lines 2950 3055 +105
==========================================
+ Hits 1725 1801 +76
- Misses 1113 1134 +21
- Partials 112 120 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
e5f96a5
to
f625bf7
Compare
The default is now to include all previous key/values and to enrich them. To get only the newly specified keys, we now have |
addresses issue #151 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KalmanMeth looks good to me. You need to also update https://github.com/netobserv/flowlogs-pipeline/blob/main/pkg/confgen/flowlogs2metrics_config.go#L70 to reflect the new policy
field
To include the original keys and values in addition to those specified in the `rules`, | ||
specify `policy: preserve_original_keys`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if an original key conflicts with a key specified in rules
? (i.e. they have the same name)
Is it an error? does the original key prevail? or the new key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new key overwrites the old value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think its worth noting in the docs?
output := make([]config.GenericMap, 0) | ||
for _, entry := range input { | ||
outputEntry := make(config.GenericMap) | ||
for _, transformRule := range g.Rules { | ||
outputEntry := entry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if g.policy != "replace_keys"
then this code is modifying the input slice. This might be a problem if the same slice is passed to a parallel transform stage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Copied map entries individually.
outputEntry := make(config.GenericMap) | ||
for _, transformRule := range g.Rules { | ||
outputEntry := entry | ||
if g.policy == "replace_keys" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to panic on an invalid policy value? I mean, if the user writes replace-keys
with a dash instead of an underline, we will treat it as preserve_original_keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added panic for illegal policy
e4d9ee4
to
7c80873
Compare
Addresses issue #151