1
0
Fork 0
mirror of https://github.com/imjasonh/client-go2 synced 2026-07-07 00:33:49 +00:00
Commit graph

2 commits

Author SHA1 Message Date
Jason Hall
6c7409049e
Fix controller example to implement correct interface method (#6)
* Fix controller example to implement correct interface method

- Change ReconcileKind to Reconcile to match the Reconciler interface
- Add nil check for secretLister to handle initialization timing
- Fix OnError handler in e2e test to not fail immediately on expected errors

This allows the controller-owned-lister example to compile and run correctly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update examples/controller-owned-lister/main.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-28 19:57:12 +00:00
Jason Hall
e5b7ad1a0d
Add generic controller framework inspired by Knative
This PR introduces a new controller package that provides a simple, type-safe
framework for building Kubernetes controllers. The implementation is inspired
by Knative's controller patterns but optimized for simplicity.

Key features:
- Simple reconciler interface with just one method (ReconcileKind)
- Automatic detection and persistence of object changes
- Built-in conflict resolution with retry logic
- Owner reference support for watching owned resources
- Error handling patterns (RequeueAfter, RequeueImmediately, PermanentError)
- Context-aware logging with clog integration
- Full test coverage including e2e tests

The framework handles the complexity of update detection, conflict resolution,
and status updates automatically, allowing users to focus on their business logic.

Also includes:
- Comprehensive documentation in controller/README.md
- Example controller implementation in examples/controller/
- Updates to use errors.Is pattern for error checking
- Minor refactoring to use "if err := ..." idiom where appropriate

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 13:01:24 -04:00