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

Add consul acl #55

Merged
merged 3 commits into from
Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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