1.7 KiB
1.7 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
A Kubernetes monitoring tool that checks for CronJobs not running according to schedule and sends Slack notifications. It runs as a container inside a K8s cluster, polling all CronJobs every 60 seconds.
Common Commands
# Run tests
go test ./...
# Run tests with race detection and coverage
go test -race -coverprofile=coverage.txt ./...
# Build the binary
CGO_ENABLED=0 go build -o release/cron-checker -ldflags '-w -s'
# Check for vulnerabilities
govulncheck ./...
# Format and vet
go fmt ./...
go vet ./...
# Check for unused modules
go mod tidy
Architecture
This is a single-file Go application (main.go) with comprehensive tests (main_test.go).
Core Components:
doCheck()- Main loop that polls K8s CronJobs, parses cron schedules, and sends Slack alerts for overdue jobsClient/ClientProviderinterfaces - Abstractions over K8s client for testabilityConfigProvider/InClusterProvider- Handles K8s in-cluster authentication
Key Dependencies:
k8s.io/client-go- Kubernetes API clientgithub.com/robfig/cron- Cron schedule parsinggithub.com/multiplay/go-slack- Slack webhook integrationgithub.com/alecthomas/kingpin/v2- CLI flag parsing
Configuration:
SLACK_URLenv var or--slack-urlflag (required) - Slack webhook URL for notifications
Building Docker Image
The Dockerfile performs a multi-stage build that runs fmt, vet, and tests before building:
docker build -t cron-checker .
To extract coverage report:
docker build --target export -o . .