Imported from IguoChan/redis-operator (
AGENTS.md). Install upstream withnpx skills add IguoChan/redis-operator. Copyright stays with the author.
Repository Guidelines
Project Structure & Module Organization
This repository is a Go-based Kubebuilder operator for Redis. Entrypoint code lives in cmd/main.go. Custom resource definitions, webhook logic, and generated deepcopy code are under api/v1/. Reconciliation logic and controller configuration live in internal/controller/. Kubernetes manifests are under config/, including CRDs in config/crd/, RBAC in config/rbac/, manager deployment files in config/manager/, and sample resources in config/samples/. Build helpers and boilerplate live in hack/; local tool binaries are installed into bin/.
Build, Test, and Development Commands
make help: list available Make targets.make generate: regenerate deepcopy methods inapi/v1/.make manifests: regenerate CRDs, RBAC, and webhook manifests.make fmt: rungo fmt ./....make vet: rungo vet ./....make test: run generation, formatting, vetting, envtest setup, andgo test ./... -coverprofile cover.out.make build: compile the manager binary tobin/manager.make run: run the controller locally against the current kubeconfig.make docker-build IMG=redis-controller:latest: build the controller image.make deploy IMG=redis-controller:latest: deploy manifests to the cluster selected by~/.kube/config.
Coding Style & Naming Conventions
Use standard Go formatting (gofmt) and keep imports organized by the Go toolchain. Follow Kubernetes API naming patterns already used in api/v1: resource types use exported CamelCase names such as Redis and RedisSentinel; YAML samples use lowercase kind-derived filenames such as cache_v1_redis.yaml. Keep generated files, especially zz_generated.deepcopy.go, updated through make generate rather than manual edits.
Testing Guidelines
Tests use Go test with Ginkgo/Gomega and controller-runtime envtest. Suite files live at api/v1/webhook_suite_test.go and internal/controller/suite_test.go. Add tests next to the package being exercised and use _test.go filenames. Run make test before opening a PR; it refreshes generated artifacts and writes coverage to cover.out.
Commit & Pull Request Guidelines
Recent commits use short, imperative summaries such as make generate, create webhook, and prometheus. Keep commit subjects concise and focused on one change. Pull requests should describe behavior changed, list validation commands run, and call out generated manifest or CRD updates. For Kubernetes-facing changes, include sample updates or deployment notes needed to reproduce the change with make deploy.
Security & Configuration Tips
Be explicit about the active Kubernetes context before running make install, make deploy, make uninstall, or make undeploy; these targets apply directly to the cluster in the current kubeconfig. Do not commit local kubeconfigs, cluster data directories, or registry credentials.