Files
influx-cli/cmd/influx/setup.go
Sam Arnold 9747d05ae1 refactor: expose generated code and client business logic to share with Kapacitor (#103)
* refactor: take clients out of internal

* refactor: move stdio to pkg

* Move internal/api to api

* refactor: final changes for Kapacitor to access shared functionality

* chore: regenerate mocks

* fix: bad automated refactor

* chore: extra formatting not caught by make fmt
2021-05-25 10:05:01 -04:00

78 lines
2.2 KiB
Go

package main
import (
"github.com/influxdata/influx-cli/v2/clients/setup"
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
"github.com/urfave/cli/v2"
)
func newSetupCmd() *cli.Command {
var params setup.Params
return &cli.Command{
Name: "setup",
Usage: "Setup instance with initial user, org, bucket",
Before: middleware.WithBeforeFns(withCli(), withApi(false)),
Flags: append(
commonFlagsNoToken(),
&cli.StringFlag{
Name: "username",
Usage: "Name of initial user to create",
Aliases: []string{"u"},
Destination: &params.Username,
},
&cli.StringFlag{
Name: "password",
Usage: "Password to set on initial user",
Aliases: []string{"p"},
Destination: &params.Password,
},
&cli.StringFlag{
Name: tokenFlagName,
Usage: "Auth token to set on the initial user",
Aliases: []string{"t"},
EnvVars: []string{"INFLUX_TOKEN"},
DefaultText: "auto-generated",
Destination: &params.AuthToken,
},
&cli.StringFlag{
Name: "org",
Usage: "Name of initial organization to create",
Aliases: []string{"o"},
Destination: &params.Org,
},
&cli.StringFlag{
Name: "bucket",
Usage: "Name of initial bucket to create",
Aliases: []string{"b"},
Destination: &params.Bucket,
},
&cli.StringFlag{
Name: "retention",
Usage: "Duration initial bucket will retain data, or 0 for infinite",
Aliases: []string{"r"},
DefaultText: "infinite",
Destination: &params.Retention,
},
&cli.BoolFlag{
Name: "force",
Usage: "Skip confirmation prompt",
Aliases: []string{"f"},
Destination: &params.Force,
},
&cli.StringFlag{
Name: "name",
Usage: "Name to set on CLI config generated for the InfluxDB instance, required if other configs exist",
Aliases: []string{"n"},
Destination: &params.ConfigName,
},
),
Action: func(ctx *cli.Context) error {
client := setup.Client{
CLI: getCLI(ctx),
SetupApi: getAPINoToken(ctx).SetupApi,
}
return client.Setup(ctx.Context, &params)
},
}
}