CLI

The Hava CLI provides a simple way to interact with Hava through a command line interface. This is a powerful way to integrate Hava into CI/CD and GitOps pipelines to ensure that diagrams are always up to date when changes are deployed in your environment

The CLI is available for Windows, MacOS, Linux, and as a Docker container

Installation

The cli is a single binary with no dependencies, so install is a simple matter for downloading the binary and run it from the local environment

We have provided some simple install scripts to simplify this and keep the cli up to date automatically using homebrew for macOS

brew tap teamhava/hava
brew install hava

More install options are available from our detailed installation instructions

Configuration

Before use the CLI needs to be configured with the API token so it can authenticate to the API. The CLI can be configured either using environment variables or by using the in-built configure command to save the configuration long term

Environment variables

VariableRequiredDescription

HAVA_TOKEN

yes

API token to authenticate with Hava API

HAVA_ENDPOINT

no

API Endpoint to connect to, defaults to SaaS endpoint. This is useful when Hava is running in a custom environment

More details on configuring Hava CLI can be found in the GitHub repository

Using the CLI

Once installed a configured, the CLI can be called from the command line with the hava command

To list all sources in your Hava account use the source list command, this will display all the available sources in a table

╭───┬─────────────┬──────────────────────────────────────┬──────────────────────┬────────────┬────────┬────────────────────╮
│   │ DISPLAYNAME │ ID                                   │ INFO                 │ NAME       │ STATE  │ TYPE               │
├───┼─────────────┼──────────────────────────────────────┼──────────────────────┼────────────┼────────┼────────────────────┤
│ 1 │ devTestAWS  │ 8eb192e2-9beb-466b-ae14-c05fc8403cf4 │ AKIAIOSFODNN7EXAMPLE │ devTestAWS │ active │ Sources::AWS::Keys │
╰───┴─────────────┴──────────────────────────────────────┴──────────────────────┴────────────┴────────┴────────────────────╯

Output Format

You can configure the CLI to output in multiple formats, JSON, HTML, Markdown etc.

To print out the result in json use the --json flag

hava source list --json | jq 
[
  {
    "DisplayName": "dev",
    "Id": "4f14c115-3b0d-40ea-b075-6df9b2fb81c9",
    "Info": "AKIAIOSFODNN7EXAMPLE",
    "Name": "dev",
    "State": "active",
    "Type": "Sources::AWS::Keys"
  },
  {
    "DisplayName": "GCPDevChange3",
    "Id": "f2a26440-10bf-43d1-9742-8361de30590f",
    "Info": "credentials.json",
    "Name": "GCPDevChange3",
    "State": "active",
    "Type": "Sources::GCP::ServiceAccountCredentials"
  }
]

See the GitHub repository for details on the complete list of formats

CI/CD Integration Examples

Our CLI makes it trivial to integrate Hava with the CI/CD tool of your choice.

Check out our examples in github for details on using the CLI in common pipelines and workflows

Last updated