Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TektonOps/subvars
Substitute environment variables from command line for template driven configuration files.
https://github.com/TektonOps/subvars
cli configuration docker environment-variables golang gotemplate linux macos template windows
Last synced: about 2 months ago
JSON representation
Substitute environment variables from command line for template driven configuration files.
- Host: GitHub
- URL: https://github.com/TektonOps/subvars
- Owner: TektonOps
- License: mit
- Created: 2021-07-06T16:12:01.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-12-24T00:58:27.000Z (12 months ago)
- Last Synced: 2024-09-07T03:48:40.629Z (3 months ago)
- Topics: cli, configuration, docker, environment-variables, golang, gotemplate, linux, macos, template, windows
- Language: Go
- Homepage: https://subvars.lmno.pk
- Size: 603 KB
- Stars: 21
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- jimsghstars - TektonOps/subvars - Substitute environment variables from command line for template driven configuration files. (Go)
README
Documentation •
Installation •
Configuration •
Contributing •
Show Your Support---
## About
Substitute Variables (subvars) is a small utility which provides a way to render any [Go templates](https://golang.org/pkg/text/template/)
from command line recognizing the object being passed in and drawing attributes from the object to create wanted text.
It is very useful for template driven configuration files.It uses [sprig v3](https://github.com/Masterminds/sprig) for [template functions](https://masterminds.github.io/sprig)
which provides additional functions apart from standard library.`subvars` reads input from `stdin` and renders output to `stdout`.
You can pipe the input or `<` direct it to subvars.Options to [render all files](https://subvars.lmno.pk/03-usage-examples/) in a given folder
and output to another folder preserving folder and file structure is available via `dir` subcommand.## Installation
### MacOS & Linux Homebrew
```bash
brew install kha7iq/tap/subvars
```### Linux
* AUR
```bash
yay -S subvars
```* Binary
```bash
export SUBVARS_VERSION="0.1.5"
wget -q https://github.com/kha7iq/subvars/releases/download/v${SUBVARS_VERSION}/subvars_Linux_x86_64.tar.gz && \
tar -xf subvars_Linux_x86_64.tar.gz && \
chmod +x subvars && \
sudo mv subvars /usr/local/bin/subvars
```### Windows
```powershell
scoop bucket add subvars https://github.com/kha7iq/scoop-bucket.git
scoop install subvars
```Alternatively you can head over to [release pages](https://github.com/kha7iq/subvars/releases)
and download the binary for windows & all other supported platforms.### Docker
Docker container is available you can pull the `latest` version or provide specific `tag`
Checkout [release](https://github.com/kha7iq/subvars/releases) page for available versions.Running Container
```bash
docker pull khaliq/subvars:latestdocker run -it --rm khaliq/subvars:latest --help
```## Usage
```bash
❯ subvars --helpNAME:
subvars - Substitute environment variables defined as go templates.USAGE:
subvars [global options] command [command options] [arguments...]VERSION:
0.1.2COMMANDS:
dir, d Directory lets you render all files in a folder & subfolder.
help, h Shows a list of commands or help for one commandGLOBAL OPTIONS:
--prefix value, --pr value Match only variables with given prefix pattern [$SUBVARS_PREFIX]
--missingkey value, -m value Behavior for missing key when parsing variables. Available options 'invalid', 'error' or 'zero' (default: "invalid") [$SUBVARS_MISSINGKEY]
--help, -h show help (default: false)
--version, -v print the version (default: false)
``````bash
echo "Hey! {{ .USER | upper }} your home folder is {{ .HOME }}" | subvars
``````bash
subvars dir --input examples --out conf
```Check [Usage Documentation](https://subvars.lmno.pk/03-usage-examples/) for detailed examples.
## Configuration
All the flags have corresponding environment variables associated with it. You
can either provide the value with flags or export to a variable.View the [Configuration Page](https://subvars.lmno.pk/02-configuration/) for more
details.## Contributing
Contributions, issues and feature requests are most welcome!
Feel free to check
[issues page](https://github.com/kha7iq/subvars/issues). You can also take a look
at the [contributing guide](https://github.com/kha7iq/subvars/blob/master/CONTRIBUTING.md).## Show your support
Give a ⭐️ if you like this project!
Fork it ⚙️
Make it better 🕶️
## Acknowledgments
This tool was inspired by the original [python envtpl](https://github.com/andreasjansson/envtpl)
project and [subfuzion](https://github.com/subfuzion/envtpl/)