Skip to content

Commit d73bc11

Browse files
alobachev-tinkoffmblaschke
authored andcommitted
[+] basic auth
1 parent 32195fa commit d73bc11

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func main() {
6464
flag.StringVar(&esURL, "esURL", esURL, "Elasticsearch HTTP URL")
6565
flag.BoolVar(&showVersion, "version", false, "Print version number and exit")
6666
flag.Parse()
67-
67+
6868
if showVersion {
6969
fmt.Println(versionString)
7070
os.Exit(0)
@@ -157,6 +157,13 @@ func handler(w http.ResponseWriter, r *http.Request) {
157157
req.Header.Set("User-Agent", versionString)
158158
req.Header.Set("Content-Type", "application/json")
159159

160+
esUser := os.Getenv("ES_USER")
161+
esPass := os.Getenv("ES_PASS")
162+
163+
if len(esUser) != 0 && len(esPass) != 0 {
164+
req.SetBasicAuth(esUser, esPass)
165+
}
166+
160167
resp, err := http.DefaultClient.Do(req)
161168
if err != nil {
162169
notificationsErrored.Inc()

0 commit comments

Comments
 (0)