Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for binding nested collections of structs ([]T and map[string]T where T is a struct) from YAML-decoded configuration values. It enables common configuration patterns like multiple database connections or service endpoints to be defined as slices or maps of structured configuration objects.
Changes:
- Enhanced
convertValuein binding.go to recursively handle slices and maps with struct element/value types - Added helper functions
convertCollectionElementandconvertStructValueto properly bind struct instances within collections - Added comprehensive test coverage in loader_test.go for successful binding and error cases
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| loader_test.go | Adds TestLoad_NestedCollections with subtests for binding slices/maps of structs and validating type conversion errors |
| binding.go | Extends convertValue to handle slices/maps of any type including structs, adds convertCollectionElement and convertStructValue helpers for recursive binding |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
asadijabar
approved these changes
Feb 23, 2026
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
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.
What
Add partial nested collection binding support for struct elements/values in the existing load/bind flow:
[]TwhereTis a struct from YAML-decoded collection values (for example,[]anycontaining nested objects).map[string]TwhereTis a struct when the source provides a direct nested map value (for example, in-memory/custom sources returningmap[string]anyvalues).invalid_type) for nested collections.This PR does not yet support binding
map[string]Tfrom flattened dotted keys (for example,clickhouse_map.primary.host) produced by the built-in file source, and does not include strict-mode dynamic nested-key validation for that shape.Docs: N/A — this change does not alter public APIs, config tags/defaults, examples, or setup/onboarding flow.
Why
Rigging already supports nested struct binding, but nested collections of structs (
[]T,map[string]T) were not handled in the binder for direct collection values. This PR delivers a minimal, low-risk improvement while keeping scope small.Type
Partially addresses #33