Add JSON5 support, --json CLI flag, typed getters, and improve YAML quoting

- Updated JSON resolver to use gjson library for JSON5 support (comments, trailing commas)
- Added --json flag to CLI tool for JSON output format
- Added typed getter methods: GetInt(), GetUint(), GetFloat(), GetBool(), GetBytes()
- GetBytes() supports human-readable formats like "10G", "20KiB" via go-humanize
- Fixed YAML interpolation to always quote output values for safety
- Updated README to clarify YAML-only input and automatic quoting behavior
- Added .gitignore to exclude compiled binary
- Fixed test config files to use unquoted interpolation syntax
- Updated tests to expect quoted interpolation output
This commit is contained in:
2025-07-21 12:13:14 +02:00
parent 8a38afba5e
commit 3c3732f033
10 changed files with 418 additions and 63 deletions

View File

@@ -6,20 +6,20 @@ server:
hostname: ${EXEC:hostname}
machine:
id: "${FILE:./test/machine-id}"
cores: "${EXEC:echo 4}"
id: ${FILE:./test/machine-id}
cores: ${EXEC:echo 4}
api:
endpoint: "${JSON:./test/hosts.json:'.api_endpoints.primary'}"
tls_host: "${JSON:./test/hosts.json:'.tls_sni_host[0]'}"
endpoint: ${JSON:./test/hosts.json:api_endpoints.primary}
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}}"
value: ${ENV:NESTED_${ENV:TEST_ENV_SUFFIX}}
env:
INJECTED_VAR: "injected-value"
COMPUTED_VAR: "${EXEC:echo computed}"
COMPUTED_VAR: ${EXEC:echo computed}