river/vm: support decoding blocks into map[string]T#3232
Merged
Conversation
1225c69 to
a760975
Compare
This allows decoding blocks into maps instead of structs. The map type
can be any map[string]T, which is useful of the map values must always
be a consistent type. If map values can be anything, use map[string]any
for decoding.
Additionally, if decoding into an interface{}, it will default to
map[string]any when decoding.
When decoding into a map, nested blocks aren't allowed and will be
rejected.
Closes grafana#2903.
rfratto
added a commit
to rfratto/agent
that referenced
this pull request
Apr 13, 2023
Add support for map[string]T blocks to river/encoding, first added in grafana#3232.
rfratto
added a commit
that referenced
this pull request
Apr 13, 2023
* river/encoding: support map[string]T blocks Add support for map[string]T blocks to river/encoding, first added in #3232. * river/encoding: address review feedback
clayton-cornell
pushed a commit
that referenced
this pull request
Aug 14, 2023
* river/encoding: support map[string]T blocks Add support for map[string]T blocks to river/encoding, first added in #3232. * river/encoding: address review feedback
clayton-cornell
pushed a commit
that referenced
this pull request
Aug 14, 2023
* river/encoding: support map[string]T blocks Add support for map[string]T blocks to river/encoding, first added in #3232. * river/encoding: address review feedback
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This allows decoding blocks into maps instead of structs. The map type can be any map[string]T, which is useful of the map values must always be a consistent type. If map values can be anything, use map[string]any for decoding.
Additionally, if decoding into an interface{}, it will default to map[string]any when decoding.
When decoding into a map, nested blocks aren't allowed and will be rejected.
Closes #2903, and unlocks module loader components to accept arguments to propagate to the module as a block rather than an object.
This is not added to the changelog because this is not a user-facing change.