cli

module
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0

README

KubeRocketCI CLI

❗ Please refer to the KubeRocketCI documentation to get the notion of the main concepts and guidelines.

krci is the command-line companion for the KubeRocketCI platform — inspect projects, deployments, pipeline runs, and SonarQube state straight from the terminal, with JSON output ready for agent workflows.

From chat to fix — CLI + AI agent

krci is built to pair with an AI coding assistant (Claude Code, Cursor, Copilot CLI, etc.). Every data command emits predictable JSON under -o json, so an agent can discover resources by filter (no hard-coded names) and then drill in — a list → get chain the agent plans on its own from your natural-language question.

"Check all my PRs that have failed and analyze the logs"
# 1. Discover failed runs for the author — no run names needed up front
krci run list --author "jane" --status failed -o json

# 2. For each name in .pipelineRuns[].name, fan out a diagnosis:
#    task tree + failed step + relevant log lines
krci run get <name> --reason -o json
"What's the reason the pipeline is failing on PR 44?"
# --reason on list targets the most recent matching run automatically,
# so the agent never has to know the run name
krci run list --project my-app --pr 44 --reason -o json
"Build main and tell me the version it produced"
# --wait blocks until the run ends and exits 1 unless it succeeded;
# the build's VCS_TAG result is the version
run=$(krci project build my-app -o json | jq -r '.data.name')
krci run get "$run" --wait -o json | jq -r '.pipelineRuns[0].results.VCS_TAG'
"Check quality gates for each of my projects"
# sonar list already carries the per-project quality-gate verdict
krci sonar list -o json | jq '.data.projects[] | {key, qualityGateStatus}'

# Drill into any red ones
krci sonar gate <key> -o json
krci sonar issues <key> --severity BLOCKER,CRITICAL -o json
"Is keycloak-operator healthy right now?"
# One-shot snapshot: measures + gate + top offenders
krci sonar get keycloak-operator -o json
krci sonar issues keycloak-operator --severity BLOCKER,CRITICAL -o json
Target state

Questions we want the agent to answer next, keeping the same list-then-drill pattern:

# "On which environments is version 1.4.2 of payments-api deployed?"
# "Which deployments include the payments-api application?"
# "Show me the promotion history for my-pipeline."

Why this works: the CLI only talks to the KubeRocketCI Portal (no direct cluster access), tokens stay encrypted on disk, and the JSON shapes are stable enough to treat krci as a first-class agent tool.

What it does

Area What you get Docs
Authentication OIDC + PKCE browser flow, AES-256-GCM token storage, OS keyring integration docs/auth.md
Projects List and inspect projects, list their built image versions, build a branch docs/project.md
Deployments Inspect deployments, their apps, environments, and promotion gates docs/deployment.md
Environments Inspect envs — deployed apps, infrastructure, gates, health, pods, and events docs/env.md
Pipeline runs List, filter, stream logs, and diagnose failures across Tekton runs docs/pipelinerun.md
SonarQube Projects, quality gates, measures, and issues via the Portal's Sonar binding docs/sonar.md
SCA Dependency-Track projects, dependencies, and vulnerability findings docs/sca.md

Every data command accepts -o table (default) or -o json. Tables render nicely on a TTY, plain text into pipes, JSON for automation.

Install

brew tap KubeRocketCI/homebrew-tap
brew install krci

Or grab a binary from GitHub Releases.

30-second tour

# Sign in
krci auth login --portal-url https://portal.example.com

# See what's there
krci project list
krci deployment list
krci pipelinerun list --project keycloak-operator

# Diagnose a failing run
krci run list --project keycloak-operator --pr 336 --reason

# Check a SonarQube gate
krci sonar gate keycloak-operator

Each command has a --help page. Deeper walk-throughs live in docs/ — start with the area you care about.

Commands

krci [--portal-url <url>]
  auth        login | status | logout
  project     list | get <name> | deployments <name> | versions <name> | build <name>
  deployment  list | get <name>
  env         list | get | pods | events <deployment> <env>
  pipelinerun list | get <name> | start <pipeline>   (also filters, --logs, --reason, --wait)
  sonar       list | get | gate | issues <project>
  sca         list | get | components | findings <project>
  version

Aliases: project → proj, deployment → dp, env → e, pipelinerun → run

Configuration

Flag Env Description
--portal-url KRCI_PORTAL_URL KubeRocketCI Portal URL: https, or http for localhost and loopback IPs

Issuer URL, cluster name, and namespace are auto-discovered from the Portal on auth login.

Path Purpose
~/.config/krci/config.yaml Portal URL and discovered metadata
~/.config/krci/tokens.enc AES-encrypted tokens; key in the OS keyring or ~/.config/krci/.keyfile

Build from source

make build        # → dist/krci
make ci           # lint → test → build

Requires Go 1.27+. For running against a local portal, see docs/development.md.

License

Apache License 2.0

Directories

Path Synopsis
cmd
krci command
internal
auth
Package auth provides OIDC authentication for the krci CLI.
Package auth provides OIDC authentication for the krci CLI.
cmdutil
Package cmdutil provides shared CLI utilities, including the Factory dependency container.
Package cmdutil provides shared CLI utilities, including the Factory dependency container.
config
Package config provides configuration loading for the krci CLI.
Package config provides configuration loading for the krci CLI.
iostreams
Package iostreams provides I/O stream abstractions for CLI commands.
Package iostreams provides I/O stream abstractions for CLI commands.
output
Package output provides rendering utilities for CLI command output.
Package output provides rendering utilities for CLI command output.
portal/restapi
Package restapi provides primitives to interact with the openapi HTTP API.
Package restapi provides primitives to interact with the openapi HTTP API.
ptr
termseq
Package termseq is the terminal sequence policy shared by the process streams and the output primitives: the SGR parameters and OSC 8 targets the CLI lets through to a terminal.
Package termseq is the terminal sequence policy shared by the process streams and the output primitives: the SGR parameters and OSC 8 targets the CLI lets through to a terminal.
token
Package token provides encrypted token persistence for the krci CLI.
Package token provides encrypted token persistence for the krci CLI.
pkg
cmd/auth
Package auth implements the "krci auth" command group.
Package auth implements the "krci auth" command group.
cmd/auth/login
Package login implements the "krci auth login" command.
Package login implements the "krci auth login" command.
cmd/auth/logout
Package logout implements the "krci auth logout" command.
Package logout implements the "krci auth logout" command.
cmd/auth/status
Package status implements the "krci auth status" command.
Package status implements the "krci auth status" command.
cmd/deployment
Package deployment implements the "krci deployment" command group.
Package deployment implements the "krci deployment" command group.
cmd/deployment/get
Package get implements the "krci deployment get" command.
Package get implements the "krci deployment get" command.
cmd/deployment/list
Package list implements the "krci deployment list" command.
Package list implements the "krci deployment list" command.
cmd/env
Package env implements the "krci env" command group.
Package env implements the "krci env" command group.
cmd/env/events
Package events implements the "krci env events" command.
Package events implements the "krci env events" command.
cmd/env/get
Package get implements the "krci env get" command.
Package get implements the "krci env get" command.
cmd/env/internal
Package envinternal holds what the `krci env` verbs that take <deployment> <env> share: the positionals, their validation, and the not-found messages.
Package envinternal holds what the `krci env` verbs that take <deployment> <env> share: the positionals, their validation, and the not-found messages.
cmd/env/internal/envtestutil
Package envtestutil holds what the tests of the `krci env` verbs that take <deployment> <env> share: a mock portal and the checks every such verb passes.
Package envtestutil holds what the tests of the `krci env` verbs that take <deployment> <env> share: a mock portal and the checks every such verb passes.
cmd/env/list
Package list implements the "krci env list" command.
Package list implements the "krci env list" command.
cmd/env/pods
Package pods implements the "krci env pods" command.
Package pods implements the "krci env pods" command.
cmd/internal/cmdtest
Package cmdtest provides shared helpers for verb-level command tests.
Package cmdtest provides shared helpers for verb-level command tests.
cmd/internal/discovery
Package discovery holds the table cells, section output and empty-result note shared by the deployment-discovery verbs.
Package discovery holds the table cells, section output and empty-result note shared by the deployment-discovery verbs.
cmd/internal/pipelinerun
Package pipelinerun holds helpers shared by the `krci pipelinerun` verbs and `krci project build` (validation, shared column headers, key=value parsing, row and dry-run rendering, run info and --reason rendering, the status color, --reason log truncation).
Package pipelinerun holds helpers shared by the `krci pipelinerun` verbs and `krci project build` (validation, shared column headers, key=value parsing, row and dry-run rendering, run info and --reason rendering, the status color, --reason log truncation).
cmd/internal/render
Package render owns the output contract shared by the verb groups: `-o` dispatch and validation, the table callback, the `{schemaVersion, data}` and `{schemaVersion, error}` envelopes, and the auth-error prefix.
Package render owns the output contract shared by the verb groups: `-o` dispatch and validation, the table callback, the `{schemaVersion, data}` and `{schemaVersion, error}` envelopes, and the auth-error prefix.
cmd/pipelinerun
Package pipelinerun implements the "krci pipelinerun" command group.
Package pipelinerun implements the "krci pipelinerun" command group.
cmd/pipelinerun/get
Package get implements the "krci pipelinerun get" command.
Package get implements the "krci pipelinerun get" command.
cmd/pipelinerun/list
Package list implements the "krci pipelinerun list" command.
Package list implements the "krci pipelinerun list" command.
cmd/pipelinerun/start
Package start implements the "krci pipelinerun start" command.
Package start implements the "krci pipelinerun start" command.
cmd/project
Package project implements the "krci project" command group.
Package project implements the "krci project" command group.
cmd/project/build
Package build implements the "krci project build <name>" command.
Package build implements the "krci project build <name>" command.
cmd/project/deployments
Package deployments implements the "krci project deployments <project>" command.
Package deployments implements the "krci project deployments <project>" command.
cmd/project/get
Package get implements the "krci project get" command.
Package get implements the "krci project get" command.
cmd/project/list
Package list implements the "krci project list" command.
Package list implements the "krci project list" command.
cmd/project/versions
Package versions implements the "krci project versions <project>" command.
Package versions implements the "krci project versions <project>" command.
cmd/root
Package root assembles the top-level cobra.Command for the krci CLI.
Package root assembles the top-level cobra.Command for the krci CLI.
cmd/sca
Package sca implements the "krci sca" command group (Software Composition Analysis views backed by Dependency-Track).
Package sca implements the "krci sca" command group (Software Composition Analysis views backed by Dependency-Track).
cmd/sca/components
Package components implements the "krci sca components" command.
Package components implements the "krci sca components" command.
cmd/sca/findings
Package findings implements the "krci sca findings" command.
Package findings implements the "krci sca findings" command.
cmd/sca/get
Package get implements the "krci sca get" command.
Package get implements the "krci sca get" command.
cmd/sca/internal
Package scainternal holds helpers shared by `krci sca` verbs (validation, enum sets, Dependency-Track error hint, table cells, paging footer).
Package scainternal holds helpers shared by `krci sca` verbs (validation, enum sets, Dependency-Track error hint, table cells, paging footer).
cmd/sca/internal/scatestutil
Package scatestutil holds helpers shared by the krci sca verb tests.
Package scatestutil holds helpers shared by the krci sca verb tests.
cmd/sca/list
Package list implements the "krci sca list" command.
Package list implements the "krci sca list" command.
cmd/sonar
Package sonar implements the "krci sonar" command group.
Package sonar implements the "krci sonar" command group.
cmd/sonar/gate
Package gate implements the "krci sonar gate" command.
Package gate implements the "krci sonar gate" command.
cmd/sonar/get
Package get implements the "krci sonar get" command.
Package get implements the "krci sonar get" command.
cmd/sonar/internal
Package sonarinternal holds helpers shared by `krci sonar` verbs (validation, enum sets, the gate status color).
Package sonarinternal holds helpers shared by `krci sonar` verbs (validation, enum sets, the gate status color).
cmd/sonar/issues
Package issues implements the "krci sonar issues" command.
Package issues implements the "krci sonar issues" command.
cmd/sonar/list
Package list implements the "krci sonar list" command.
Package list implements the "krci sonar list" command.
cmd/version
Package version implements the "krci version" command.
Package version implements the "krci version" command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL