README ¶
confman
Simple configuration manager implemented as REST-ful microservice, written in Go.
Useful if you have a project that consists of multiple applications/modules. confman
provides a secure and easy way to maintain centralized configuration file that can be conveniently shared and accessed by your applications/modules across the whole project.
Installation
Install all dependencies. Skip any dependencies that you already have in your Go installation.
go get -u github.com/gorilla/mux
go get -u github.com/tidwall/gjson
go get -u golang.org/x/term
Clone and build this repository.
git clone https://github.com/capsic/confman
go build .
Configuration
/config.json
- confman
configuration
{
"port": 7777,
"configurationFile": "configuration.conf",
"encrypt": true,
"ipWhitelist": [
"127.0.0.1",
"[::1]"
],
"ssl": true,
"certFile": "fullchain.pem",
"keyFile": "privkey.pem"
}
port
- The microservice will be bound to this port.configurationFile
- The configuration file name (insidedata
directory) that will be served byconfman
.encrypt
- Configuration file may contain sensitive informations (eg. database password, private IP address, email info, etc.), you might want to enable this option soconfman
will encrypt the original configuration file once you start the service. You will be prompted to enter encryption passphrase when you start the service.ipWhitelist
- Additional security measure to limit access by remote IP address. Empty array means no IP checking.ssl
- Enable/disable SSL support on the service. If enabled you must place your certificate file (eg. cert.pem) and private key file (eg. key.pem) in thecert
directory.certFile
- SSL certificate file name, ignore ifssl
is disabled.keyFile
- SSL private key file name, ignore ifssl
is disabled.
/data/configuration.conf
- the actual configuration file that will be served by confman
, put whatever you need in here. Should be in JSON format, elements can be nested arbitrarily.
...
{
"mysql": {
"host": "127.0.0.1",
"port": 3306,
"user": "mysqluser",
"password": "mysqlpassword"
},
"rabbitmq": {
"host": "127.0.0.1",
"port": 5672,
"vhost": "/",
"credentials": {
"user": "rabbituser",
"password": "rabbitpassword"
}
},
"someArray": [
{"id": 1, "name": "John"},
{"id": 2, "name": "Doe"},
{"id": 3, "name": "Jane", "data": ["a", "b", "c", 1, 2, 3]}
]
}
...
Usage
Just execute the Go binary that you got at build.
By default CONFMANHOME
is set to /opt/capsic/confman
, if you're not running from this directory you need to specify the absolute path you're running this service from. This can be done either by:
- Manually set
CONFMANHOME
env. variable to the directory of yourconfman
build. - Or, specify it as CLI argument to the command (example #2).
- Or, change the
DEFAULTHOME
constant inmain.go
then rebuild the binary.
./confman
./confman /Users/myuser/confman
Making a REST request (example):
http://127.0.0.1:7777/get?key=mysql
>> {"host":"127.0.0.1","password":"mysqlpassword","port":3306,"user":"mysqluser"}
http://127.0.0.1:7777/get?key=mysql.host
>> "127.0.0.1"
http://127.0.0.1:7777/get?key=rabbitmq.port
>> 5672
http://127.0.0.1:7777/get?key=rabbitmq.credentials.password
>> "rabbitpassword"
https://127.0.0.1:7777/get?key=someArray
>> [{"id":1,"name":"John"},{"id":2,"name":"Doe"},{"id":3,"uname":"Jane","username":"janedoe"}]
https://127.0.0.1:7777/get?key=someArray.2.data
>> ["a","b","c",1,2,3]
https://127.0.0.1:7777/get?key=someArray.2.data.0
>> "a"
Credits
License
Documentation ¶
There is no documentation for this package.