https://github.com/drpsychick/toml_update
Update a toml configuration file from ENV variables
https://github.com/drpsychick/toml_update
12-factor go golang toml toml-config
Last synced: 11 months ago
JSON representation
Update a toml configuration file from ENV variables
- Host: GitHub
- URL: https://github.com/drpsychick/toml_update
- Owner: DrPsychick
- License: gpl-3.0
- Created: 2021-05-13T09:45:32.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-05-04T18:49:10.000Z (about 1 year ago)
- Last Synced: 2025-05-04T19:35:36.099Z (about 1 year ago)
- Topics: 12-factor, go, golang, toml, toml-config
- Language: Go
- Homepage:
- Size: 59.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://app.circleci.com/pipelines/github/DrPsychick/toml_update)
[](https://coveralls.io/github/DrPsychick/toml_update?branch=master)
[](https://github.com/drpsychick/toml_update/blob/master/LICENSE)
[](https://github.com/drpsychick/toml_update)
[](https://github.com/drpsychick/toml_update/graphs/contributors)
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FTXDN7LCDWUEA&source=url)
[](https://github.com/sponsors/DrPsychick)
[](https://github.com/drpsychick/toml_update/issues)
[](https://github.com/drpsychick/toml_update/issues?q=is%3Aissue+is%3Aclosed)
[](https://github.com/drpsychick/toml_update/pulls)
[](https://github.com/drpsychick/toml_update/pulls?q=is%3Apr+is%3Aclosed)
# toml_update
Update a toml configuration file from ENV variables
## Example
This example uses a `telegraf` configuration file, same works for other projects using the same configuration format
```shell
docker run --rm telegraf telegraf config > test.conf
export CONF_UPDATE=test.conf
export CONF_PREFIX=PFX
export PFX_myvar1=inputs.cpu.totalcpu=false
export PFX_whatever2=agent.interval="20s"
export PFX_ping_urls=inputs.ping.urls=["google.com","amazon.com"]
export PFX_emptysection=inputs.netstat.enabled=#no configuration
grep -e 'totalcpu' -e '^[^#]*interval = ' test.conf
# if you've cloned the repo, simply run `go build toml_update.go` to get the binary
./toml_update
grep -e 'totalcpu' -e '^[^#]*interval = ' test.conf
```
## Built and released with [goreleaser](https://goreleaser.com)
### Setup
```shell
docker run --rm --privileged \
-v $PWD:/go/src/github.com/drpsychick/toml_update \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/drpsychick/toml_update \
goreleaser/goreleaser init
go mod init github.com/drpsychick/toml_update
```
### Test
```shell
docker run --rm --privileged \
-v $PWD:/go/src/github.com/drpsychick/toml_update \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/drpsychick/toml_update \
goreleaser/goreleaser --snapshot --skip=publish --clean
```
### Release
```shell
git tag -a v0.0.8 -m "Reviewed"
git push origin v0.0.8
docker run --rm --privileged \
-v $PWD:/go/src/github.com/drpsychick/toml_update \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/drpsychick/toml_update \
-e GITHUB_TOKEN=XXX \
goreleaser/goreleaser release --clean
```