Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
Add support for loading configuration from directories
Browse files Browse the repository at this point in the history
  • Loading branch information
palourde committed Nov 24, 2015
1 parent 58cfe41 commit ff0651b
Show file tree
Hide file tree
Showing 9 changed files with 399 additions and 226 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ build
.idea/
coverage.out
*.swp

keys/
*.rsa
*.rsa.pub

cover.out
coverage.html
27 changes: 27 additions & 0 deletions fixtures/conf.d/config_base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"sensu": [
{
"name": "us-east-2",
"host": "10.0.0.2"
},
{
"name": "us-west-2",
"host": "192.168.0.2",
"port": 4569,
"timeout": 5
}
],
"uchiwa": {
"host": "127.0.0.1",
"port": 3000,
"users": [
{
"username" : "admin",
"password": "secret",
"role": {
"readonly": false
}
}
]
}
}
21 changes: 21 additions & 0 deletions fixtures/conf.d/config_overwrite.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"sensu": [
{
"name": "us-east-3",
"host": "10.0.0.3"
}
],
"uchiwa": {
"host": "192.168.0.1",
"port": 8000,
"users": [
{
"username" : "readonly",
"password": "secret",
"role": {
"readonly": true
}
}
]
}
}
13 changes: 9 additions & 4 deletions fixtures/config_test.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"sensu": [
{
"name": "qux",
"host": "hidden-ravine-4272.herokuapp.com",
"port": 80
"name": "us-east-1",
"host": "10.0.0.1"
},
{
"name": "us-west-1",
"host": "192.168.0.1",
"port": 4570,
"timeout": 5
}
],
"uchiwa": {
"host": "0.0.0.0",
"port": 3000,
"port": 8080,
"user": "foo",
"pass": "bar"
}
Expand Down
25 changes: 0 additions & 25 deletions fixtures/config_test_multiple.json

This file was deleted.

6 changes: 2 additions & 4 deletions uchiwa.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import (

func main() {
configFile := flag.String("c", "./config.json", "Full or relative path to the configuration file")
configDir := flag.String("d", "", "Full or relative path to the configuration directory, or comma delimited directories")
publicPath := flag.String("p", "public", "Full or relative path to the public directory")
flag.Parse()

config, err := config.Load(*configFile)
if err != nil {
logger.Fatal(err)
}
config := config.Load(*configFile, *configDir)

logger.Debug("Debug mode enabled")

Expand Down
Loading

0 comments on commit ff0651b

Please sign in to comment.