forked from kelseyhightower/confd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f238a00
commit 3a20318
Showing
15 changed files
with
147 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
confd | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ package config | |
|
||
import ( | ||
"testing" | ||
|
||
"github.com/kelseyhightower/confd/log" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[template] | ||
src = "basic.conf.tmpl" | ||
dest = "/tmp/confd-basic-test.conf" | ||
keys = [ | ||
"/database/host", | ||
"/database/password", | ||
"/database/port", | ||
"/database/username", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[template] | ||
src = "iteration.conf.tmpl" | ||
dest = "/tmp/confd-iteration-test.conf" | ||
keys = [ | ||
"/upstream", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[database] | ||
host={{.database_host}} | ||
password={{.database_password}} | ||
port={{.database_port}} | ||
username={{.database_username}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
upstream app { | ||
{{range $server := GetDir "upstream"}} | ||
server {{$server.Value}}; | ||
{{end}} | ||
} | ||
|
||
server { | ||
server_name www.example.com; | ||
|
||
location / { | ||
proxy_pass http://app; | ||
proxy_redirect off; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
docker_host=${1} | ||
consul_id=$(docker run -p 8500:8500 -p 8400:8400 -d kelseyhightower/consul -server -bootstrap -ui-dir /opt/consul/web_ui -client 0.0.0.0 -advertise ${docker_host}) | ||
|
||
# Configure consul | ||
curl -X PUT http://${docker_host}:8500/v1/kv/database/host -d '127.0.0.1' | ||
curl -X PUT http://${docker_host}:8500/v1/kv/database/password -d 'p@sSw0rd' | ||
curl -X PUT http://${docker_host}:8500/v1/kv/database/port -d '3306' | ||
curl -X PUT http://${docker_host}:8500/v1/kv/database/username -d 'confd' | ||
curl -X PUT http://${docker_host}:8500/v1/kv/upstream/app1 -d '10.0.1.10:8080' | ||
curl -X PUT http://${docker_host}:8500/v1/kv/upstream/app2 -d '10.0.1.11:8080' | ||
|
||
# Run confd | ||
./confd -onetime -confdir ./integration/confdir -backend consul -consul-addr "${1}:8500" | ||
|
||
# Cleanup | ||
docker stop $consul_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
etcd_host=${1} | ||
etcd_port=${2} | ||
|
||
# Configure consul | ||
curl -L -X PUT http://${etcd_host}:${etcd_port}/v2/keys/database/host -d value=127.0.0.1 | ||
curl -L -X PUT http://${etcd_host}:${etcd_port}/v2/keys/database/password -d value=p@sSw0rd | ||
curl -L -X PUT http://${etcd_host}:${etcd_port}/v2/keys/database/port -d value=3306 | ||
curl -L -X PUT http://${etcd_host}:${etcd_port}/v2/keys/database/username -d value=confd | ||
curl -L -X PUT http://${etcd_host}:${etcd_port}/v2/keys/upstream/app1 -d value=10.0.1.10:8080 | ||
curl -L -X PUT http://${etcd_host}:${etcd_port}/v2/keys/upstream/app2 -d value=10.0.1.11:8080 | ||
|
||
# Run confd | ||
./confd -onetime -confdir ./integration/confdir -backend etcd -node "http://${etcd_host}:${etcd_port}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package node | ||
|
||
type Node struct { | ||
Key string | ||
Value interface{} | ||
} | ||
|
||
type Directory map[string][]Node | ||
|
||
func NewDirectory() Directory { | ||
d := make(Directory) | ||
return d | ||
} | ||
|
||
// Add. | ||
func (d Directory) Add(key string, node Node) { | ||
if d[key] == nil { | ||
d[key] = make([]Node, 0) | ||
} | ||
d[key] = append(d[key], node) | ||
} | ||
|
||
// Get. | ||
func (d Directory) Get(key string) []Node { | ||
return d[key] | ||
} | ||
|
||
// Set. | ||
func (d Directory) Set(key string, nodes []Node) { | ||
d[key] = nodes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters