
This commit represents a few experiments of features I've used in Cobra 1. Uses cli.GenericFlag to encapsulate parsing and validation of flag values at parse time. This removes the burden from the individual CLI commands to parse and validate args and options. 2. Add influxid.ID that may be used by any flag that requires an Influx ID. influxid.ID parses and validates string value is a valid ID, removing this burden from individual commands and ensuring valid values before the command actions begins. 3. Binds cli.Flags directly to params structures to directly capture the values when parsing flags. 4. Moves from global state to local builder functions for the majority of the commands. This allows the commands to bind to flag variables reducing the repeated ctx.String(), ctx.Int(), etc 5. Leverages the BeforeFunc to create middleware and inject the CLI and API client into commands, saving the repeated boilerplate across all of the instantiated commands. This is extensible, so additional middleware can be appends using the middleware.WithBeforeFns
influx-cli
CLI for managing resources in InfluxDB v2
Status
This is a work-in-progress effort to decouple the influx
CLI from the OSS influxdb
codebase.
Our goals are to:
- Make it easier to keep the CLI up-to-date with InfluxDB Cloud API changes
- Enable faster turn-around on fixes/features that only affect the CLI
- Allow the CLI to be built & released for a wider range of platforms than the server can support
Building
Run make
to build the CLI. The output binary will be written to bin/$(GOOS)/influx
.
Regenerating OpenAPI client
We use OpenAPITools/openapi-generator
to generate
the underlying HTTP client used by the CLI. Run make openapi
to re-generate the code. You'll need Docker
running locally for the script to work.
Testing
Run make test
to run unit tests.
Description
Languages
Go
92%
Mustache
6.1%
Shell
1.6%
Makefile
0.3%