chore: refactor influxid.ID
, cleanup organization checking (#326)
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/influxdata/influx-cli/v2/clients"
|
||||
"github.com/influxdata/influx-cli/v2/clients/apply"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/template"
|
||||
@ -16,8 +17,7 @@ import (
|
||||
|
||||
func newApplyCmd() cli.Command {
|
||||
var params struct {
|
||||
orgId string
|
||||
orgName string
|
||||
orgParams clients.OrgParams
|
||||
stackId string
|
||||
inPaths cli.StringSlice
|
||||
inUrls cli.StringSlice
|
||||
@ -89,19 +89,7 @@ For more templates created by the community, see
|
||||
https://github.com/influxdata/community-templates.
|
||||
`,
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.orgId,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.orgName,
|
||||
},
|
||||
append(commonFlags(), getOrgFlags(¶ms.orgParams)...),
|
||||
&cli.StringFlag{
|
||||
Name: "stack-id",
|
||||
Usage: "Stack ID to associate with template application",
|
||||
@ -167,8 +155,7 @@ https://github.com/influxdata/community-templates.
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
parsedParams := apply.Params{
|
||||
OrgId: params.orgId,
|
||||
OrgName: params.orgName,
|
||||
OrgParams: params.orgParams,
|
||||
StackId: params.stackId,
|
||||
Recursive: params.recursive,
|
||||
Quiet: params.quiet,
|
||||
|
@ -26,19 +26,7 @@ Examples:
|
||||
ArgsUsage: "path",
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Flags: append(
|
||||
commonFlagsNoPrint(),
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.Org,
|
||||
},
|
||||
append(commonFlagsNoPrint(), getOrgFlags(¶ms.OrgParams)...),
|
||||
&cli.StringFlag{
|
||||
Name: "bucket-id",
|
||||
Usage: "The ID of the bucket to backup",
|
||||
@ -47,7 +35,7 @@ Examples:
|
||||
&cli.StringFlag{
|
||||
Name: "bucket, b",
|
||||
Usage: "The name of the bucket to backup",
|
||||
Destination: ¶ms.Bucket,
|
||||
Destination: ¶ms.BucketName,
|
||||
},
|
||||
&cli.GenericFlag{
|
||||
Name: "compression",
|
||||
|
@ -30,7 +30,7 @@ func newBucketCreateCmd() cli.Command {
|
||||
Usage: "Create bucket",
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
append(commonFlags(), getOrgFlags(¶ms.OrgParams)...),
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
Usage: "New bucket name",
|
||||
@ -53,18 +53,6 @@ func newBucketCreateCmd() cli.Command {
|
||||
Usage: "Shard group duration used internally by the storage engine",
|
||||
Destination: ¶ms.ShardGroupDuration,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.GenericFlag{
|
||||
Name: "schema-type",
|
||||
Usage: "The schema type (implicit, explicit)",
|
||||
@ -90,28 +78,16 @@ func newBucketDeleteCmd() cli.Command {
|
||||
Usage: "Delete bucket",
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
append(commonFlags(), getOrgFlags(¶ms.OrgParams)...),
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The bucket ID, required if name isn't provided",
|
||||
Destination: ¶ms.ID,
|
||||
Destination: ¶ms.BucketID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
Usage: "The bucket name, org or org-id will be required by choosing this",
|
||||
Destination: ¶ms.Name,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
Destination: ¶ms.BucketName,
|
||||
},
|
||||
),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
@ -134,28 +110,16 @@ func newBucketListCmd() cli.Command {
|
||||
Aliases: []string{"find", "ls"},
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
append(commonFlags(), getOrgFlags(¶ms.OrgParams)...),
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The bucket ID, required if name isn't provided",
|
||||
Destination: ¶ms.ID,
|
||||
Destination: ¶ms.BucketID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
Usage: "The bucket name, org or org-id will be required by choosing this",
|
||||
Destination: ¶ms.Name,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
Destination: ¶ms.BucketName,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: "limit",
|
||||
@ -199,13 +163,13 @@ func newBucketUpdateCmd() cli.Command {
|
||||
Name: "name, n",
|
||||
Usage: "New name to set on the bucket",
|
||||
EnvVar: "INFLUX_BUCKET_NAME",
|
||||
Destination: ¶ms.Name,
|
||||
Destination: ¶ms.BucketName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The bucket ID",
|
||||
Required: true,
|
||||
Destination: ¶ms.ID,
|
||||
Destination: ¶ms.BucketID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "description, d",
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"github.com/influxdata/influx-cli/v2/clients"
|
||||
"github.com/influxdata/influx-cli/v2/clients/bucket_schema"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/influxid"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@ -102,7 +101,7 @@ func newBucketSchemaCreateCmd() cli.Command {
|
||||
func newBucketSchemaUpdateCmd() cli.Command {
|
||||
var params struct {
|
||||
clients.OrgBucketParams
|
||||
ID influxid.ID
|
||||
ID string
|
||||
Name string
|
||||
ColumnsFile string
|
||||
ColumnsFormat bucket_schema.ColumnsFormat
|
||||
@ -116,10 +115,10 @@ func newBucketSchemaUpdateCmd() cli.Command {
|
||||
commonFlags(),
|
||||
append(
|
||||
getOrgBucketFlags(¶ms.OrgBucketParams),
|
||||
&cli.GenericFlag{
|
||||
Name: "id",
|
||||
Usage: "ID of the measurement",
|
||||
Value: ¶ms.ID,
|
||||
&cli.StringFlag{
|
||||
Name: "id",
|
||||
Usage: "ID of the measurement",
|
||||
Destination: ¶ms.ID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name",
|
||||
@ -147,7 +146,7 @@ func newBucketSchemaUpdateCmd() cli.Command {
|
||||
return getBucketSchemaClient(ctx).
|
||||
Update(getContext(ctx), bucket_schema.UpdateParams{
|
||||
OrgBucketParams: params.OrgBucketParams,
|
||||
ID: params.ID.String(),
|
||||
ID: params.ID,
|
||||
Name: params.Name,
|
||||
Stdin: os.Stdin,
|
||||
ColumnsFile: params.ColumnsFile,
|
||||
|
@ -14,11 +14,11 @@ func newDeleteCmd() cli.Command {
|
||||
Description: "Delete points from InfluxDB, by specify start, end time and a sql like predicate string",
|
||||
Flags: append(
|
||||
commonFlagsNoPrint(),
|
||||
&cli.GenericFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization that owns the bucket",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Value: ¶ms.OrgID,
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization that owns the bucket",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
@ -26,11 +26,11 @@ func newDeleteCmd() cli.Command {
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.GenericFlag{
|
||||
Name: "bucket-id",
|
||||
Usage: "The ID of the bucket to delete from",
|
||||
EnvVar: "INFLUX_BUCKET_ID",
|
||||
Value: ¶ms.BucketID,
|
||||
&cli.StringFlag{
|
||||
Name: "bucket-id",
|
||||
Usage: "The ID of the bucket to delete from",
|
||||
EnvVar: "INFLUX_BUCKET_ID",
|
||||
Destination: ¶ms.BucketID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "bucket, b",
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/influxdata/influx-cli/v2/clients"
|
||||
"github.com/influxdata/influx-cli/v2/clients/export"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/template"
|
||||
@ -252,10 +253,9 @@ https://docs.influxdata.com/influxdb/latest/reference/cli/influx/export/`,
|
||||
|
||||
func newExportAllCmd() cli.Command {
|
||||
var params struct {
|
||||
out string
|
||||
orgId string
|
||||
orgName string
|
||||
filters cli.StringSlice
|
||||
orgParams clients.OrgParams
|
||||
out string
|
||||
filters cli.StringSlice
|
||||
}
|
||||
return cli.Command{
|
||||
Name: "all",
|
||||
@ -293,19 +293,7 @@ and
|
||||
https://docs.influxdata.com/influxdb/latest/reference/cli/influx/export/all/
|
||||
`,
|
||||
Flags: append(
|
||||
commonFlagsNoPrint(),
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.orgId,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.orgName,
|
||||
},
|
||||
append(commonFlagsNoPrint(), getOrgFlags(¶ms.orgParams)...),
|
||||
&cli.StringFlag{
|
||||
Name: "file, f",
|
||||
Usage: "Output file for created template; defaults to std out if no file provided; the extension of provided file (.yml/.json) will dictate encoding",
|
||||
@ -320,8 +308,7 @@ https://docs.influxdata.com/influxdb/latest/reference/cli/influx/export/all/
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
parsedParams := export.AllParams{
|
||||
OrgId: params.orgId,
|
||||
OrgName: params.orgName,
|
||||
OrgParams: params.orgParams,
|
||||
}
|
||||
|
||||
for _, filter := range params.filters.Value() {
|
||||
|
@ -302,11 +302,11 @@ func commonFlags() []cli.Flag {
|
||||
// the flags to the given params container.
|
||||
func getOrgFlags(params *clients.OrgParams) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.GenericFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Value: ¶ms.OrgID,
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
@ -321,10 +321,10 @@ func getOrgFlags(params *clients.OrgParams) []cli.Flag {
|
||||
// the flags to the given params container.
|
||||
func getBucketFlags(params *clients.BucketParams) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.GenericFlag{
|
||||
Name: "bucket-id, i",
|
||||
Usage: "The bucket ID, required if name isn't provided",
|
||||
Value: ¶ms.BucketID,
|
||||
&cli.StringFlag{
|
||||
Name: "bucket-id, i",
|
||||
Usage: "The bucket ID, required if name isn't provided",
|
||||
Destination: ¶ms.BucketID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "bucket, n",
|
||||
|
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"github.com/influxdata/influx-cli/v2/clients/org"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/influxid"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@ -54,18 +53,18 @@ func newOrgCreateCmd() cli.Command {
|
||||
}
|
||||
|
||||
func newOrgDeleteCmd() cli.Command {
|
||||
var id influxid.ID
|
||||
var id string
|
||||
return cli.Command{
|
||||
Name: "delete",
|
||||
Usage: "Delete organization",
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.GenericFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Value: &id,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: &id,
|
||||
},
|
||||
),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
@ -91,13 +90,13 @@ func newOrgListCmd() cli.Command {
|
||||
Name: "name, n",
|
||||
Usage: "The organization name",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.Name,
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.GenericFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Value: ¶ms.ID,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
@ -118,18 +117,18 @@ func newOrgUpdateCmd() cli.Command {
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.GenericFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Required: true,
|
||||
Value: ¶ms.ID,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Required: true,
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
Usage: "New name to set on the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.Name,
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "description, d",
|
||||
|
@ -27,11 +27,11 @@ func newOrgMembersAddCmd() cli.Command {
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: append(
|
||||
commonFlagsNoPrint(),
|
||||
&cli.GenericFlag{
|
||||
Name: "member, m",
|
||||
Usage: "The member ID",
|
||||
Required: true,
|
||||
Value: ¶ms.MemberId,
|
||||
&cli.StringFlag{
|
||||
Name: "member, m",
|
||||
Usage: "The member ID",
|
||||
Required: true,
|
||||
Destination: ¶ms.MemberId,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
@ -39,11 +39,11 @@ func newOrgMembersAddCmd() cli.Command {
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.GenericFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Value: ¶ms.OrgID,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
@ -71,11 +71,11 @@ func newOrgMembersListCmd() cli.Command {
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.GenericFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Value: ¶ms.OrgID,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
@ -97,11 +97,11 @@ func newOrgMembersRemoveCmd() cli.Command {
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: append(
|
||||
commonFlagsNoPrint(),
|
||||
&cli.GenericFlag{
|
||||
Name: "member, m",
|
||||
Usage: "The member ID",
|
||||
Required: true,
|
||||
Value: ¶ms.MemberId,
|
||||
&cli.StringFlag{
|
||||
Name: "member, m",
|
||||
Usage: "The member ID",
|
||||
Required: true,
|
||||
Destination: ¶ms.MemberId,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
@ -109,11 +109,11 @@ func newOrgMembersRemoveCmd() cli.Command {
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.GenericFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Value: ¶ms.OrgID,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The organization ID",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
|
@ -19,19 +19,7 @@ func newQueryCmd() cli.Command {
|
||||
ArgsUsage: "[query literal or '-' for stdin]",
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Flags: append(
|
||||
commonFlagsNoPrint(),
|
||||
&cli.GenericFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Value: &orgParams.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: &orgParams.OrgName,
|
||||
},
|
||||
append(commonFlagsNoPrint(), getOrgFlags(&orgParams)...),
|
||||
&cli.StringFlag{
|
||||
Name: "file, f",
|
||||
Usage: "Path to Flux query file",
|
||||
|
@ -28,7 +28,7 @@ func newRemoteCreateCmd() cli.Command {
|
||||
Usage: "Create a new remote connection",
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
append(commonFlags(), getOrgFlags(¶ms.OrgParams)...),
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
Usage: "Name for the new remote connection",
|
||||
@ -40,18 +40,6 @@ func newRemoteCreateCmd() cli.Command {
|
||||
Usage: "Description for the new remote connection",
|
||||
Destination: ¶ms.Description,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the local organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "remote-url",
|
||||
Usage: "The url for the remote database",
|
||||
|
@ -39,7 +39,7 @@ Examples:
|
||||
Name: "org, o",
|
||||
Usage: "The original name of the organization to restore",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.Org,
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "bucket-id",
|
||||
@ -49,7 +49,7 @@ Examples:
|
||||
&cli.StringFlag{
|
||||
Name: "bucket, b",
|
||||
Usage: "The original name of the bucket to restore",
|
||||
Destination: ¶ms.Bucket,
|
||||
Destination: ¶ms.BucketName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "new-bucket",
|
||||
@ -68,19 +68,19 @@ Examples:
|
||||
}
|
||||
params.Path = ctx.Args().Get(0)
|
||||
|
||||
if params.Full && (params.Org != "" ||
|
||||
if params.Full && (params.OrgName != "" ||
|
||||
params.OrgID != "" ||
|
||||
params.Bucket != "" ||
|
||||
params.BucketName != "" ||
|
||||
params.BucketID != "" ||
|
||||
params.NewOrgName != "" ||
|
||||
params.NewBucketName != "") {
|
||||
return errors.New("--full restore cannot be limited to a single org or bucket")
|
||||
}
|
||||
|
||||
if params.NewOrgName != "" && params.OrgID == "" && params.Org == "" {
|
||||
if params.NewOrgName != "" && params.OrgID == "" && params.OrgName == "" {
|
||||
return errors.New("--org-id or --org must be set to use --new-org")
|
||||
}
|
||||
if params.NewBucketName != "" && params.BucketID == "" && params.Bucket == "" {
|
||||
if params.NewBucketName != "" && params.BucketID == "" && params.BucketName == "" {
|
||||
return errors.New("--bucket-id or --bucket must be set to use --new-bucket")
|
||||
}
|
||||
|
||||
|
@ -38,19 +38,7 @@ For information about Stacks and how they integrate with InfluxDB templates, see
|
||||
https://docs.influxdata.com/influxdb/latest/reference/cli/influx/stacks/`,
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgId,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
append(commonFlags(), getOrgFlags(¶ms.OrgParams)...),
|
||||
&cli.StringSliceFlag{
|
||||
Name: "stack-id",
|
||||
Usage: "Stack ID to filter by",
|
||||
@ -103,19 +91,7 @@ and
|
||||
https://docs.influxdata.com/influxdb/latest/reference/cli/influx/stacks/init/`,
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgId,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
append(commonFlags(), getOrgFlags(¶ms.OrgParams)...),
|
||||
&cli.StringFlag{
|
||||
Name: "stack-name, n",
|
||||
Usage: "Name given to created stack",
|
||||
@ -152,19 +128,7 @@ func newStacksRemoveCmd() cli.Command {
|
||||
Usage: "Remove a stack(s) and all associated resources",
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.OrgId,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
append(commonFlags(), getOrgFlags(¶ms.OrgParams)...),
|
||||
&cli.StringSliceFlag{
|
||||
Name: "stack-id",
|
||||
Usage: "Stack IDs to be removed",
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/influxdata/influx-cli/v2/clients"
|
||||
"github.com/influxdata/influx-cli/v2/clients/template"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||
pkgtmpl "github.com/influxdata/influx-cli/v2/pkg/template"
|
||||
@ -13,28 +14,15 @@ import (
|
||||
)
|
||||
|
||||
type templateParams struct {
|
||||
orgId string
|
||||
orgName string
|
||||
files cli.StringSlice
|
||||
urls cli.StringSlice
|
||||
recurse bool
|
||||
encoding pkgtmpl.Encoding
|
||||
orgParams clients.OrgParams
|
||||
files cli.StringSlice
|
||||
urls cli.StringSlice
|
||||
recurse bool
|
||||
encoding pkgtmpl.Encoding
|
||||
}
|
||||
|
||||
func templateFlags(params *templateParams) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: ¶ms.orgId,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.orgName,
|
||||
},
|
||||
return append(getOrgFlags(¶ms.orgParams), []cli.Flag{
|
||||
&cli.StringSliceFlag{
|
||||
Name: "file, f",
|
||||
Usage: "Path to template file; Supports file paths or (deprecated) HTTP(S) URLs",
|
||||
@ -56,7 +44,7 @@ func templateFlags(params *templateParams) []cli.Flag {
|
||||
Usage: "Encoding for the input stream. If a file is provided will gather encoding type from file extension. If extension provided will override.",
|
||||
Value: ¶ms.encoding,
|
||||
},
|
||||
}
|
||||
}...)
|
||||
}
|
||||
|
||||
func (params templateParams) parseSources() ([]pkgtmpl.Source, error) {
|
||||
@ -121,8 +109,7 @@ func newTemplateCmd() cli.Command {
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
parsedParams := template.SummarizeParams{
|
||||
OrgId: params.orgId,
|
||||
OrgName: params.orgName,
|
||||
OrgParams: params.orgParams,
|
||||
RenderTableColors: !params.noColor,
|
||||
RenderTableBorders: !params.noTableBorders,
|
||||
}
|
||||
@ -152,8 +139,7 @@ func newTemplateValidateCmd() cli.Command {
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
parsedParams := template.ValidateParams{
|
||||
OrgId: params.orgId,
|
||||
OrgName: params.orgName,
|
||||
OrgParams: params.orgParams,
|
||||
}
|
||||
sources, err := params.parseSources()
|
||||
if err != nil {
|
||||
|
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"github.com/influxdata/influx-cli/v2/clients/user"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
|
||||
"github.com/influxdata/influx-cli/v2/pkg/influxid"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@ -28,19 +27,7 @@ func newUserCreateCmd() cli.Command {
|
||||
Name: "create",
|
||||
Usage: "Create user",
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.GenericFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Value: ¶ms.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: ¶ms.OrgName,
|
||||
},
|
||||
append(commonFlags(), getOrgFlags(¶ms.OrgParams)...),
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
Usage: "The user name",
|
||||
@ -68,17 +55,17 @@ func newUserCreateCmd() cli.Command {
|
||||
}
|
||||
|
||||
func newUserDeleteCmd() cli.Command {
|
||||
var id influxid.ID
|
||||
var id string
|
||||
return cli.Command{
|
||||
Name: "delete",
|
||||
Usage: "Delete user",
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.GenericFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Required: true,
|
||||
Value: &id,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Required: true,
|
||||
Destination: &id,
|
||||
},
|
||||
),
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
@ -97,10 +84,10 @@ func newUserListCmd() cli.Command {
|
||||
Usage: "List users",
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.GenericFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Value: ¶ms.Id,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Destination: ¶ms.Id,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
@ -117,16 +104,16 @@ func newUserListCmd() cli.Command {
|
||||
}
|
||||
|
||||
func newUserUpdateCmd() cli.Command {
|
||||
var params user.UpdateParmas
|
||||
var params user.UpdateParams
|
||||
return cli.Command{
|
||||
Name: "update",
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.GenericFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Required: true,
|
||||
Value: ¶ms.Id,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Required: true,
|
||||
Destination: ¶ms.Id,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
@ -148,10 +135,10 @@ func newUserSetPasswordCmd() cli.Command {
|
||||
Name: "password",
|
||||
Flags: append(
|
||||
commonFlagsNoPrint(),
|
||||
&cli.GenericFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Value: ¶ms.Id,
|
||||
&cli.StringFlag{
|
||||
Name: "id, i",
|
||||
Usage: "The user ID",
|
||||
Destination: ¶ms.Id,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "name, n",
|
||||
|
@ -10,10 +10,10 @@ import (
|
||||
// and can specify to require one but not both.
|
||||
func getAuthLookupFlags(params *v1_auth.AuthLookupParams) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.GenericFlag{
|
||||
Name: "id",
|
||||
Usage: "The ID of the authorization",
|
||||
Value: ¶ms.ID,
|
||||
&cli.StringFlag{
|
||||
Name: "id",
|
||||
Usage: "The ID of the authorization",
|
||||
Destination: ¶ms.ID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "username",
|
||||
|
@ -64,7 +64,7 @@ func (p *writeParams) makeErrorFile() (*os.File, error) {
|
||||
}
|
||||
|
||||
func (p *writeParams) Flags() []cli.Flag {
|
||||
return []cli.Flag{
|
||||
return append(getOrgFlags(&p.OrgParams), []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "bucket-id",
|
||||
Usage: "The ID of destination bucket",
|
||||
@ -77,18 +77,6 @@ func (p *writeParams) Flags() []cli.Flag {
|
||||
EnvVar: "INFLUX_BUCKET_NAME",
|
||||
Destination: &p.BucketName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org-id",
|
||||
Usage: "The ID of the organization",
|
||||
EnvVar: "INFLUX_ORG_ID",
|
||||
Destination: &p.OrgID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "org, o",
|
||||
Usage: "The name of the organization",
|
||||
EnvVar: "INFLUX_ORG",
|
||||
Destination: &p.OrgName,
|
||||
},
|
||||
&cli.GenericFlag{
|
||||
Name: "precision, p",
|
||||
Usage: "Precision of the timestamps of the lines",
|
||||
@ -167,7 +155,7 @@ func (p *writeParams) Flags() []cli.Flag {
|
||||
Usage: "Input compression, either 'none' or 'gzip'",
|
||||
Value: &p.Compression,
|
||||
},
|
||||
}
|
||||
}...)
|
||||
}
|
||||
|
||||
func newWriteCmd() cli.Command {
|
||||
|
Reference in New Issue
Block a user