Merged pull request #41 from influxdata/nc-idp-influx
chore(idp): Rename cmd/idp to cmd/influxpull/10616/head
commit
321d528808
|
@ -8,7 +8,7 @@ idpdb.bolt
|
|||
/dist
|
||||
|
||||
# Project binaries.
|
||||
/idp
|
||||
/influx
|
||||
/idpd
|
||||
/ifqld
|
||||
/bin
|
||||
|
|
6
Makefile
6
Makefile
|
@ -26,7 +26,7 @@ SOURCES := $(shell find . -name '*.go' -not -name '*_test.go')
|
|||
SOURCES_NO_VENDOR := $(shell find . -path ./vendor -prune -o -name "*.go" -not -name '*_test.go' -print)
|
||||
|
||||
# List of binary cmds to build
|
||||
CMDS := bin/idp bin/idpd bin/ifqld
|
||||
CMDS := bin/influx bin/idpd bin/ifqld
|
||||
|
||||
# List of utilities to build as part of the build process
|
||||
UTILS := bin/pigeon bin/cmpgen bin/goreleaser
|
||||
|
@ -49,8 +49,8 @@ subdirs: $(SUBDIRS)
|
|||
bin/ifqld: $(SOURCES)
|
||||
$(GO_BUILD) -i -o bin/ifqld ./cmd/ifqld
|
||||
|
||||
bin/idp: $(SOURCES)
|
||||
$(GO_BUILD) -i -o bin/idp ./cmd/idp
|
||||
bin/influx: $(SOURCES)
|
||||
$(GO_BUILD) -i -o bin/influx ./cmd/influx
|
||||
|
||||
bin/idpd: $(SOURCES)
|
||||
$(GO_BUILD) -i -o bin/idpd ./cmd/idpd
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
Execute()
|
||||
}
|
||||
|
||||
var idpCmd = &cobra.Command{
|
||||
Use: "idp",
|
||||
Short: "IDP Client",
|
||||
Run: idpF,
|
||||
}
|
||||
|
||||
func init() {
|
||||
idpCmd.AddCommand(authorizationCmd)
|
||||
idpCmd.AddCommand(bucketCmd)
|
||||
idpCmd.AddCommand(ifqlCmd)
|
||||
idpCmd.AddCommand(organizationCmd)
|
||||
idpCmd.AddCommand(userCmd)
|
||||
}
|
||||
|
||||
// Flags contains all the CLI flag values for idp.
|
||||
type Flags struct {
|
||||
token string
|
||||
host string
|
||||
}
|
||||
|
||||
var flags Flags
|
||||
|
||||
func init() {
|
||||
viper.SetEnvPrefix("IDP")
|
||||
|
||||
idpCmd.PersistentFlags().StringVarP(&flags.token, "token", "t", "", "API token to be used throughout client calls")
|
||||
viper.BindEnv("TOKEN")
|
||||
if h := viper.GetString("TOKEN"); h != "" {
|
||||
flags.token = h
|
||||
}
|
||||
|
||||
idpCmd.PersistentFlags().StringVar(&flags.host, "host", "http://localhost:9999", "HTTP address of IDP")
|
||||
viper.BindEnv("HOST")
|
||||
if h := viper.GetString("HOST"); h != "" {
|
||||
flags.host = h
|
||||
}
|
||||
}
|
||||
|
||||
func idpF(cmd *cobra.Command, args []string) {
|
||||
cmd.Usage()
|
||||
}
|
||||
|
||||
// Execute executes the idpd command
|
||||
func Execute() {
|
||||
if err := idpCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/cmd/idp/internal"
|
||||
"github.com/influxdata/platform/cmd/influx/internal"
|
||||
"github.com/influxdata/platform/http"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
|
@ -7,7 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/cmd/idp/internal"
|
||||
"github.com/influxdata/platform/cmd/influx/internal"
|
||||
"github.com/influxdata/platform/http"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
|
@ -0,0 +1,64 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
Execute()
|
||||
}
|
||||
|
||||
var influxCmd = &cobra.Command{
|
||||
Use: "influx",
|
||||
Short: "Influx Client",
|
||||
Run: influxF,
|
||||
}
|
||||
|
||||
func init() {
|
||||
influxCmd.AddCommand(authorizationCmd)
|
||||
influxCmd.AddCommand(bucketCmd)
|
||||
influxCmd.AddCommand(replCmd)
|
||||
influxCmd.AddCommand(queryCmd)
|
||||
influxCmd.AddCommand(organizationCmd)
|
||||
influxCmd.AddCommand(userCmd)
|
||||
}
|
||||
|
||||
// Flags contains all the CLI flag values for influx.
|
||||
type Flags struct {
|
||||
token string
|
||||
host string
|
||||
}
|
||||
|
||||
var flags Flags
|
||||
|
||||
func init() {
|
||||
viper.SetEnvPrefix("INFLUX")
|
||||
|
||||
influxCmd.PersistentFlags().StringVarP(&flags.token, "token", "t", "", "API token to be used throughout client calls")
|
||||
viper.BindEnv("TOKEN")
|
||||
if h := viper.GetString("TOKEN"); h != "" {
|
||||
flags.token = h
|
||||
}
|
||||
|
||||
influxCmd.PersistentFlags().StringVar(&flags.host, "host", "http://localhost:9999", "HTTP address of Influx")
|
||||
viper.BindEnv("HOST")
|
||||
if h := viper.GetString("HOST"); h != "" {
|
||||
flags.host = h
|
||||
}
|
||||
}
|
||||
|
||||
func influxF(cmd *cobra.Command, args []string) {
|
||||
cmd.Usage()
|
||||
}
|
||||
|
||||
// Execute executes the influx command
|
||||
func Execute() {
|
||||
if err := influxCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/cmd/idp/internal"
|
||||
"github.com/influxdata/platform/cmd/influx/internal"
|
||||
"github.com/influxdata/platform/http"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
|
@ -21,90 +21,41 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var ifqlCmd = &cobra.Command{
|
||||
Use: "ifql",
|
||||
Short: "Commands to interact with an IFQL server",
|
||||
Run: ifqlF,
|
||||
var queryCmd = &cobra.Command{
|
||||
Use: "query [query literal or @/path/to/query.ifql]",
|
||||
Short: "Execute an IFQL query",
|
||||
Long: `Execute a literal IFQL query provided as a string,
|
||||
or execute a literal IFQL query contained in a file by specifying the file prefixed with an @ sign.`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: ifqlQueryF,
|
||||
}
|
||||
|
||||
var ifqlFlags struct {
|
||||
var queryFlags struct {
|
||||
StorageHosts string
|
||||
OrgID string
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
ifqlCmd.PersistentFlags().StringVar(&ifqlFlags.StorageHosts, "storage-hosts", "localhost:8082", "Comma-separated list of storage hosts")
|
||||
queryCmd.PersistentFlags().StringVar(&queryFlags.StorageHosts, "storage-hosts", "localhost:8082", "Comma-separated list of storage hosts")
|
||||
viper.BindEnv("STORAGE_HOSTS")
|
||||
if h := viper.GetString("STORAGE_HOSTS"); h != "" {
|
||||
ifqlFlags.StorageHosts = h
|
||||
queryFlags.StorageHosts = h
|
||||
}
|
||||
|
||||
ifqlCmd.PersistentFlags().BoolVarP(&ifqlFlags.Verbose, "verbose", "v", false, "Verbose output")
|
||||
queryCmd.PersistentFlags().BoolVarP(&queryFlags.Verbose, "verbose", "v", false, "Verbose output")
|
||||
viper.BindEnv("VERBOSE")
|
||||
if viper.GetBool("VERBOSE") {
|
||||
ifqlFlags.Verbose = true
|
||||
queryFlags.Verbose = true
|
||||
}
|
||||
|
||||
ifqlCmd.PersistentFlags().StringVar(&ifqlFlags.OrgID, "org-id", "", "Organization ID")
|
||||
queryCmd.PersistentFlags().StringVar(&queryFlags.OrgID, "org-id", "", "Organization ID")
|
||||
viper.BindEnv("ORG_ID")
|
||||
if h := viper.GetString("ORG_ID"); h != "" {
|
||||
ifqlFlags.OrgID = h
|
||||
queryFlags.OrgID = h
|
||||
}
|
||||
}
|
||||
|
||||
func ifqlF(cmd *cobra.Command, args []string) {
|
||||
cmd.Usage()
|
||||
}
|
||||
|
||||
func init() {
|
||||
ifqlCmd.AddCommand(&cobra.Command{
|
||||
Use: "repl",
|
||||
Short: "Interactive IFQL REPL (read-eval-print-loop)",
|
||||
Args: cobra.NoArgs,
|
||||
Run: ifqlReplF,
|
||||
})
|
||||
}
|
||||
|
||||
func ifqlReplF(cmd *cobra.Command, args []string) {
|
||||
hosts, err := storageHostReader(strings.Split(ifqlFlags.StorageHosts, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
org, err := orgID(ifqlFlags.OrgID)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
buckets, err := bucketService(flags.host, flags.token)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
r, err := getIFQLREPL(hosts, buckets, org, ifqlFlags.Verbose)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
r.Run()
|
||||
}
|
||||
|
||||
func init() {
|
||||
ifqlCmd.AddCommand(&cobra.Command{
|
||||
Use: "query [query literal or @/path/to/query.ifql]",
|
||||
Short: "Execute an IFQL query",
|
||||
Long: `Execute a literal IFQL query provided as a string,
|
||||
or execute a literal IFQL query contained in a file by specifying the file prefixed with an @ sign.`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: ifqlQueryF,
|
||||
})
|
||||
}
|
||||
|
||||
func ifqlQueryF(cmd *cobra.Command, args []string) {
|
||||
q, err := repl.LoadQuery(args[0])
|
||||
if err != nil {
|
||||
|
@ -112,13 +63,13 @@ func ifqlQueryF(cmd *cobra.Command, args []string) {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
hosts, err := storageHostReader(strings.Split(ifqlFlags.StorageHosts, ","))
|
||||
hosts, err := storageHostReader(strings.Split(queryFlags.StorageHosts, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
org, err := orgID(ifqlFlags.OrgID)
|
||||
org, err := orgID(queryFlags.OrgID)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
|
@ -130,7 +81,7 @@ func ifqlQueryF(cmd *cobra.Command, args []string) {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
r, err := getIFQLREPL(hosts, buckets, org, ifqlFlags.Verbose)
|
||||
r, err := getIFQLREPL(hosts, buckets, org, queryFlags.Verbose)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
|
@ -166,7 +117,7 @@ func bucketService(addr, token string) (platform.BucketService, error) {
|
|||
|
||||
func orgID(org string) (ifqlid.ID, error) {
|
||||
var oid ifqlid.ID
|
||||
err := oid.DecodeFromString(ifqlFlags.OrgID)
|
||||
err := oid.DecodeFromString(org)
|
||||
return oid, err
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var replCmd = &cobra.Command{
|
||||
Use: "repl",
|
||||
Short: "Interactive REPL (read-eval-print-loop)",
|
||||
Args: cobra.NoArgs,
|
||||
Run: replF,
|
||||
}
|
||||
|
||||
var replFlags struct {
|
||||
StorageHosts string
|
||||
OrgID string
|
||||
Verbose bool
|
||||
}
|
||||
|
||||
func init() {
|
||||
replCmd.PersistentFlags().StringVar(&replFlags.StorageHosts, "storage-hosts", "localhost:8082", "Comma-separated list of storage hosts")
|
||||
viper.BindEnv("STORAGE_HOSTS")
|
||||
if h := viper.GetString("STORAGE_HOSTS"); h != "" {
|
||||
replFlags.StorageHosts = h
|
||||
}
|
||||
|
||||
replCmd.PersistentFlags().BoolVarP(&replFlags.Verbose, "verbose", "v", false, "Verbose output")
|
||||
viper.BindEnv("VERBOSE")
|
||||
if viper.GetBool("VERBOSE") {
|
||||
replFlags.Verbose = true
|
||||
}
|
||||
|
||||
replCmd.PersistentFlags().StringVar(&replFlags.OrgID, "org-id", "", "Organization ID")
|
||||
viper.BindEnv("ORG_ID")
|
||||
if h := viper.GetString("ORG_ID"); h != "" {
|
||||
replFlags.OrgID = h
|
||||
}
|
||||
}
|
||||
|
||||
func replF(cmd *cobra.Command, args []string) {
|
||||
hosts, err := storageHostReader(strings.Split(replFlags.StorageHosts, ","))
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
org, err := orgID(replFlags.OrgID)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
buckets, err := bucketService(flags.host, flags.token)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
r, err := getIFQLREPL(hosts, buckets, org, replFlags.Verbose)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
r.Run()
|
||||
}
|
|
@ -6,7 +6,7 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/influxdata/platform"
|
||||
"github.com/influxdata/platform/cmd/idp/internal"
|
||||
"github.com/influxdata/platform/cmd/influx/internal"
|
||||
"github.com/influxdata/platform/http"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
Loading…
Reference in New Issue