From 8baf928a5b475d3b60112042fef5b29f64906834 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Wed, 21 Jun 2023 20:38:30 +0200 Subject: [PATCH] added config package --- config/config.go | 22 ++++++++++++++++++++++ consul/discovery.go | 2 +- go.mod | 1 + go.sum | 2 ++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 config/config.go diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..67c6b43 --- /dev/null +++ b/config/config.go @@ -0,0 +1,22 @@ +package config + +import ( + "os" + + "github.com/joho/godotenv" +) + +var ErrLoadingEnvs error + +func init() { + ErrLoadingEnvs = godotenv.Load() +} + +func GetEnv(name string, defVal string) string { + env := os.Getenv(name) + if env == "" { + return defVal + } + + return env +} diff --git a/consul/discovery.go b/consul/discovery.go index 133151a..2dc5984 100644 --- a/consul/discovery.go +++ b/consul/discovery.go @@ -153,7 +153,7 @@ func (s *Service) getTags() []string { "traefik.http.services." + s.Name + ".loadbalancer.server.scheme=http", "traefik.http.services." + s.Name + ".loadbalancer.server.port=" + strconv.Itoa(s.port), "traefik.http.services." + s.Name + ".loadbalancer.passhostheader=false", - "traefik.http.middlewares.auth_" + s.Name + ".plugin.auth.handlerURL=", + "traefik.http.middlewares.auth_" + s.Name + ".plugin.auth.handlerURL="", // "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.authRequestHeaders=Cookie", // "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.authResponseHeaders=Set-Cookie, Server", // "traefik.http.middlewares.auth_" + s.Name + ".forwardauth.trustForwardHeader=true", diff --git a/go.mod b/go.mod index f820a5d..b8bfe9c 100644 --- a/go.mod +++ b/go.mod @@ -21,6 +21,7 @@ require ( github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/serf v0.10.1 // indirect + github.com/joho/godotenv v1.5.1 // indirect github.com/mattn/go-colorable v0.1.6 // indirect github.com/mattn/go-isatty v0.0.12 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect diff --git a/go.sum b/go.sum index e5498ae..4984b77 100644 --- a/go.sum +++ b/go.sum @@ -64,6 +64,8 @@ github.com/hashicorp/memberlist v0.5.0 h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0= github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY= github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=