https://github.com/pyaillet/placeholder
Minimal project used to handle placeholders in files
https://github.com/pyaillet/placeholder
Last synced: about 1 year ago
JSON representation
Minimal project used to handle placeholders in files
- Host: GitHub
- URL: https://github.com/pyaillet/placeholder
- Owner: pyaillet
- License: wtfpl
- Created: 2019-03-22T14:43:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-27T07:42:53.000Z (about 7 years ago)
- Last Synced: 2025-03-29T18:15:15.670Z (over 1 year ago)
- Language: Go
- Size: 39.1 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# placeholder
[](https://travis-ci.org/pyaillet/placeholder)
[](https://codecov.io/gh/pyaillet/placeholder)
Minimal project used to handle placeholders in files
## Description
The goal of this project is to provide a simple tool to replace placeholders
in files with values either from json, yaml, property files or from the
environment.
A placeholder is made from a prefix, a suffix and a key identifier matching
this regex: `[A-Za-z][A-Za-z0-9_]*`.
It's also possible to list keys identified in one or more files by using the
command: `placeholder -s '{{' -e '}}' list *.templates`.
When a key is identified but no corresponding value is provided the program
exits with an error.
## Usage examples
### With json
```shell
$ cat template.file
This is a simple template file containing a placeholder surrounded with
'${' and '}' which will be replaced by the value contained in a value file.
The key value is ${KEY}
```
```shell
$ cat values.json
{
"KEY": "value from json"
}
```
```shell
$ placeholder replace -i values.json template.file
```
```shell
$ cat template.file
This is a simple template file containing a placeholder surrounded with
'${' and '}' which will be replaced by the value contained in a value file.
The key value is value from json
```
### With yaml
```shell
$ cat values.yaml
KEY: value from yaml
```
```shell
$ placeholder replace -i values.yaml template.file
```
```shell
$ cat template.file
This is a simple template file containing a placeholder surrounded with
'${' and '}' which will be replaced by the value contained in a value file.
The key value is value from yaml
```
### With properties
```shell
$ cat values.properties
KEY=value from properties
```
```shell
$ placeholder replace -i values.properties template.file
```
```shell
$ cat template.file
This is a simple template file containing a placeholder surrounded with
'${' and '}' which will be replaced by the value contained in a value file.
The key value is value from properties
```
### From environment
```shell
$ KEY="value from env" placeholder replace template.file
```
```shell
$ cat template.file
This is a simple template file containing a placeholder surrounded with
'${' and '}' which will be replaced by the value contained in a value file.
The key value is value from env
```
### Bloc separator
You can also change the default bloc separator by specifying the start and end bloc with the `-s` and `-e` arguments :
```shell
$ placeholder -s '%#' -e '#%' replace -i values.json template.file
```
```shell
$ cat template.file
This is a simple template file containing a placeholder surrounded with
'%#' and '#%' which will be replaced by the value contained in a value file.
The key value is value from env
```
## Build it
To build this project, you must have make and go >= 1.12 installed.
You can then just type:
`make build`
If you don't want to install go but use docker instead, type:
`make docker-build`