mirror of
https://github.com/imjasonh/git-k8s
synced 2026-07-10 15:41:54 +00:00
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
34 lines
1 KiB
Go
34 lines
1 KiB
Go
package v1alpha1
|
|
|
|
import "k8s.io/apimachinery/pkg/runtime"
|
|
|
|
// SetDefaults_GitRepository sets default values for GitRepository.
|
|
func SetDefaults_GitRepository(r *GitRepository) {
|
|
if r.Spec.DefaultBranch == "" {
|
|
r.Spec.DefaultBranch = "main"
|
|
}
|
|
}
|
|
|
|
// SetDefaults_GitPushTransaction sets default values for GitPushTransaction.
|
|
func SetDefaults_GitPushTransaction(t *GitPushTransaction) {
|
|
if t.Status.Phase == "" {
|
|
t.Status.Phase = TransactionPhasePending
|
|
}
|
|
}
|
|
|
|
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
|
return RegisterDefaults(scheme)
|
|
}
|
|
|
|
// RegisterDefaults adds default functions to the given scheme.
|
|
// This is a placeholder that will be populated by code generation.
|
|
// For now we register defaults manually.
|
|
func RegisterDefaults(scheme *runtime.Scheme) error {
|
|
scheme.AddTypeDefaultingFunc(&GitRepository{}, func(obj interface{}) {
|
|
SetDefaults_GitRepository(obj.(*GitRepository))
|
|
})
|
|
scheme.AddTypeDefaultingFunc(&GitPushTransaction{}, func(obj interface{}) {
|
|
SetDefaults_GitPushTransaction(obj.(*GitPushTransaction))
|
|
})
|
|
return nil
|
|
}
|