Implement proper YAML path navigation and complex type support

- YAML resolver now supports full path navigation (e.g., production.primary.host)
- Both JSON and YAML resolvers return YAML-formatted data for complex types
- This allows proper type preservation when loading objects/arrays from files
- Updated convertToType to parse YAML returned by resolvers
- Added comprehensive tests for YAML path navigation including arrays
- Fixed JSON resolver to support "." path for entire document
- All README examples now work correctly

The key insight was that resolvers should return YAML strings for complex
types, which can then be parsed and merged into the configuration structure,
preserving the original types (maps, arrays) instead of flattening to strings.
This commit is contained in:
sneak committed 2025-07-21 18:57:13 +02:00
1 parent e7fa389634
commit 6b8c16dd1d
8 files changed
+575 -11

No files matched your search

+2 -2
View File
@@ -14,8 +14,8 @@ api:
tls_host: ${JSON:./test/hosts.json:tls_sni_host.0}
database:
host: ${YAML:./test/data.yaml:'.database.host'}
version: ${YAML:./test/data.yaml:'.version'}
host: ${YAML:./test/data.yaml:database.host}
version: ${YAML:./test/data.yaml:version}
nested:
value: ${ENV:NESTED_${ENV:TEST_ENV_SUFFIX}}
+20
View File
@@ -0,0 +1,20 @@
production:
primary:
host: prod-db-primary.example.com
port: 5432
username: prod_user
replica:
host: prod-db-replica.example.com
port: 5432
staging:
primary:
host: staging-db.example.com
port: 5432
username: staging_user
development:
primary:
host: localhost
port: 5432
username: dev_user
+15
View File
@@ -0,0 +1,15 @@
features:
analytics:
enabled: true
provider: google
tracking_id: UA-123456
new_ui:
enabled: false
rollout_percentage: 25
rate_limiting:
enabled: true
requests_per_minute: 100
settings:
debug: false
log_level: info