name: code-review description: >- Review a pull request or code change in tekton-pruner. Use when asked to review a PR, evaluate a diff, or assess code quality. Applies Tekton community standards, Go best practices, operator patterns, and pruner-specific domain knowledge (reconciler logic, ConfigMap validation, TTL/history semantics). license: Apache-2.0 metadata: project: tekton-pruner allowed-tools: Read Grep Glob Bash(git diff:) Bash(git log:)
Code Review
tekton-pruner follows Tekton community review standards.
Review Checklist
Correctness
- Logic changes have corresponding unit tests in the relevant
_test.gofile - New ConfigMap fields are covered in
pkg/config/config_validation_test.goandconfig_validation_hierarchical_test.go - Reconciler changes do not break idempotency (re-running reconcile must be safe)
- TTL and history-limit logic in
pkg/config/ttl_handler.goandhistory_limiter.gocorrectly handles zero-value, negative, and missing fields - No data races — verify with
make test-unit(race detector is on by default)
Go Quality
-
make fmtproduces no diff -
go vet ./...is clean - No use of
init()for non-trivial side effects - Errors are wrapped with
fmt.Errorf("...: %w", err)— not swallowed - Contexts are propagated, not ignored
- No direct use of
os.Exitoutsidemain
Kubernetes / Operator Patterns
- RBAC changes in
config/200-clusterrole.yaml/config/200-role.yamlare least-privilege — add only the verbs actually required - New CRDs or config resources include corresponding YAML in
config/ - Informers and listers are used for reads; direct API calls for writes
- Reconcile loops return
controller.NewPermanentErroronly for truly unrecoverable conditions - Webhook validation in
pkg/webhook/configmapvalidation.gorejects invalid pruner specs early, with clear error messages
Domain: Pruner Logic
- ConfigMap selector logic (
pkg/config/config.go,pkg/config/helper.go) correctly resolves namespace-level overrides vs cluster-level defaults -
pkg/config/constants.gois the single source of truth for annotation and label keys — no hardcoded strings elsewhere - History and TTL limits are validated against each other where both are set
- The pruner reconciler correctly handles
PipelineRunandTaskRunindependently; shared logic belongs inpkg/config/helper.go
Observability
- New controller actions emit metrics via
pkg/metrics/ - Log statements use structured logging (
zap) with appropriate levels (Infofor normal operations,Errorfor failures,Debugfor verbose paths)
Documentation
- Public functions and types have Go doc comments
- User-facing ConfigMap fields are documented in
docs/(especiallydocs/tutorials/anddocs/configmap-validation.md) -
ARCHITECTURE.mdis updated if a new component or major design change is introduced
What to Approve
Approve when:
- All checklist items pass
- Tests cover the changed behavior
- The change is focused (one concern per PR)
- Commit messages follow Tekton commit conventions
What to Block
Block (request changes) when:
- Logic is untested or tests are trivially green
- RBAC grants broad wildcard verbs
- Errors are silently swallowed in reconcile loops
- ConfigMap validation can be bypassed