https://github.com/ironcore864/yaml-config-env-interpolation
https://github.com/ironcore864/yaml-config-env-interpolation
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ironcore864/yaml-config-env-interpolation
- Owner: IronCore864
- Created: 2024-08-05T04:56:51.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-06T03:56:24.000Z (almost 2 years ago)
- Last Synced: 2025-06-08T00:46:20.918Z (about 1 year ago)
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `$VAR` Style Interpolation in YAML Used as Configurations
A simple PoC.
This Go program reads environment definitions from a YAML file, resolves environment variables with support for interpolation, and manages dependencies between variables. As a PoC, the program will render and print the final environment key-value pairs.
## Features
- Supports the interpolation of environment variables in the format `${var}` or `$var`.
- Resolves values from the current environment variables if referenced.
- Handles dependencies between variables to ensure correct rendering order.
- Supports escaping the `$` character using `$$` to include a literal `$` in the result.
## Notes
- Circular dependencies result in an error.
- To include a literal `$` in the result value, escape it using `$$` in the input value. Maybe this feature should be removed because it's not usual to pass in a literal `$` as env var.
## Sample Usages
File `environment1.yaml`:
```yaml
environment:
THINGDIR: "/home/${USER}/thing"
CMD_DIR: "/root/sleepy"
CMD_SOCKET: "$CMD_DIR/.sock"
```
Expected Output:
```bash
CMD_DIR=/root/sleepy
CMD_SOCKET=/root/sleepy/.sock
THINGDIR=/home/tiexin/thing
```