Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add option to dump the raw flux response from query #19433

Merged
merged 3 commits into from
Aug 26, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd/influx/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
var queryFlags struct {
org organization
file string
raw bool
}

func cmdQuery(f *globalFlags, opts genericCLIOpts) *cobra.Command {
Expand All @@ -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
}
Expand Down Expand Up @@ -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 {
Expand All @@ -141,7 +148,6 @@ func fluxQueryF(cmd *cobra.Command, args []string) error {
return err
}
}
results.Release()
glinton marked this conversation as resolved.
Show resolved Hide resolved
return results.Err()
}

Expand Down