Code Monkey home page Code Monkey logo

influx-cli's Introduction

influx-cli

CLI for managing resources in InfluxDB v2

Motivation

This repository decouples the influx CLI from the OSS influxdb codebase. Our goals are to:

  1. Make it easier to keep the CLI up-to-date with InfluxDB Cloud API changes
  2. Enable faster turn-around on fixes/features that only affect the CLI
  3. Allow the CLI to be built & released for a wider range of platforms than the server can support

Building the CLI

Follow these steps to build the CLI. If you're updating your CLI build, see Updating openapi below.

  1. Clone this repo (influx-cli) and change to your influx-cli directory.

    git clone [email protected]:influxdata/influx-cli.git
    cd influx-cli
    
  2. Build the CLI. The make and make influx commands write the new binary to bin/$(GOOS)/influx.

    make
    

Updating openapi

If you change or update your branch, you may also need to update influx-cli/openapi and regenerate the client code. influx-cli/openapi is a Git submodule that contains the underlying API contracts and client used by the CLI. We use OpenAPITools/openapi-generator to generate the HTTP client.

To update, run the following commands in your influx-cli repo:

  1. Update the openapi Git submodule. The following command pulls the latest commits for the branch and all submodules.

    git pull --recurse-submodules

  2. With Docker running locally, regenerate openapi.

    make openapi

  3. Rebuild the CLI

    make

Running the CLI

After building, use influx -h to see the list of available commands.

Enabling Completions

The CLI supports generating completions for bash, zsh, and powershell. To enable completions for a single shell session, run one of these commands:

# For bash:
source <(influx completion bash)
# For zsh:
source <(influx completion zsh)
# For pwsh:
Invoke-Expression ((influx completion powershell) -join "`n`")

To enable completions across sessions, add the appropriate line to your shell's login profile (i.e. ~/.bash_profile).

Testing

Run make test to run unit tests.

influx-cli's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

influx-cli's Issues

Port the `delete` command tree from `influxdb`

Port the delete command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

`influx dashboards` doesn't work when `--org` is specified

Steps to reproduce:

  1. Initialize an influxdb OSS instance locally (I use OS X), create an organization and a bucket. For my case, I did the initialization using the http://localhost:9999 UI.
  2. While the OSS is running, try to access the database using influx repl command:
➜  influxdb git:(master) influx repl -o "my-org"
Error: Unable to find organization: organization not found.
  1. Go to the web UI, find the organization Id for "my-org", try again access the database by using the organization id:
➜  influxdb git:(master) influx repl --org-id 047e8606a2268000
>

This works.

Expected behavior:
The -o flag with the organization name should work the same as the organization id.

Actual behavior:
Only organization id works.

Environment info:

  • System info: Run uname -srm and copy the output here
    Darwin 19.0.0 x86_64
  • InfluxDB version: Run influxd version and copy the output here
    2.0.0 (cde064b)
    Note: influxd version does not work:
➜  influxdb git:(master) influxd version
Error: unknown command "version" for "influxd"
Run 'influxd --help' for usage.

CLI: list members of an org shows nil

After creating a new user for an organization influx user create -o influxdata -u new_russ -p something and then listing the members of the org, i see a <nil> displayed in the username, even though it is returned when i print as json.

➜  influxdb git:(master) ✗ ./bin/darwin/influx org members list -n influxdata
ID			Name	User Type	Status
0673b0f2e540a000	<nil>	member		active
➜  influxdb git:(master) ✗
➜  influxdb git:(master) ✗ ./bin/darwin/influx org members list -n influxdata --json
[
	{
		"id": "0673b0f2e540a000",
		"name": "new_russ",
		"status": "active"
	}
]

might be related to something here: https://github.com/influxdata/influxdb/blob/master/cmd/influx/organization.go#L606

influx CLI remote completions

Proposal:
Like to add the ability to use an existing profile to pull remote data for autocompletion in the shell.

Example:

influx bucket ls --id=
foo_bucket      FOO_BUCKET_ID       Description of foo bucket
bar_bucket      BAR_BUCKET_ID       Description of bar bucket

and user can tab complete to select the bucket they are interested in and the id/name/field is filled in by the autocompletions

Current behavior:
manually have to copy pasta data into the shell

Desired behavior:
I want choices provided for me

Alternatives considered:
leave it be

Use case:
Dramatically improves the usability of the influx cli tool

Port the `bucket` command tree from `influxdb`

Port the bucket command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Port the `completion` command from `influxdb`

Port the completion command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Port the `template` command tree from `influxdb`

Port the template command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Fixup `influx` CLI config create/update command

the current API looks as follows
$ influx config create 
--active        -a  -- Set it to be the active config
--help          -h  -- Help for the create command
--hide-headers      -- Hide the table headers; defaults false; Maps to env var $INFLUX_HIDE_HEADERS
--host              -- HTTP address of Influx; Maps to env var $INFLUX_HOST
--json              -- Output data as json; defaults false; Maps to env var $INFLUX_OUTPUT_JSON
--local             -- Run commands locally against the filesystem
--name          -n  -- The config name (required)
--org           -o  -- The optional organization name
--skip-verify       -- SkipVerify controls whether a client verifies the server's certificate chain and host name.
--token         -t  -- API token to be used throughout client calls; Maps to env var $INFLUX_TOKEN
--url           -u  -- The config url (required)
updated CLI
$ influx config create 
--active        -a  -- Set it to be the active config
--help          -h  -- Help for the create command
--hide-headers      -- Hide the table headers; defaults false; Maps to env var $INFLUX_HIDE_HEADERS
--json              -- Output data as json; defaults false; Maps to env var $INFLUX_OUTPUT_JSON
--config-name          -n  -- The config name (required)
--config-org           -o  -- The optional organization name
--config-token          -- API token to be used throughout client calls; Maps to env var $INFLUX_TOKEN
--config-host-address          -u  -- The config url (required)

AC

  • flag names and descriptions updated to match details above

Port the `dashboards` command tree from `influxdb`

Port the dashboards command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Port the `secret` command tree from `influxdb`

Port the secret command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Influx CLI should output results in CSV and JSON like 1.X

Proposal:
Using the influx command line tool, the output format should be in csv or json as well as the default.

This exists with older version of ./influx and should be in the new version. When using curl, the data comes back as csv, but not from the CLI.

Current behavior:

using this from the command line:
MBP15-KCURTIS:influx kcurtis$ ./influx query 'from(bucket:"scrap")|>range(start:-5s)|>yield()' -o kmc
Result: _result
Table: keys: [_start, _stop, _field, _measurement, tag1]
_start:time _stop:time _field:string _measurement:string tag1:string _time:time _value:float


2019-12-17T22:29:28.169521000Z 2019-12-17T22:29:33.169521000Z f1 kr

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------needs to be in csv
Use case:
Why is this important (helps with prioritizing requests)?
As an Analyst, I need the data to be easily opened in standard analysis tools (excel, google sheets, etc) so that I can work with the data in standard tools

Port the `task` command tree from `influxdb`

Port the task command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

`influx apply --json` outputs invalid JSON

When running influx apply -f $FILENAME --force true --json, the output to stdout is not parseable as JSON

Steps to reproduce:
List the minimal actions needed to reproduce the behavior.

  1. Create a minimal template, eg. example.yaml:
apiVersion: influxdata.com/v2alpha1
kind: Label
metadata:
    name: foo-bar-ab9001
spec:
    color: '#066fc5'
    name: some_label
  1. Run influx apply -f example.yaml --force true --json
  2. Observe that the output is not, strictly speaking, valid JSON

Specifically, the output is the concatenation of two bits of text that are each individually valid JSON documents, but, you cannot simply concatenate JSON documents and still have valid JSON; for example, {} is a valid JSON document, but {}{} is not.

Expected behavior:
Using the --json flag results in output that can be parsed by a JSON parsing library

Actual behavior:
You get output that isn't valid JSON such as the following:

{
        "buckets": [],
        "checks": [],
        "dashboards": [],
        "labels": [
                {
                        "id": 0,
                        "stateStatus": "new",
                        "templateMetaName": "foo-bar-ab9001",
                        "kind": "Label",
                        "new": {
                                "name": "some_label",
                                "color": "#066fc5",
                                "description": ""
                        },
                        "old": null
                }
        ],
        "labelMappings": [],
        "notificationEndpoints": [],
        "notificationRules": [],
        "tasks": [],
        "telegrafConfigs": [],
        "variables": []
}
{
        "stackID": "06c65a42a111b000",
        "Summary": {
                "buckets": [],
                "checks": [],
                "dashboards": [],
                "notificationEndpoints": [],
                "notificationRules": [],
                "labels": [
                        {
                                "kind": "Label",
                                "templateMetaName": "foo-bar-ab9001",
                                "envReferences": [],
                                "id": 488176851853881344,
                                "orgID": 346504372515078680,
                                "name": "some_label",
                                "properties": {
                                        "color": "#066fc5",
                                        "description": ""
                                }
                        }
                ],
                "labelMappings": [],
                "missingEnvRefs": [],
                "missingSecrets": [],
                "summaryTask": [],
                "telegrafConfigs": [],
                "variables": []
        }
}

Environment info:
InfluxDB Cloud 2.0
CLI tools version: Influx CLI 2.0.3 (git: fe04d346df) build_date: 2020-12-15T01:00:16Z

Bootstrap the project

Make it possible to develop in this repo using our usual flow.

  • Set up go modules
  • Pick a CLI library to use for now, and make the program entry-point with it
  • Add enough build/test harness for CI to run

Port the `config` command tree from `influxdb`

Port the config command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Failure during `influx setup` can leave system in an inconsistent state

influx setup isn't idempotent: if it fails after the CLI sends an onboarding request to the server, subsequent runs will fail with an "instance has already been set up" error.

The only thing the CLI does after the onboarding request is write a config file. We could potentially log/print the config contents on error (though it includes an auth token, so that could be a security risk).

Port the `write` command tree from `influxdb`

Port the write command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

[v2.0] improve "influx template"

Steps to reproduce:

  1. Run "influx template"

Expected behavior:
See 'influx template -h' for help

Actual behavior:
Nothing is returned

Environment info:
Influx CLI 2.0.1 (git: 37cc047133) build_date: 2020-11-11T03:53:31Z

CLI does not paginate resources

The CLI communicates to influx over the HTTP API, which by default has a limit of 100 for all resources and offers pagination to get more results.

This isn't properly being taken into account in the CLI, and therefore it's impossible to show results past the first 100.

AC: As a user, I should see all results when entering a command like influx buckets list.

cli: influx auths list doesn't work for cloud

As a user, i would expect to see the list of tokens in my cloud2 account.

➜  influxdb git:(master) ✗ influx bucket list
ID			Name		Retention	Organization ID
c687a55297399f56	demo		0s		03921cbebef90000
8e0cc79097d0afb5	integral	0s		03921cbebef90000
d5c18759d2df7021	seattle		0s		03921cbebef90000
05e5d14466ae5000	smiley		0s		03921cbebef90000
33b8e2b88bbe557c	telegraf	0s		03921cbebef90000
4b64018436a7cdf1	test		0s		03921cbebef90000
05e35c6cb8250000	time_bucket	720h0m0s	03921cbebef90000
000000000000000a	_tasks		72h0m0s
000000000000000b	_monitoring	168h0m0s
➜  influxdb git:(master) ✗ influx config
Active	Name	URL						Org
*	uswest	https://us-west-2-1.aws.cloud2.influxdata.com	russ+cloud2's organization
➜  influxdb git:(master) ✗ influx bucket list
ID			Name		Retention	Organization ID
c687a55297399f56	demo		0s		03921cbebef90000
8e0cc79097d0afb5	integral	0s		03921cbebef90000
d5c18759d2df7021	seattle		0s		03921cbebef90000
05e5d14466ae5000	smiley		0s		03921cbebef90000
33b8e2b88bbe557c	telegraf	0s		03921cbebef90000
4b64018436a7cdf1	test		0s		03921cbebef90000
05e35c6cb8250000	time_bucket	720h0m0s	03921cbebef90000
000000000000000a	_tasks		72h0m0s
000000000000000b	_monitoring	168h0m0s
➜  influxdb git:(master) ✗ influx auth list
ID	Description	Token	User Name	User ID	Permissions
							[]

Port the `restore` command tree from `influxdb`

Port the restore command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

NOTE: Use the new API design from influxdata/openapi#97

Port the `apply` command tree from `influxdb`

Port the apply command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Port the `setup` command tree from `infludb`

Port the setup command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Port the `export` command tree from `influxdb`

Port the export command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

CLI: Improve error messaging when an unexpected response comes back

Sometimes, there are apis that work in OSS but not in cloud. the CLI seems to do a poor job in detecting response codes and providing a good error message. This issue is to improve that parsing and error messaging.

Here's an example:

[techops@t410 influxdb2-client-2.0.4-linux-amd64]$ ./influx v1 auth list --host https://us-west-2-1.aws.cloud2.influxdata.com --org-id xxxxxxxxxx --token (all access token)
Error: Invalid character '<' looking for beginning of value.
See 'influx v1 auth list -h' for help

Port the `auth` command tree from `influxdb`

Port the auth command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Make creating configurations easier

Proposal:
Make the influx config create command interactive for parameters not passed as flags

Current behavior:
You must pass all config parameters as command line arguments, which requires knowing what arguments you need

Desired behavior:
A user should be able to run influx config create alone and be promoted to input each config parameter.

Alternatives considered:
You could allow a mix of command line arguments and interactivity, only prompting for what wasn't passed on the CLI.

You could also check for environment variables to use as default options in the interactive mode.

Use case:
Using configurations is the new recommended way to use the influxdb CLI, but the process for creating them is not clear or intuitive, which will leave new users feeling confused by InfluxDB and having an undesirably high "time to awesome"

Port the `v1 auth` command tree from `influxdb`

Port the v1 auth command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Port the `backup` command tree from `influxdb`

Port the backup command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

NOTE: Use the new API design from influxdata/openapi#96

Port the `telegrafs` command tree from `influxdb`

Port the telegrafs command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Port the `v1 dbrp` command tree from `influxdb`

Port the v1 dbrp command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Port the `query` command tree from `influxdb`

Port the query command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Port the `stacks` command tree from `influxdb`

Port the stacks command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

influx v1 auth create - ERROR

Hello
I am trying to create a configuration to connect to Kapacitor using "influx v1 auth create" but I am getting an error:

ts=2021-03-16T10:38:53.617340Z lvl=error msg="api error encountered" log_id=0SveeFdW000 error="authorization not found"

The script which adds a docker container (located in the docker-entrypoint-initdb.d folder) during creation:

influx v1 auth create \
 --username ${DOCKER_INFLUXDB_INIT_USERNAME} \
 --read-bucket ${DOCKER_INFLUXDB_INIT_BUCKET_ID} \
 --write-bucket ${DOCKER_INFLUXDB_INIT_BUCKET_ID} \
 --password ${DOCKER_INFLUXDB_INIT_PASSWORD} \
 --token ${DOCKER_INFLUXDB_INIT_ADMIN_TOKEN} \
 --org ${DOCKER_INFLUXDB_INIT_ORG} 

Add ability to generate All Access tokens from the CLI

Proposal:
Add the ability to create All Access tokens from the influx CLI.

Current behavior:
Currently to grant all permissions on a token, you have to pass all the permission flags when creating the token. But even still, these tokens appear to behave differently than an All Access token created through the InfluxDB UI (you can't export a template using one of these CLI-generated tokens).

Desired behavior:
A single flag on influx auth create that generates an All Access token:

influx auth create --all-access

Alternatives considered:

  • Passing all permissions when creating a token through the CLI.

Use case:
Ease of use when managing tokens from the command line.

Use --errors-file for more than just CSV conversion errors in `influx write`

Proposal:
influx write should support recording more than just CSV->LP conversion errors.

Current behavior:
Only CSV->LP conversion errors are written to the location pointed to by --errors-file. Other errors are printed to console, but not persisted to file.

Desired behavior:
All errors encountered during writes are written to the errors-file, along with the source line that caused the problem.

Use case:
Help support efficiently debug & fix up bad lines during bulk data migrations

influx cli: write command cannot handle large files

tried to load a 5GB file into my influxdb instance and it keeps failing:

➜  influxdb git:(master) ✗ ls -lh ~/influxdb-data
-rw-r--r--  1 rsavage  staff   5.1G May 11 13:14 ./influxdb-data
➜  influxdb git:(master) ✗ time ./bin/darwin/influx write -b benchmark -f ~/influxdb-data
Error: Failed to write data: Post "http://localhost:9999/api/v2/write?bucket=c68f4b658e3087c6&org=05ad7794c3047000&precision=ns": dial tcp: lookup localhost: no such host.
See 'influx write -h' for help
./bin/darwin/influx write -b benchmark -f   5.02s user 1.61s system 9% cpu 1:12.25 total

UX improvements for influx write

Proposal:
To support large data imports, influx write should have the following improvements:

  • Error handling - failing lines are written out to a log file with the error message, for easy correction and re-importation
  • Error threshold - an import will halt when it reaches a given error-threshold
  • Restart-ability - record its progress through each file and record when it failed or was halted
  • Progress reporting - report on the status of import periodically, with lines imported, lines failed, est. percentage completion, etc.
  • Handles compressed files - compressed line protocol or CSV files should be able to be read
  • Respond to standard HTTP errors to throttle uploads dynamically

Use case:
These features will make importing very large data sets into Influx much simpler and more robust, helping new customers on-board with less pain.

Port the `user` command tree from `influxdb`

Port the user command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Add ARM64 to CI

We want to ensure the new influx CLI works on linux/arm64 hosts. Add build/test jobs for ARM64 to our Circle workflow. Circle offers support for ARM machine executors that might be useful here.

influx cli: cannot create auth: Error: Id must have a length of 16 bytes.

➜  influxdb git:(add-docker) ✗ ./bin/darwin/influx auth create --write-bucket node_metrics_v1
Error: Id must have a length of 16 bytes.
See 'influx auth create -h' for help

Looks like this only happens if use the wrong command line flag. the following works fine (write-bucketS):

./bin/darwin/influx auth create --write-buckets node_metrics_v1

Reorganize the hierarchy of the CLI to be more action oriented

$ influx get buckets
$ influx export
$ influx apply pkg
$ influx config ...

instead of having the rest hierarchy we have now, we orient it around the action users want to take. I think it supports what you are after more so than cobbling it together in its current shape.

@jsteenb2 can add additional details here.

additional details from @jsteenb2:

Influx CLI proposal

This proposal is advocating for action/verb oriented commands.
At the time of writing this, the CLI is more or less a mirror of the resource heirarchy of the REST API.
I am submitting that we can change up this workflow in the CLI, to minimize command bloat, standardize inputs/outputs, and make it simpler to extend the CLI to support additional features.
In addition, we can support the existing CLI while we transition, but while we are in beta, we can deprecate these and sunset them early in the v2 GA release cycle, if not before.

New Commands

influx list cmd
influx list|ls [resource command] [--name --id]

Both --json and --hide-headers flags are still supported in addition to the --token, --host and org flags.

The list command will have the following subcommands:

influx list buckets

influx list labels

influx list organizations|orgs

influx list secrets

influx list tasks

influx list telegrafs

influx list authorizations|auth

API for list command does not limit how many filters you can use.
The API should allow the user to filter single record or all of them.
Follows same output mechanics with table/json out.

influx list buckets --name=Name1 --name=Name2 --id=ID1 --id=ID2

The CLI should also extend list commands to support args where we inspect the arg to see if it is a valid ID.
If arg is a valid ID then uses it to filter results.
If it is not then the arg is assumed a name and uses it to filter results.
If both args and flags are used, then the CLI should work all the same.

influx list buckets Name1 Name2 ID1 ID2

If no args or flags are provided, then the list command returns all entities.
Paginating as needed, while writing to stdout after each page.

influx list buckets
influx apply command
influx apply [resource command] [pkg flags]

The influx apply command and all its sub commands take piped inputs in the form of a package.

The base command is equivalent to the influx pkg command.

influx apply --file PATH_TO_PKG --url URL_TO_PKG ... other flags

The available sub commands are:

influx apply bucket

influx apply label

influx apply organization|org

influx apply pkg

influx apply secret

influx apply task

influx apply telegraf

influx apply authorization|auth

For all resource sub commands they can provide input via flags for creating or updating a resource.
When an id is provided, the command will update the existing resource identified by its ID and will update it to the specification provided.

# apply and create a bucket from pkg via piped input
cat pkg.yml | influx apply bucket

# apply and create a bucket via file input
influx apply bucket --file PATH_TO_PKG

# apply and create a new bucket via flags
influx apply bucket --name BUCKET_NAME --retention-period 24h

# apply and update existing bucket via flags
influx apply bucket --id BUCKET_ID --name BUCKET_NAME --retention-period 24h  

When providing a pkg, that has more than just buckets in it, the pkg will apply all buckets from that package and any associations outlined in it (aka labels).

influx remove command
influx remove|rm [resource command] [--force]

Available resource sub commands:

influx remove authorization|auth

influx remove bucket

influx remove label

influx remove organization|org

influx remove secret

influx remove stack

influx remove task

influx remove telegraf

Each sub command should support taking args via flags and or arguments.

# remove by --id flag
influx remove bucket --id $BUCKET_ID

# remove by --name flag
influx remove bucket --name $BUCKET_NAME

# remove by input arg being ID
influx remove bucket $BUCKET_ID 

# remove by input arg of bucket name
influx remove bucket $BUCKET_NAME

# mix of names, ids, flags
# this sample removes up to 4 buckets if names and ids are all unique
influx remove bucket \
    --id $BUCKET_ID_1 \
    --name $BUCKET_NAME_1 \
    $BUCKET_ID_2 $BUCKET_NAME_2

All remove commands should ask for confirmation if the --force flag is not provided

influx export command

The export command is used to export existing resources in the form of a package.

influx export [command] [existing flags]

Export has the following sub command(s):

influx export all [existing flags]

# potential sub commands by resource (if desired)
influx export buckets

influx export checks

influx export dashboards

influx export endpoints

influx export labels

influx export tasks

influx export telegraf-configs|telegrafs

influx export variables
influx convert command

The convert command takes a raw input and turns it into a package.
The first example would be to convert a telegraf configuration into a package.
Other examples like converting non-influx v2 platform resources (v1 -> v2 resources, grafana dashboards -> v2 dashboards, etc).

Existing commands which are all action/verb based which will remain unchanged

influx CLI specific commands

influx completion

influx config

influxd ping

influx ping

query commands

influx query

influx repl

influx transpile

setup command

influx setup

write commands

influx backup

influx delete

influx write

Port the `org` command tree from `influxdb`

Port the org command (and any subcommands) from the influxdb repo.

  • Replace the use of any hand-rolled HTTP clients with code-generated clients
  • Interesting business logic should "live" outside of the cmd/ module
  • Tests should also be ported / extended as part of this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.