These changes re-work some of the authentication logic used to pass the API key when executing commands. Before this, ALL commands authenticated with this key, even the version command. This PR moves the client logic to allow setting a basic HTTP client without bearer tokens. It also moves the missing API key check so that it happens in a pre-Execute check on each top-level command. This check cascades down to all of its children.
Related Issues
closes #359
332
92
Testing
Open a new shell and do not export VULTR_API_KEY
Test these commands:
[x] go run main.go account
[x] go run main.go backups list
[x] go run main.go bare-metal list
[x] go run main.go billing history list
[x] go run main.go block-storage list
[x] go run main.go database list
[x] go run main.go dns domain list
[x] go run main.go firewall group list
[x] go run main.go instance list
[x] go run main.go iso list
[x] go run main.go kubernetes list
[x] go run main.go load-balancer list
[x] go run main.go network list
[x] go run main.go object-storage list
[x] go run main.go reserved-ip list
[x] go run main.go script list
[x] go run main.go snapshot list
[x] go run main.go ssh list
[x] go run main.go user list
[x] go run main.go vpc list
[x] go run main.go vpc2 list
All of which should show something along the lines of:
Error:
Please export your VULTR API key as an environment variable or add 'api-key' to your config file, eg:
export VULTR_API_KEY='<api_key_from_vultr_account>'
Usage:
vultr-cli database list [flags]
Aliases:
list, l
Examples:
# Full example
vultr-cli database list
# Summarized view
vultr-cli database list --summarize
Flags:
-h, --help help for list
-l, --label string (optional) Filter by label.
-r, --region string (optional) Filter by region.
--summarize (optional) Summarize the list output. One line per database.
-t, --tag string (optional) Filter by tag.
Global Flags:
--config string config file (default is $HOME/.vultr-cli.yaml) (default "/home/michael/.vultr-cli.yaml")
exit status 1
Conversely, these should still return data:
[x] go run main.go plans list
[x] go run main.go application list
[x] go run main.go os list
[x] go run main.go version
Checklist:
[x] Have you checked to ensure there aren't other open Pull Requests for the same update/change?
[x] Have you linted your code locally prior to submission?
[x] Have you successfully ran tests with your changes locally?
Description
These changes re-work some of the authentication logic used to pass the API key when executing commands. Before this, ALL commands authenticated with this key, even the
version
command. This PR moves the client logic to allow setting a basic HTTP client without bearer tokens. It also moves the missing API key check so that it happens in a pre-Execute
check on each top-level command. This check cascades down to all of its children.Related Issues
closes #359
332
92
Testing
Open a new shell and do not
export VULTR_API_KEY
Test these commands:
[x]
go run main.go account
[x]
go run main.go backups list
[x]
go run main.go bare-metal list
[x]
go run main.go billing history list
[x]
go run main.go block-storage list
[x]
go run main.go database list
[x]
go run main.go dns domain list
[x]
go run main.go firewall group list
[x]
go run main.go instance list
[x]
go run main.go iso list
[x]
go run main.go kubernetes list
[x]
go run main.go load-balancer list
[x]
go run main.go network list
[x]
go run main.go object-storage list
[x]
go run main.go reserved-ip list
[x]
go run main.go script list
[x]
go run main.go snapshot list
[x]
go run main.go ssh list
[x]
go run main.go user list
[x]
go run main.go vpc list
[x]
go run main.go vpc2 list
All of which should show something along the lines of:
Conversely, these should still return data:
go run main.go plans list
go run main.go application list
go run main.go os list
go run main.go version
Checklist: