From facda7cd7d08e70e6929cadcb4d47c7a9ce30594 Mon Sep 17 00:00:00 2001 From: greg linton Date: Tue, 25 Aug 2020 13:17:41 -0600 Subject: [PATCH 1/3] feat(cli): add option to dump the raw flux response from query --- cmd/influx/query.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/influx/query.go b/cmd/influx/query.go index c2b8b1e56f4..efb596dc56e 100644 --- a/cmd/influx/query.go +++ b/cmd/influx/query.go @@ -23,6 +23,7 @@ import ( var queryFlags struct { org organization file string + raw bool } func cmdQuery(f *globalFlags, opts genericCLIOpts) *cobra.Command { @@ -34,6 +35,7 @@ func cmdQuery(f *globalFlags, opts genericCLIOpts) *cobra.Command { f.registerFlags(cmd) queryFlags.org.register(cmd, true) cmd.Flags().StringVarP(&queryFlags.file, "file", "f", "", "Path to Flux query file") + cmd.Flags().BoolVarP(&queryFlags.raw, "raw", "r", false, "Display raw query results") return cmd } @@ -123,6 +125,11 @@ func fluxQueryF(cmd *cobra.Command, args []string) error { return err } + if queryFlags.raw { + io.Copy(os.Stdout, resp.Body) + return nil + } + dec := csv.NewMultiResultDecoder(csv.ResultDecoderConfig{}) results, err := dec.Decode(resp.Body) if err != nil { @@ -141,7 +148,6 @@ func fluxQueryF(cmd *cobra.Command, args []string) error { return err } } - results.Release() return results.Err() } From 53650e2a984d49bdbb6db080a0a4096519819ca6 Mon Sep 17 00:00:00 2001 From: greg linton Date: Tue, 25 Aug 2020 13:26:08 -0600 Subject: [PATCH 2/3] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84320133530..05069d551fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ 1. [19219](https://github.com/influxdata/influxdb/pull/19219): List buckets via the API now supports after (ID) parameter as an alternative to offset. 1. [19390](https://github.com/influxdata/influxdb/pull/19390): Record last success and failure run times in the Task 1. [19402](https://github.com/influxdata/influxdb/pull/19402): Inject Task's LatestSuccess Timestamp In Flux Extern +1. [19433](https://github.com/influxdata/influxdb/pull/19433): Add option to dump raw query results in CLI ### Bug Fixes From 0458c621395d217d11c19466fb5553d6a1d42dee Mon Sep 17 00:00:00 2001 From: greg linton Date: Wed, 26 Aug 2020 11:19:48 -0600 Subject: [PATCH 3/3] chore: re-add call to release and explanatory comment --- cmd/influx/query.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/influx/query.go b/cmd/influx/query.go index efb596dc56e..6e3b6f4bdd7 100644 --- a/cmd/influx/query.go +++ b/cmd/influx/query.go @@ -148,6 +148,9 @@ func fluxQueryF(cmd *cobra.Command, args []string) error { return err } } + // It is safe and appropriate to call Release multiple times and must be + // called before checking the error on the next line. + results.Release() return results.Err() }