1
0
Fork 0
mirror of https://github.com/imjasonh/git-k8s synced 2026-07-16 20:45:03 +00:00
Commit graph

8 commits

Author SHA1 Message Date
Claude
1d7073009f
Add Prometheus metrics, health probes, Git timeouts, and unit tests
Critical production-readiness improvements:

- Prometheus metrics: reconcile count/latency per controller, Git operation
  duration (clone/push/ls-remote) via pkg/metrics with /metrics on :9090
- Health probes: leverage Knative's built-in health server on :8080, add
  readiness/liveness probes to all four deployment manifests
- Git operation timeouts: 5-minute context deadline on all git.CloneContext
  and PushContext calls to prevent indefinite blocking on large repos
- Unit tests: new ReconcileKind-level tests for push (pending→failed on
  missing repo, auth error paths), sync (branch-not-found, LastSyncTime),
  resolver (missing repo, partial hashes, empty phase), and repowatcher
  (ls-remote errors, empty remote, unchanged branches)

https://claude.ai/code/session_01PaXbaSqhVEqj97kpY4v6rt
2026-03-17 14:32:02 +00:00
Claude
01fcebed54
Improve test coverage from 10.3% to 42.7% with diffcover analysis
Apply the diffcover technique to map code snippets to features, identify
under-tested components, and add comprehensive tests for all reconciler
business logic. Key improvements:

- pkg/reconciler/internal: 26.7% → 100% (generic adapter fully tested)
- pkg/client: 5.6% → 71.8% (full CRUD for all 4 resource types)
- pkg/reconciler/repowatcher: 10.1% → 56.3% (ReconcileKind lifecycle)
- pkg/reconciler/push: 0% → 33.3% (failTransaction, updateBranches)
- pkg/reconciler/sync: 0% → 33.0% (findBranch, createPushTransaction)
- pkg/reconciler/resolver: 2.1% → 17.0% (merge transactions, manual intervention)

Includes COVERAGE_REPORT.md with full code-to-feature mapping showing
which tests cover which lines, following the diffcover methodology.

https://claude.ai/code/session_016Yeyfoocn7SN2HuMsxRD6f
2026-03-04 19:49:59 +00:00
Claude
b122fb297f
Refactor reconcilers to use Knative ReconcileKind pattern
Move the key-splitting, resource-fetching, and not-found handling into a
generic internal.NewReconciler wrapper so that each reconciler only
implements ReconcileKind(ctx, *TypedResource) — matching the Knative
generated reconciler convention. The controller setup wraps the
reconciler with internal.NewReconciler, which bridges Reconcile(ctx, key)
to ReconcileKind(ctx, *T).

This removes duplicated boilerplate from all three reconcilers (push,
sync, resolver), eliminates their Reconcile/LeaderAware methods, and
makes splitKey an unexported implementation detail.

https://claude.ai/code/session_01Eu3LyxX3G1KCcw4aDzmHvp
2026-02-28 05:06:22 +00:00
Claude
0cb9e4aa1d
Fix multiple code review issues: dedup splitKey, fix merge bug, remove dead code
- Extract triplicated splitKey into shared pkg/reconciler/internal package
  using strings.Cut and removing the unnecessary error return
- Fix resolver merge bug: attemptMerge was using treeA.Hash as the merge
  commit tree, silently dropping all of branch B's changes. Now builds a
  proper merged tree that applies B's non-conflicting changes onto A's tree
- Replace hand-rolled nestedFieldNoCopy/unstructuredNestedStringMap with
  k8s.io/apimachinery's unstructured.NestedStringMap stdlib equivalent
- Hoist branch listing out of per-refspec loop in updateBranches to avoid
  redundant API calls
- Add not-found handling in all three reconcilers so deleted resources
  don't cause infinite requeue loops
- Fix client.Get() to use checked type assertion with a clear panic message
  instead of an opaque nil-pointer dereference
- Remove dead code: unused addDefaultingFuncs wrapper, unused context
  injection in push controller setup

https://claude.ai/code/session_01634JRpHEoM9FzuBjZ7qHcY
2026-02-28 04:39:00 +00:00
Claude
4e4f5f923f
Add unit tests and GitRepoSync e2e test
Add unit tests for all packages that previously had zero test coverage:
- pkg/apis/git/v1alpha1: defaults, deepcopy, scheme registration, constants
- pkg/client: toUnstructured/fromUnstructured round-trips, context injection
- pkg/reconciler/push: splitKey, nestedFieldNoCopy, unstructuredNestedStringMap, base64 decoding
- pkg/reconciler/sync: splitKey
- pkg/reconciler/resolver: splitKey, changeName

Add e2e test exercising the sync controller:
- Creates second Gitea repo and GitRepository CR
- Creates GitBranch CRs with headCommit set via status subresource patch
- Creates GitRepoSync CR and verifies the sync controller processes it

https://claude.ai/code/session_01QfFzqKQUsxxBsiZUhuJ3pG
2026-02-28 01:52:05 +00:00
Claude
cc391645e1
Change API group from git.k8s.io to git-k8s.imjasonh.com
The *.k8s.io group is protected in Kubernetes and requires an
api-approved.kubernetes.io annotation. Switch to a custom domain
to avoid the restriction entirely.

https://claude.ai/code/session_01QfFzqKQUsxxBsiZUhuJ3pG
2026-02-28 00:34:34 +00:00
Claude
ffc7c82ae4
Fix LeaderAware interface: use correct Promote signature
The Knative reconciler.LeaderAware interface requires:
  Promote(Bucket, func(Bucket, types.NamespacedName)) error
Our code had the wrong enqueue function signature using
(Bucket, string) error instead.

https://claude.ai/code/session_01QfFzqKQUsxxBsiZUhuJ3pG
2026-02-28 00:21:24 +00:00
Claude
8e65104201
Implement Git-as-K8s control plane with Knative controllers
Build a complete Kubernetes control plane for Git operations using Knative's
pkg framework, go-git for in-memory Git operations, and ko for builds.

Architecture:
- 4 CRDs: GitRepository, GitBranch, GitPushTransaction, GitRepoSync
- Push controller: atomic Git push via go-git with CAS (compare-and-swap)
- Sync controller: two-way sync with in-memory merge base calculation
- Resolver controller: automated 3-way merge for conflicted syncs
- In-cluster Gitea server for backing storage
- Full RBAC, ko-based deployments, and code-gen scaffolding

Note: go.sum needs generation via `go mod tidy` in an environment with
full internet access (knative.dev/pkg v0.0.0-20250520014526-44579e9ce5ed).

https://claude.ai/code/session_01QfFzqKQUsxxBsiZUhuJ3pG
2026-02-27 23:58:44 +00:00