parent
f54848f443
commit
aee64f1901
|
@ -13,6 +13,7 @@
|
|||
1. [19030](https://github.com/influxdata/influxdb/pull/19030): Enable dynamic destination for the influx CLI configs file
|
||||
1. [19029](https://github.com/influxdata/influxdb/pull/19029): Navigating away from a dashboard cancels all pending queries
|
||||
1. [19003](https://github.com/influxdata/influxdb/pull/19003): Upgrade to Flux v0.74.0
|
||||
1. [19040](https://github.com/influxdata/influxdb/pull/19040): Drop the REPL command from influx CLI
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -303,7 +303,6 @@ func influxCmd(opts ...genericCLIOptFn) *cobra.Command {
|
|||
cmdOrganization,
|
||||
cmdPing,
|
||||
cmdQuery,
|
||||
cmdREPL,
|
||||
cmdSecret,
|
||||
cmdSetup,
|
||||
cmdStack,
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/influxdata/flux"
|
||||
"github.com/influxdata/flux/dependencies/filesystem"
|
||||
"github.com/influxdata/flux/plan"
|
||||
"github.com/influxdata/flux/repl"
|
||||
"github.com/influxdata/flux/runtime"
|
||||
_ "github.com/influxdata/flux/stdlib"
|
||||
"github.com/influxdata/flux/stdlib/influxdata/influxdb"
|
||||
|
@ -98,3 +104,19 @@ func fluxQueryF(cmd *cobra.Command, args []string) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getFluxREPL(skipVerify bool) (*repl.REPL, error) {
|
||||
deps := flux.NewDefaultDependencies()
|
||||
deps.Deps.FilesystemService = filesystem.SystemFS
|
||||
if skipVerify {
|
||||
deps.Deps.HTTPClient = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
ctx := deps.Inject(context.Background())
|
||||
return repl.New(ctx, deps), nil
|
||||
}
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
|
||||
"github.com/influxdata/flux"
|
||||
"github.com/influxdata/flux/dependencies/filesystem"
|
||||
"github.com/influxdata/flux/plan"
|
||||
"github.com/influxdata/flux/repl"
|
||||
"github.com/influxdata/flux/runtime"
|
||||
_ "github.com/influxdata/flux/stdlib"
|
||||
"github.com/influxdata/flux/stdlib/influxdata/influxdb"
|
||||
_ "github.com/influxdata/influxdb/v2/query/stdlib"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var replFlags struct {
|
||||
org organization
|
||||
}
|
||||
|
||||
func cmdREPL(f *globalFlags, opt genericCLIOpts) *cobra.Command {
|
||||
cmd := opt.newCmd("repl", replF, true)
|
||||
cmd.Short = "Interactive Flux REPL (read-eval-print-loop)"
|
||||
cmd.Args = cobra.NoArgs
|
||||
|
||||
f.registerFlags(cmd)
|
||||
replFlags.org.register(cmd, false)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func replF(cmd *cobra.Command, args []string) error {
|
||||
if err := replFlags.org.validOrgFlags(&flags); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
plan.RegisterLogicalRules(
|
||||
influxdb.DefaultFromAttributes{
|
||||
Org: &influxdb.NameOrID{
|
||||
ID: replFlags.org.id,
|
||||
Name: replFlags.org.name,
|
||||
},
|
||||
Host: &flags.Host,
|
||||
Token: &flags.Token,
|
||||
},
|
||||
)
|
||||
runtime.FinalizeBuiltIns()
|
||||
|
||||
r, err := getFluxREPL(flags.skipVerify)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.Run()
|
||||
return nil
|
||||
}
|
||||
|
||||
func getFluxREPL(skipVerify bool) (*repl.REPL, error) {
|
||||
deps := flux.NewDefaultDependencies()
|
||||
deps.Deps.FilesystemService = filesystem.SystemFS
|
||||
if skipVerify {
|
||||
deps.Deps.HTTPClient = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
ctx := deps.Inject(context.Background())
|
||||
return repl.New(ctx, deps), nil
|
||||
}
|
Loading…
Reference in New Issue