1
0
Fork 0
mirror of https://github.com/imjasonh/git-k8s synced 2026-07-10 15:41:54 +00:00
git-k8s/cmd/push-controller/main.go
Claude 3b8e1bc276
Address PR review comments: fix ref counting, dedup resolveAuth, remove unused CacheStatus
- Fix Release() ref counting bug: avoid calling getRef() which increments
  count, instead look up ref directly and clean up when count reaches zero
- Remove unpopulated CacheStatus struct and fields from types, deepcopy,
  and CRD manifest since nothing writes to them
- Extract duplicated resolveAuth into shared pkg/gitauth package with
  explicit key validation for missing "username"/"password" keys
- Fix GC() race condition by skipping paths with active in-process refs
- Remove misleading WorkspaceCacheMiss metric increment for in-memory
  (non-cache) code paths
- Change push controller from shallow to full clones to avoid silent
  failures when transactions reference historical commits
- Add tests for ref count cleanup, ref leak prevention, GC active ref
  skipping, and gitauth key validation

https://claude.ai/code/session_01WJE6ozYXZMn1CD6d4vy8b6
2026-03-17 15:45:09 +00:00

27 lines
817 B
Go

package main
import (
"os"
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/signals"
"github.com/imjasonh/git-k8s/pkg/health"
_ "github.com/imjasonh/git-k8s/pkg/metrics" // register Prometheus metrics
"github.com/imjasonh/git-k8s/pkg/reconciler/push"
"github.com/imjasonh/git-k8s/pkg/workspace"
)
func main() {
ctx := signals.NewContext()
go health.ServeMetrics(ctx, ":9090") //nolint:errcheck
// GIT_CACHE_DIR enables PVC-backed workspace caching when set.
// Push controller needs full history to resolve refs referenced by
// push transactions (e.g., older tags or historical commits).
cacheDir := os.Getenv("GIT_CACHE_DIR")
wsMgr := workspace.NewManager(cacheDir, false)
ctx = workspace.WithManager(ctx, wsMgr)
sharedmain.MainWithContext(ctx, "push-controller", push.NewController)
}