A fast Spring cloud-config-client written in Go.
It fetches properties from a Spring cloud-config-server and make them available via system environment variables For more information on spring cloud config take a look here.
You can get the latest binary using Go:
> go get -u github.com/jamowei/senv/senv
or download released binary from here.
Your spring config server is running on http://127.0.0.1:8888/.
your application.yml file in config repo is:
# general
description: Spring Config Server
user: admin
workdir: /var/work
---
# test environment
spring:
profiles:
active: dev
db:
user: ${user}
password: test123
---
# production environment
spring:
profiles:
active: prod
db:
user: ${user}
password: prod123
your own application file myapp.yml in config repo:
file:
input: ${workdir}/input.txt
output: ${workdir}/output.txt
and you have a static file "conf.xml" with variables:
<configuration>
<user>${db.user}</user>
<pass>${db.password}</pass>
</configuration>
then you can start your application myapp like the following:
- with development settings:
> senv env -n myapp -p dev \n Fetching config from server at: http://127.0.0.1:8888/myapp/dev/master Located environment: name="myapp", profiles=[dev], label="master", version=29374923859338549, state="" > echo "$DB_USER:$DB_PASSWORD" // prints: admin:test123 > myapp -user $DB_USER -pass $DB_PASSWORD -in $FILE_INPUT -out $FILE_OUTPUT ...
- with production settings:
> senv env -n myapp -p prod \n Fetching config from server at: http://127.0.0.1:8888/myapp/prod/master Located environment: name="myapp", profiles=[prod], label="master", version=29374923859338549, state="" > echo "$DB_USER:$DB_PASSWORD" // prints: admin:prod123 > myapp -user $DB_USER -pass $DB_PASSWORD -in $FILE_INPUT -out $FILE_OUTPUT ...
- getting the "conf.xml":
> senv file -n myapp -p prod conf.xml \n Fetching file "conf.xml" from server at: http://127.0.0.1:8888/myapp/prod/master/conf.xml > cat conf.xml //prints: <configuration> <user>admin</user> <pass>prod123</pass> </configuration> > myapp -conf conf.xml ...
> senv --help
Senv is a fast native config-client for a
spring-cloud-config-server written in Go
Usage:
senv [command]
Available Commands:
env Fetches properties and sets them as environment variables
file Receives static file(s)
help Help about any command
Flags:
-h, --help help for senv
--host string configserver host (default "127.0.0.1")
-l, --label string config-repo label to be used (default "master")
-n, --name string spring.application.name (default "application")
--port string configserver port (default "8888")
-p, --profiles strings spring.active.profiles (default [default])
--version version for senv
Use "senv [command] --help" for more information about a command.
- https support with own ca
- customizable http header for vault and basic auth
- 100% code coverage
- ...
- Fork it
- Download your fork to your PC (
git clone https://github.com/your_username/cobra && cd cobra
) - Create your feature branch (
git checkout -b my-new-feature
) - Make changes and add them (
git add .
) - Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new pull request
Senv is released under the MIT license. See LICENSE