duysmile / config-env

A tool for embedding variable environment into the input file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

config-env

A tool for embedding variable content into the input file.

The tool parse input file, loads variable environment to pattern {{env "variable_env"}}, and writes to the output path.

config-env

Features

  • Load input file and replace {{env "variable_env"}} with value of variable environment variable_env

Installation

From source

Download the source code and try with:

go build -o output/config-env

Use config-env

Use from Docker

Pull the docker image from:

docker pull ghcr.io/vnteamopen/config-env:main

Quickstart:

  1. Create a file config.yml with following content:

config.yml

name: thuc
host: {{env "HOST_NAME"}}
port: {{env "PORT"}}
path: /hello

2.1. Run config-env

HOST_NAME=localhost PORT=1234 ./config-env config.yml output.yml

or

HOST_NAME=localhost PORT=1234 config-env config.yml output.yml

2.2. Run config-env with docker

docker run --rm -it -v $(pwd):/files/ -w /files -e HOST_NAME=localhost -e PORT=1234  ghcr.io/vnteamopen/config-env:main /app/config-env ./config.yml ./output.yml
  1. output.yml will be write with content
name: thuc
host: localhost
port: 1234
path: /hello

Features

  1. Overwrite template file with -w flag
config-env -w person.yml
  1. Provide both flag -w and output.yml will overwrite template file and write output file
config-env -w person.yml output.yml
  1. Provide multiple outputs
config-env person.yml output1.yml output2.yml
  1. Support output to stdout
config-env -out-screen person.yml
  1. Custom template's pattern
# change default pattern `{{env "path"}}` to `%%env "path"%%`
config-env -c %%,%% person.yml output.yml

Future

Check https://github.com/vnteamopen/config-env/issues

About

A tool for embedding variable environment into the input file.

License:MIT License


Languages

Language:Go 98.5%Language:Dockerfile 1.5%