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 are three main stages depend if we are going to add a new feature, release a new version with some features or apply a fix to a current release.
In order to add new features just create a feature branch from master, and after merger the Pull Request a workflow will run the tests and if everything pass a new alpha tag will be created (like v0.0-alpha.0) and a new release will be generaged with this tag.
After some alpha versions we can create what we call a release, and to do that we have to run manual the Release Action. This workflow will create a new release branch and a new tag like v0.0.0. With this tag a new release will be generated.
If we find out a bug in a release, we can apply a bugfix just creating a fix branch from the specific release branch, and createing a Pull Request to the same release branc. When the Pull Request is merged, after pass the tests, a new fix tag will be created just increasing the patch number of the version, and a new release will be build and released.
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.