Description
Substitute Variables (subvars) is a utility which provides a way to render any Go templates 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 for template functions which provides additional functions apart from standard library.
subVars alternatives and similar packages
Based on the "Configuration" category.
Alternatively, view subvars alternatives based on common mentions on social networks and blogs.
-
kelseyhightower/envconfig
Golang library for managing configuration data from environment variables -
env
A simple and zero-dependencies library to parse environment variables into structs -
koanf
Simple, extremely lightweight, extensible, configuration management library for Go. Support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper. -
cleanenv
✨Clean and minimalistic environment configuration reader for Golang -
konfig
Composable, observable and performant config handling for Go for the distributed processing era -
confita
Load configuration in cascade from multiple backends into a struct -
gookit/config
📝 Go configuration manage(load,get,set,export). support JSON, YAML, TOML, Properties, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名 -
GoLobby/Config
A lightweight yet powerful configuration manager for the Go programming language -
envconfig
Small library to read your configuration from environment variables -
gcfg
read INI-style configuration files into Go structs; supports user-defined types and subsections -
goConfig
goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file. -
joshbetz/config
🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP. -
configuro
An opinionated configuration loading framework for Containerized and Cloud-Native applications. -
configuration
Library for setting values to structs' fields from env, flags, files or default tag -
hocon
go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config -
configure
Configure is a Go package that gives you easy configuration of your project through redundancy -
uConfig
Lightweight, zero-dependency, and extendable configuration management library for Go -
go-up
go-up! A simple configuration library with recursive placeholders resolution and no magic. -
CONFLATE
Library providing routines to merge and validate JSON, YAML and/or TOML files -
go-ssm-config
Go utility for loading configuration parameters from AWS SSM (Parameter Store) -
Genv
Genv is a library for Go (golang) that makes it easy to read and use environment variables in your projects. It also allows environment variables to be loaded from the .env file. -
swap
Instantiate/configure structs recursively, based on build environment. (YAML, TOML, JSON and env).
Tired of breaking your main and manually rebasing outdated pull requests?
Do you think we are missing an alternative of subVars or a related project?
Popular Comparisons
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 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 for template functions 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 in a given folder
and output to another folder is available via dir
subcommand.
Installation
MacOS & Linux Homebrew
brew install kha7iq/tap/subvars
Linux Binary
export SUBVARS_VERSION="0.1.2"
wget -q https://github.com/kha7iq/subvars/releases/download/v${SUBVARS_VERSION}/subvars_Darwin_x86_64.tar.gz && \
tar -xf subvars_Darwin_x86_64.tar.gz && \
chmod +x subvars && \
sudo mv subvars /usr/local/bin/subvars
Windows
scoop bucket add subvars https://github.com/kha7iq/scoop-bucket.git
scoop install subvars
Alternatively you can head over to release pages 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 page for available versions.
Running Container
docker pull khaliq/subvars:latest
docker run -it --rm khaliq/subvars:latest --help
Usage
❯ subvars --help
NAME:
subvars - Substitute environment variables defined as go templates.
USAGE:
subvars [global options] command [command options] [arguments...]
VERSION:
0.1.2
COMMANDS:
dir, d Directory lets you render all files in a folder & subfolder.
help, h Shows a list of commands or help for one command
GLOBAL 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)
echo "Hey! {{ .USER | upper }} your home folder is {{ .HOME }}" | subvars
subvars dir --input examples --out conf
Check Usage Documentation 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 for more details.
Contributing
Contributions, issues and feature requests are most welcome!Feel free to check issues page. You can also take a look at the contributing guide.
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 project and subfuzion/envtpl
*Note that all licence references and agreements mentioned in the subVars README section above
are relevant to that project's source code only.