Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 24e20f6

Browse files
author
Harmen
authored
Merge pull request #22 from MaheshGPai/master
Allow passing aerospike credentials via environment variables
2 parents 7526bbc + bb24798 commit 24e20f6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

main.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ var (
3939
showVersion = flag.Bool("version", false, "show version")
4040
addr = flag.String("listen", ":9145", "listen address for prometheus")
4141
nodeAddr = flag.String("node", "127.0.0.1:3000", "aerospike node")
42-
username = flag.String("username", "", "username. Leave empty for no authentication")
43-
password = flag.String("password", "", "password")
42+
username = flag.String("username", "", "username. Leave empty for no authentication. ENV variable AS_USERNAME, if set, will override this.")
43+
password = flag.String("password", "", "password. ENV variable AS_PASSWORD, if set, will override this.")
4444

4545
landingPage = `<html>
4646
<head><title>Aerospike exporter</title></head>
@@ -64,6 +64,16 @@ func main() {
6464
log.Fatal("usage error")
6565
}
6666

67+
user := os.Getenv("AS_USERNAME")
68+
if user != "" {
69+
*username = user
70+
}
71+
72+
pass := os.Getenv("AS_PASSWORD")
73+
if pass != "" {
74+
*password = pass
75+
}
76+
6777
if *showVersion {
6878
fmt.Printf("asprom %s\n", version)
6979
os.Exit(0)

0 commit comments

Comments
 (0)