Skip to content
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

[pkg/ottl]: add SliceToMap function #35412

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

bacherfl
Copy link
Contributor

@bacherfl bacherfl commented Sep 25, 2024

Description: This PR adds a function that converts slices to maps, as described in the linked issue. Currently still WIP, but creating a draft PR already to show how this could be implemented and used

Link to tracking Issue: #35256

Testing: Added unit and end to end tests

Documentation: Added description for the new function in the readme file

@bacherfl bacherfl changed the title [pkg/ottl]: add Associate function [pkg/ottl]: add SliceToMap function Sep 27, 2024
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
@@ -84,12 +94,29 @@ func Test_e2e_editors(t *testing.T) {
m.PutStr("test.foo.flags", "pass")
m.PutStr("test.foo.slice.0", "val")
m.PutStr("test.foo.nested.test", "pass")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@evan-bradley @TylerHelmuth - This is not related to the function implemented in this PR, but after adding a slice of nested objects to the test attributes I found that the flatten function seems to not flatten the attributes of nested objects within a slice, but rather leaves the objects within the slice unchanged - is this intended or is this a bug in that function?

Also, when setting the depth to 0 (as in the test case below), slices at the top level of the input of the flatten function will still be flattened.

Please let me know if this behavior is intended or if this may be a bug - If it's the latter, I can create an issue for that and work on a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant