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

Commit

Permalink
Merge pull request #55 from hashicorp/add_consul_ACL
Browse files Browse the repository at this point in the history
Add consul acl
  • Loading branch information
nicholasjackson committed Oct 15, 2018
2 parents 3b6abf5 + 102d5ee commit 07baa3e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion consul/service_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ type cacheItem struct {
}

// NewResolver creates a new Resolver
func NewResolver(address string, logger hclog.Logger) *Resolver {
func NewResolver(address, ACLToken string, logger hclog.Logger) *Resolver {
clientSet := dependency.NewClientSet()
clientSet.CreateConsulClient(&dependency.CreateConsulClientInput{
Address: address,
Token: ACLToken,
})

watch, _ := watch.NewWatcher(&watch.NewWatcherInput{
Expand Down
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
nodeURI = flag.String("node_addr", "localhost", "URI of the current Nomad node, this address is used for reporting and logging")
nomadAddr = flag.String("nomad_addr", "localhost:4646", "Address for Nomad API endpoint")
consulAddr = flag.String("consul_addr", "http://localhost:8500", "Address for Consul API endpoint")
consulACL = flag.String("consul_acl", "", "ACL token for Consul API, only required if ACL are enabled in Consul")
nomadRegion = flag.String("nomad_region", "global", "Default region to schedule functions in")
enableBasicAuth = flag.Bool("enable_basic_auth", false, "Flag for enabling basic authentication on gateway endpoints")
basicAuthSecretPath = flag.String("basic_auth_secret_path", "/secrets", "The directory path to the basic auth secret file")
Expand Down Expand Up @@ -123,6 +124,7 @@ func main() {
*nodeURI,
*nomadAddr,
*consulAddr,
*consulACL,
*nomadRegion,
)

Expand Down Expand Up @@ -165,7 +167,7 @@ func createFaaSHandlers(nomadClient *api.Client, consulResolver *consul.Resolver
}
}

func makeDependencies(statsDAddr, thisAddr, nomadAddr, consulAddr, region string) (hclog.Logger, *statsd.Client, *api.Client, *consul.Resolver) {
func makeDependencies(statsDAddr, thisAddr, nomadAddr, consulAddr, consulACL, region string) (hclog.Logger, *statsd.Client, *api.Client, *consul.Resolver) {
logger := setupLogging()

logger.Info("Using StatsD server:" + statsDAddr)
Expand All @@ -185,7 +187,7 @@ func makeDependencies(statsDAddr, thisAddr, nomadAddr, consulAddr, region string
logger.Error("Unable to create nomad client", err)
}

cr := consul.NewResolver(consulAddr, logger.Named("consul_resolver"))
cr := consul.NewResolver(consulAddr, consulACL, logger.Named("consul_resolver"))

return logger, stats, nomadClient, cr
}
Expand Down
2 changes: 1 addition & 1 deletion travis_deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

if ([ "$TRAVIS_BRANCH" == "master" ] || [ ! -z "$TRAVIS_TAG" ]) && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
if ([ ! -z "$TRAVIS_TAG" ]) && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
cd $GOPATH/src/github.com/hashicorp/faas-nomad;
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" quay.io;
goreleaser --rm-dist --skip-validate
Expand Down

0 comments on commit 07baa3e

Please sign in to comment.