Update a toml configuration file from ENV variables
This example uses a telegraf
configuration file, same works for other projects using the same configuration format
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
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
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
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