Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

Commit

Permalink
Added support for Consul ACL Token
Browse files Browse the repository at this point in the history
Updated to newer libraries of consul
Updated documentation for Consul ACL Token
  • Loading branch information
Kevin Kamps committed Nov 28, 2019
1 parent 0fafea5 commit 813a96a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ Usage:
Max number of events to be buffered (default 1024)
-registry-consul-log-ttl-passes-enabled
Logging of ttl passes are enabled if set to true
-registry-consul-token string
Token is used to provide a per-request ACL token
-registry-consul-url string
Consul address (default "http://127.0.0.1:8500")
```
Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
module kevinkamps/registrar

go 1.12

require (
github.com/davecgh/go-spew v1.1.1
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/docker v0.7.3-0.20180827131323-0c5f8d2b9b23
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7
github.com/fsouza/go-dockerclient v1.3.1
github.com/hashicorp/consul v1.2.4
github.com/hashicorp/go-cleanhttp v0.5.0 // indirect
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 // indirect
github.com/hashicorp/serf v0.8.1 // indirect
github.com/hashicorp/consul v1.6.2
github.com/hashicorp/consul/api v1.3.0
github.com/heroku/docker-registry-client v0.0.0-20181004091502-47ecf50fd8d4
github.com/mitchellh/mapstructure v1.1.2 // indirect
gopkg.in/yaml.v2 v2.2.1
)
2 changes: 2 additions & 0 deletions registry/consul/ConsulConfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Configuration struct {
DeregisterCriticalServiceAfter *int
EventsBufferSize *int
Datacenter *string
Token *string
}

func NewConsulConfiguration() *Configuration {
Expand All @@ -26,6 +27,7 @@ func NewConsulConfiguration() *Configuration {
config.EventsBufferSize = flag.Int("registry-consul-event-buffer-size", 1024, "Max number of events to be buffered")
config.LogTtlPassesEnabled = flag.Bool("registry-consul-log-ttl-passes-enabled", false, "Logging of ttl passes are enabled if set to true")
config.Datacenter = flag.String("registry-consul-datacenter", "dc1", "Consul datacenter")
config.Token = flag.String("registry-consul-token", "", "Token is used to provide a per-request ACL token")

return &config
}
Expand Down
2 changes: 2 additions & 0 deletions registry/consul/ConsulRegistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func (this *ConsulRegistry) initConsulConnection() {
config.Datacenter = *this.Configuration.Datacenter
config.Address = this.Configuration.Url.Host
config.Scheme = this.Configuration.Url.Scheme
config.Token = *this.Configuration.Token

log.Println(fmt.Sprintf("Registry - Consul: Connecting to: %s ", this.Configuration.Url))
client, err := consulapi.NewClient(config)
if err != nil {
Expand Down

0 comments on commit 813a96a

Please sign in to comment.