|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides guidance to AI coding assistants when working with this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +OCM CLI (`ocm`) is a command-line tool for interacting with the OpenShift Cluster Manager (OCM) API. Built in Go with Cobra for command structure and the OCM SDK (`ocm-sdk-go`) for type-safe API interactions. |
| 8 | + |
| 9 | +## Build & Test Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +make # Build all command binaries |
| 13 | +make install # Install ocm binary to $GOPATH/bin |
| 14 | +make test # Run all tests (Ginkgo) |
| 15 | +make lint # Run golangci-lint via container |
| 16 | +make fmt # Format Go source code |
| 17 | +make clean # Remove build artifacts |
| 18 | +``` |
| 19 | + |
| 20 | +## Architecture |
| 21 | + |
| 22 | +### Command Structure (`cmd/ocm/`) |
| 23 | +- **Core API**: `get`, `post`, `patch`, `delete` — direct API interaction |
| 24 | +- **Resource management**: `create`, `edit`, `describe`, `list` — higher-level operations |
| 25 | +- **Authentication**: `login`, `logout`, `token`, `whoami` |
| 26 | +- **Cluster operations**: `cluster/` subcommands for cluster lifecycle |
| 27 | +- **Account management**: `account/` subcommands for organizations, users, roles |
| 28 | +- **Utilities**: `config`, `completion`, `version`, `tunnel` |
| 29 | + |
| 30 | +### Key Packages |
| 31 | +- **pkg/ocm/** — Core OCM SDK connection and authentication handling |
| 32 | +- **pkg/arguments/** — Command-line argument parsing and interactive prompts |
| 33 | +- **pkg/config/** — Configuration file management (`~/.config/ocm/ocm.json`) |
| 34 | +- **pkg/output/** — Output formatting (JSON, table) with YAML table definitions |
| 35 | +- **pkg/cluster/** — Cluster-specific operations and utilities |
| 36 | +- **pkg/plugin/** — Plugin discovery and execution (`ocm-` prefix binaries in PATH) |
| 37 | + |
| 38 | +### Connection & Auth |
| 39 | +- OCM SDK connections built through `pkg/ocm/connection-builder/` |
| 40 | +- Multiple auth methods supported; environment variable `OCM_CONFIG` for alternate config |
| 41 | +- Keyring support via `OCM_KEYRING` for secure credential storage |
| 42 | +- Automatic token refresh and session management |
| 43 | + |
| 44 | +## Key Conventions |
| 45 | + |
| 46 | +- Module path: `github.com/openshift-online/ocm-cli` |
| 47 | +- Ginkgo/Gomega for testing (tests in `tests/` directory) |
| 48 | +- Use `podman` over `docker` (configurable via `container_runner` Make variable) |
| 49 | +- Static binaries (CGO disabled) |
| 50 | +- Plugin extensions use `ocm-` prefix naming convention |
0 commit comments