From e457cefb24c3fa78ecc1aa8d334057cc563a4e47 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Fri, 7 Oct 2016 16:07:08 -0500 Subject: [PATCH] Support INFLUX_USERNAME and INFLUX_PASSWORD for setting username/password in the CLI --- CHANGELOG.md | 1 + cmd/influx/cli/cli.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82563c32ff..3a0d88c0fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - [#7146](https://github.com/influxdata/influxdb/issues/7146): Add max-values-per-tag to limit high tag cardinality data - [#5955](https://github.com/influxdata/influxdb/issues/5955): Make regex work on field and dimension keys in SELECT clause. - [#7470](https://github.com/influxdata/influxdb/pull/7470): Reduce map allocations when computing the TagSet of a measurement. +- [#6894](https://github.com/influxdata/influxdb/issues/6894): Support `INFLUX_USERNAME` and `INFLUX_PASSWORD` for setting username/password in the CLI. ### Bugfixes diff --git a/cmd/influx/cli/cli.go b/cmd/influx/cli/cli.go index 47f4e2f580..0d115e9572 100644 --- a/cmd/influx/cli/cli.go +++ b/cmd/influx/cli/cli.go @@ -102,6 +102,15 @@ func (c *CommandLine) Run() error { } } + // Read environment variables for username/password. + if c.Username == "" { + c.Username = os.Getenv("INFLUX_USERNAME") + } + // If we prompted for a password, always use the entered password. + if !promptForPassword && c.Password == "" { + c.Password = os.Getenv("INFLUX_PASSWORD") + } + if err := c.Connect(""); err != nil { return fmt.Errorf( "Failed to connect to %s\nPlease check your connection settings and ensure 'influxd' is running.",