Thank you for contributing to the RHOAS CLI. See below for guides to help you contribute.
The following will need to be installed on your device in order to contribute to this project.
- Go >= v1.15
- golangci-lint
- OpenAPI Generator
- Yarn
- GoReleaser (optional)
You can run the CLI commands files directly with go run. All commands and subcommands are in the ./pkg/cmd folder.
go run ./cmd/rhoas kafka create --name=test --provider=aws --region=us-east-1Runs a linter on the Go source code. Configuration can be found in .golangci.yaml.
There are a number of lint rules enabled. You can find a full list of rules here with usage and configuration guides.
Builds a binary in the $GOPATH/bin directory. Can be executed globally as it is in your $PATH.
Builds an executable binary rhoas of the CLI in the project root. Executable only inside the workspace.
Formats source code.
If you have the Go extension for VS Code, you can generate test stubs for a file, package or function. See Go#Test
Runs unit tests
Runs integration tests
The CLI communicates with the Managed Services API. For this there is a generated API client in ./pkg/api/managedservices/client.
Please ensure you have the latest generated version. Follow the steps below to update the Managed Services API version.
Saves the latest version of the Managed Services OpenAPI specification file to the ./openapi directory.
Validates the Managed Services OpenAPI specification file.
Generates a Golang API client in ./pkg/api/managedservices/client.
The repo has a local mocked version of the Managed Services API in ./mas-mock.
To work and test CLI locally please follow the mock readme and then login into cli using dev profile:
rhoas login --url=http://locahost:8080
The mock API can become outdated from the current state of the Managed Services API. If you want to work with it please ensure it uses the latest OpenAPI spec, making changes where necessary.
The repo has a local Keycloak instance which replicates the production environment. To start the server run make mock-api/start.
You will need to update the config.AuthURL variable to http;//localhost:8080/auth/realms/redhat-external.
rhoas loginStarts the mocked Managed Services API server at http://localhost:8000.
This will also start a local Keycloak instance at http://localhost:8000 for authentication from the CLI.
When Keycloak is up and running, log in as an admin (username: admin, password: admin).
Next, you will need to import the custom realm and client for the RHOAS CLI by running make mock-api/keycloak/import-realm.
Once complete you should see the rhoas-cli-prod client in a sso-external realm from the Keycloak admin panel.
Imports a Keycloak realm and rhoas-cli-prod client.
To log in to the mock API, run rhoas login against the local server with your authentication token:
rhoas login --url http://localhost:8000If you don't have an authentication token, you can still use a faked one, provided it has the correct payload:
export TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImQ4NDgzMTAyLTRhYzAtNDQ0Mi1hZjMwLTAwYWExMDdjZDc5MCJ9.eyJpYXQiOjE2MDQ1OTAzNDAsImp0aSI6ImNjZjg1MmM5LWI5YWEtNDE3Ny1hYmU0LWZkYWU0NmZmNmIxMSIsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MCIsImF1ZCI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MCIsInN1YiI6ImY6LTMzMGVkMmRiLWEwMWUtNDI2OC04ZTkzLTE5ZjhmOGM2YTUxYzpkZXZlbG9wZXIiLCJ0eXAiOiJPZmZsaW5lIiwiYXpwIjoiYXBpLXNlcnZpY2VzIiwibm9uY2UiOiI5OTBjOTI1NS0xNTI3LTRiMTItOTM5OS02YWM2ZGZkMDJmZWQiLCJzZXNzaW9uX3N0YXRlIjoiYTY4Y2U1ZjktZTBiNi00MTc0LTg1YWItMDdmNzBkOGYxZmU2Iiwic2NvcGUiOiJvcGVuaWQgb2ZmbGluZV9hY2Nlc3MifQ.WTfFifDGnPkJX-IQSbzPWRhBKE7Gq5E6SKq3e70jbNc"The main CLI documentation can be found in the ./docs folder.
Documentation can be generated from the CLI commands.
make docs/generateAfter running the command, the documentation should be updated with the command using markdown and then transformed to ascidocs
- Write clear and meaningful Git commit mesages following the Conventional Commits specification
- Provide clear documentation comments.
- Make sure you include a clear and detailed PR description, linking to the related issue when it exists.
Releases can be triggered directing using Github Releases. Before performing release, do the following:
- Run
./scripts/pullapi.shscript to make sure that CLI is using latest version of the Managed Services API. - Change
./pkg/version.gothat will correspond to the new version. - Push all required changes to main branch
After that, go to Github Releases and create the new release.
Note: The project follows semantic versioning
For testing purposes we should always release snapshot version that will not be used by end users. To release snapshot version please execute:
goreleaser --snapshot --rm-distFor testing you can use localy hosted Kafka
- Run local kafka
cd mas-mock
docker-compose up -d
- Use Kafdrop to monitor it
- In CLI execute use command
rhoas kafka use 324234234
- Edit
clusterHostin~/.rhoascli.jsonto point tolocalhost:9092
Your config should look as follows:
...
"services": {
"kafka": {
"clusterId": "1iSY6RQ3JKI8Q0OTmjQFd3ocFRg"
}
}
...