Build status | Relase version | License |
---|---|---|
Component | Coverage | Bugs | Maintainability Rating | Go Report |
---|---|---|---|---|
KLI |
This repo contains a CLI to access, query and manage KAI servers.
Go to release page and download the binary you prefer.
brew install konstellation-io/tap/kli
Scoop installation is made via a Konstellation owned bucket.
scoop bucket add konstellation-io https://github.com/konstellation-io/scoop-bucket.git
scoop install konstellation-io/kli
Fetch the script and execute it locally.
$ curl -fsSL -o get_kli.sh https://raw.githubusercontent.com/konstellation-io/kai-kli/main/scripts/get-kli.sh
$ chmod 700 get_kli.sh
$ ./get_kli.sh
Use it with --help
flag to get a list of options.
./get_kli.sh --help
- gomock a mock library.
- spf13/cobra used as CLI framework.
- joho/godotenv used to parse env files.
- golangci-lint as linters runner.
You can compile the binary with this command:
./scripts/generate_release.sh <version> <executable_name>
Then run any command:
./kli help
# Output:
Use Konstellation API from the command line.
Usage:
kli [command]
Available Commands:
kai Manage KAI
server Manage servers for kli
Flags:
-h, --help help for kli
Use "kli [command] --help" for more information about a command.
Example:
./kli server ls
# Output
SERVER URL
local* http://api.kai.local
int https://api.your-domain.com
- You can set a Version variable as a key/value pair directly:
./kli kai version config your-version --set SOME_VAR="any value"
# Output:
# [✔] Config updated for version 'your-version'.
- Add a value from an environment variable:
export SOME_VAR="any value"
./kli kai version config your-version --set-from-env SOME_VAR
# Output:
# [✔] Config updated for version 'your-version'.
- Add multiple variables from a file:
# variables.env file
SOME_VAR=12345
ANOTHER_VAR="some long string... "
./kli kai version config your-version --set-from-file variables.env
# Output:
# [✔] Config updated for version 'your-version'.
NOTE: godotenv
library currently doesn't support multiline variables, as stated in
PR #118 @godotenv. Use next example as a workaround.
- Add a file as value:
export SOME_VAR=$(cat any_file.txt)
./kli kai version config your-version --set-from-env SOME_VAR
# Output:
# [✔] Config updated for version 'your-version'.
To create new tests install GoMock. Mocks used on tests are generated with mockgen, when you need a new mock, add the following:
//go:generate mockgen -source=${GOFILE} -destination=$PWD/mocks/${GOFILE} -package=mocks
To generate the mocks execute:
$ go generate ./...
go test ./...
golangci-lint
is a fast Go linters runner. It runs linters in parallel, uses caching, supports yaml config, has
integrations with all major IDE and has dozens of linters included.
As you can see in the .golangci.yml
config file of this repo, we enable more linters than the default and
have more strict settings.
To run golangci-lint
execute:
golangci-lint run
In the development lifecycle of KLI there we use the Nyx automatic semantic version tool.
In order to allow Nyx infer the next version to publish we use the Angular commit convention standard.
WARNING: If the above standard is not correctly followed Nyx won't be able to infer the next version and a new release won't be published.
A local release can be created for testing without creating anything official on the release page.
- Make sure GoReleaser is installed
- Run:
goreleaser --skip-validate --skip-publish --rm-dist
- Find the built binaries under
dist/
folder.