This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
make build- Build the OCM agent binary tobuild/_output/ocm-agentmake build-image- Build container image with tag based on git hashmake clean- Remove build artifacts
make test- Run all Go tests (alias formake go-test)make go-test- Run Go unit tests with vet checksmake coverage- Generate test coverage report usinghack/codecov.sh
make lint- Run golangci-lint (installs automatically if not present)make vet- Run gofmt and go vet checksmake mockgen- Generate mocks for testing (installs mockgen if needed)
make serve- Run OCM agent locally with sample configuration- Requires
$TOKEN,$SERVICEenvironment variables - Uses sample OCM URL for testing
- Requires
make build-push- Build and push container imagemake skopeo-push- Push image using skopeo (requires QUAY_USER and QUAY_TOKEN)
Main Entry Point: cmd/ocm-agent/main.go - Simple CLI wrapper around the root command
CLI Framework: pkg/cli/
- Uses Cobra for command structure
- Main command is
servewhich starts the HTTP server - Configuration handled via Viper with support for config files, env vars, and flags
HTTP Server: pkg/cli/serve/serve.go
- Gorilla Mux router for handling webhook endpoints
- Supports both traditional OSD/ROSA mode and Fleet (HyperShift) mode
- Prometheus metrics endpoint at
/metrics
Request Handlers: pkg/handlers/
webhookreceiver.go- Main AlertManager webhook receiverwebhookrhobsreceiver.go- RHOBS (Red Hat Observability Service) webhook receivercluster.go- Cluster management operationsupgrade_policies.go- Cluster upgrade policy managementreadyz.go/livez.go- Health check endpoints
OCM Integration: pkg/ocm/
- Wrapper around OCM SDK for API communication
- Handles authentication (token-based or client credentials)
- Connection management and retry logic
Kubernetes Client: pkg/k8s/
- Kubernetes client-go wrapper for cluster operations
- Used for reading cluster metadata and applying configurations
pkg/config/- Configuration management using Viperpkg/metrics/- Prometheus metrics collectionpkg/logging/- Structured logging with logruspkg/httpchecker/- HTTP health checking utilities with retry logicpkg/consts/- Application constants
Traditional Mode: Runs on OSD/ROSA clusters to forward alerts to OCM Service Log Fleet Mode: Runs in HyperShift management clusters to handle fleet-wide notifications
- Unit tests alongside source files (
*_test.go) - Ginkgo/Gomega BDD testing framework
- Mock generation using
golang/mock - E2E tests in
test/e2e/directory - Test utilities and scripts in
test/directory
Uses multi-stage Dockerfile in build/Dockerfile with FIPS-enabled Go build for security compliance.
This is a Kubernetes-native Go service that acts as a bridge between cluster monitoring (AlertManager/RHOBS) and OpenShift Cluster Manager services. The agent receives webhook notifications about cluster events and forwards them to appropriate OCM services for SRE visibility and automation.