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

fix(influx): remove references to local #18623

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

### Bug Fixes
1. [18602](https://github.com/influxdata/influxdb/pull/18602): Fix uint overflow during setup on 32bit systems
1. [18623](https://github.com/influxdata/influxdb/pull/18623): Drop support for --local flag within influx CLI

## v2.0.0-beta.12 [2020-06-12]

Expand Down
4 changes: 0 additions & 4 deletions cmd/influx/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,6 @@ func writeTokens(w io.Writer, printOpts tokenPrintOpt) error {
}

func newAuthorizationService() (platform.AuthorizationService, error) {
if flags.local {
return newLocalKVService()
}

httpClient, err := newHTTPClient()
if err != nil {
return nil, err
Expand Down
4 changes: 0 additions & 4 deletions cmd/influx/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ func newBackupService() (influxdb.BackupService, error) {
func backupF(cmd *cobra.Command, args []string) error {
ctx := context.Background()

if flags.local {
return fmt.Errorf("local flag not supported for backup command")
}

if backupFlags.Path == "" {
return fmt.Errorf("must specify path")
}
Expand Down
23 changes: 0 additions & 23 deletions cmd/influx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ import (
"time"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/bolt"
"github.com/influxdata/influxdb/v2/cmd/influx/config"
"github.com/influxdata/influxdb/v2/cmd/influx/internal"
"github.com/influxdata/influxdb/v2/http"
"github.com/influxdata/influxdb/v2/internal/fs"
"github.com/influxdata/influxdb/v2/kit/cli"
"github.com/influxdata/influxdb/v2/kv"
"github.com/influxdata/influxdb/v2/pkg/httpc"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.uber.org/zap"
)

const maxTCPConnections = 10
Expand Down Expand Up @@ -149,7 +146,6 @@ func runEMiddlware(mw cobraRunEMiddleware) genericCLIOptFn {

type globalFlags struct {
config.Config
local bool
skipVerify bool
traceDebugID string
}
Expand Down Expand Up @@ -236,7 +232,6 @@ func (b *cmdInfluxBuilder) cmd(childCmdFns ...func(f *globalFlags, opt genericCL
}
flags.Config = cfg

cmd.PersistentFlags().BoolVar(&flags.local, "local", false, "Run commands locally against the filesystem")
cmd.PersistentFlags().BoolVar(&flags.skipVerify, "skip-verify", false, "SkipVerify controls whether a client verifies the server's certificate chain and host name.")

// Update help description for all commands in command tree
Expand Down Expand Up @@ -413,20 +408,6 @@ func walk(c *cobra.Command, f func(*cobra.Command)) {
}
}

func newLocalKVService() (*kv.Service, error) {
boltFile, err := fs.BoltFile()
if err != nil {
return nil, err
}

store := bolt.NewKVStore(zap.NewNop(), boltFile)
if err := store.Open(context.Background()); err != nil {
return nil, err
}

return kv.NewService(zap.NewNop(), store), nil
}

type organization struct {
id, name string
}
Expand Down Expand Up @@ -545,10 +526,6 @@ func writeJSON(w io.Writer, v interface{}) error {
}

func newBucketService() (influxdb.BucketService, error) {
if flags.local {
return newLocalKVService()
}

client, err := newHTTPClient()
if err != nil {
return nil, err
Expand Down
13 changes: 4 additions & 9 deletions cmd/influx/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,31 @@ func Test_influx_cmd(t *testing.T) {
}{
{
name: "all full length flags set",
args: []string{"--token=TOKEN", "--host=HOST", "--local=true", "--skip-verify=true"},
args: []string{"--token=TOKEN", "--host=HOST", "--skip-verify=true"},
envVars: envVarsZeroMap,
expected: globalFlags{
Config: config.Config{
Token: "TOKEN",
Host: "HOST",
},
skipVerify: true,
local: true,
},
},
{
name: "token p flag set",
args: []string{"-t=TOKEN", "--host=HOST", "--local=true", "--skip-verify=true"},
args: []string{"-t=TOKEN", "--host=HOST", "--skip-verify=true"},
envVars: envVarsZeroMap,
expected: globalFlags{
Config: config.Config{
Token: "TOKEN",
Host: "HOST",
},
skipVerify: true,
local: true,
},
},
{
name: "env vars set",
args: []string{"--local=true", "--skip-verify=true"},
args: []string{"--skip-verify=true"},
envVars: map[string]string{
"INFLUX_TOKEN": "TOKEN",
"INFLUX_HOST": "HOST",
Expand All @@ -57,12 +55,11 @@ func Test_influx_cmd(t *testing.T) {
Host: "HOST",
},
skipVerify: true,
local: true,
},
},
{
name: "env vars and flags set",
args: []string{"--local=true", "--token=flag-token", "--host=flag-host"},
args: []string{"--token=flag-token", "--host=flag-host"},
envVars: map[string]string{
"INFLUX_TOKEN": "TOKEN",
"INFLUX_HOST": "HOST",
Expand All @@ -73,7 +70,6 @@ func Test_influx_cmd(t *testing.T) {
Host: "flag-host",
},
skipVerify: false,
local: true,
},
},
}
Expand Down Expand Up @@ -101,7 +97,6 @@ func Test_influx_cmd(t *testing.T) {

assert.Equal(t, tt.expected.Host, flagCapture.Host)
assert.Equal(t, tt.expected.Token, flagCapture.Token)
assert.Equal(t, tt.expected.local, flagCapture.local)
assert.Equal(t, tt.expected.skipVerify, flagCapture.skipVerify)
}

Expand Down
12 changes: 0 additions & 12 deletions cmd/influx/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,6 @@ func (b *cmdOrgBuilder) registerPrintFlags(cmd *cobra.Command) {
}

func newOrgServices() (influxdb.OrganizationService, influxdb.UserResourceMappingService, influxdb.UserService, error) {
if flags.local {
svc, err := newLocalKVService()
if err != nil {
return nil, nil, nil, err
}
return svc, svc, svc, nil
}

client, err := newHTTPClient()
if err != nil {
return nil, nil, nil, err
Expand All @@ -535,10 +527,6 @@ func newOrgServices() (influxdb.OrganizationService, influxdb.UserResourceMappin
}

func newOrganizationService() (influxdb.OrganizationService, error) {
if flags.local {
return newLocalKVService()
}

client, err := newHTTPClient()
if err != nil {
return nil, err
Expand Down
4 changes: 0 additions & 4 deletions cmd/influx/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import (

func cmdPing(f *globalFlags, opts genericCLIOpts) *cobra.Command {
runE := func(cmd *cobra.Command, args []string) error {
if flags.local {
return fmt.Errorf("local flag not supported for ping command")
}

c := http.Client{
Timeout: 5 * time.Second,
Transport: &http.Transport{
Expand Down
4 changes: 0 additions & 4 deletions cmd/influx/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ func readFluxQuery(args []string, file string) (string, error) {
}

func fluxQueryF(cmd *cobra.Command, args []string) error {
if flags.local {
return fmt.Errorf("local flag not supported for query command")
}

if err := queryFlags.org.validOrgFlags(&flags); err != nil {
return err
}
Expand Down
5 changes: 0 additions & 5 deletions cmd/influx/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"crypto/tls"
"fmt"
"net/http"

"github.com/influxdata/flux"
Expand Down Expand Up @@ -32,10 +31,6 @@ func cmdREPL(f *globalFlags, opt genericCLIOpts) *cobra.Command {
}

func replF(cmd *cobra.Command, args []string) error {
if flags.local {
return fmt.Errorf("local flag not supported for repl command")
}

if err := replFlags.org.validOrgFlags(&flags); err != nil {
return err
}
Expand Down
8 changes: 0 additions & 8 deletions cmd/influx/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ func cmdSetupUser(opt genericCLIOpts) *cobra.Command {
}

func setupUserF(cmd *cobra.Command, args []string) error {
if flags.local {
return fmt.Errorf("local flag not supported for setup command")
}

// check if setup is allowed
client, err := newHTTPClient()
if err != nil {
Expand Down Expand Up @@ -118,10 +114,6 @@ func setupUserF(cmd *cobra.Command, args []string) error {
}

func setupF(cmd *cobra.Command, args []string) error {
if flags.local {
return fmt.Errorf("local flag not supported for setup command")
}

// check if setup is allowed
client, err := newHTTPClient()
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions cmd/influx/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import (

func cmdTask(f *globalFlags, opt genericCLIOpts) *cobra.Command {
runE := func(cmd *cobra.Command, args []string) error {
if flags.local {
return fmt.Errorf("local flag not supported for task command")
}

seeHelp(cmd, args)
return nil
}
Expand Down
4 changes: 0 additions & 4 deletions cmd/influx/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,6 @@ type userPrintOpts struct {
}

func newUserService() (influxdb.UserService, error) {
if flags.local {
return newLocalKVService()
}

client, err := newHTTPClient()
if err != nil {
return nil, err
Expand Down