Add Consul token config #23

Merged
maximilien merged 1 commit from aya/bottin:feature/consul-token into main 2025-01-18 18:13:27 +00:00
2 changed files with 7 additions and 0 deletions
Showing only changes of commit 8eb2f4403e - Show all commits

View file

@ -87,6 +87,7 @@ suffix in the `suffix` key of the json config file.
By default, Bottin connects to the Consul server on localhost. By default, Bottin connects to the Consul server on localhost.
Change this by specifying the `consul_host` key in the json config file. Change this by specifying the `consul_host` key in the json config file.
You may need a `consul_token` to connect to the Consul server.
### Bind addresses ### Bind addresses

View file

@ -40,6 +40,7 @@ type ConfigFile struct {
ConsulHost string `json:"consul_host"` ConsulHost string `json:"consul_host"`
ConsulConsistent bool `json:"consul_force_consistency"` ConsulConsistent bool `json:"consul_force_consistency"`
ConsulToken string `json:"consul_token"`
Acl []string `json:"acl"` Acl []string `json:"acl"`
@ -56,6 +57,7 @@ type Config struct {
ConsulHost string ConsulHost string
ConsulConsistent bool ConsulConsistent bool
ConsulToken string
Acl ACL Acl ACL
@ -114,6 +116,7 @@ func readConfig(logger *log.Logger) Config {
ConsulHost: config_file.ConsulHost, ConsulHost: config_file.ConsulHost,
ConsulConsistent: config_file.ConsulConsistent, ConsulConsistent: config_file.ConsulConsistent,
ConsulToken: config_file.ConsulToken,
Acl: acl, Acl: acl,
} }
@ -168,6 +171,9 @@ func main() {
if config.ConsulHost != "" { if config.ConsulHost != "" {
consul_config.Address = config.ConsulHost consul_config.Address = config.ConsulHost
} }
if config.ConsulToken != "" {
consul_config.Token = config.ConsulToken
}
consul_client, err := consul.NewClient(consul_config) consul_client, err := consul.NewClient(consul_config)
if err != nil { if err != nil {
logger.Fatal(err) logger.Fatal(err)