1
0
Fork 0
mirror of https://github.com/imjasonh/git-k8s synced 2026-07-09 23:27:01 +00:00

Merge pull request #2 from imjasonh/claude/git-k8s-control-plane-ksW2i

Initial plan
This commit is contained in:
Jason Hall 2026-02-27 19:44:45 -05:00 committed by GitHub
commit fe3fe95983
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 64 additions and 33 deletions

View file

@ -27,6 +27,9 @@ jobs:
go build ./cmd/sync-controller/
go build ./cmd/resolver-controller/
- name: Test
run: go test ./...
- name: Vet
run: go vet ./...
@ -84,15 +87,15 @@ jobs:
- name: Verify CRDs are installed
run: |
kubectl get crd gitrepositories.git.k8s.io
kubectl get crd gitbranches.git.k8s.io
kubectl get crd gitpushtransactions.git.k8s.io
kubectl get crd gitreposyncs.git.k8s.io
kubectl get crd gitrepositories.git-k8s.imjasonh.com
kubectl get crd gitbranches.git-k8s.imjasonh.com
kubectl get crd gitpushtransactions.git-k8s.imjasonh.com
kubectl get crd gitreposyncs.git-k8s.imjasonh.com
- name: Smoke test - create a GitRepository
run: |
cat <<EOF | kubectl apply -f -
apiVersion: git.k8s.io/v1alpha1
apiVersion: git-k8s.imjasonh.com/v1alpha1
kind: GitRepository
metadata:
name: test-repo

25
.gitignore vendored Normal file
View file

@ -0,0 +1,25 @@
# Binaries
push-controller
sync-controller
resolver-controller
# Go
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
vendor/
# IDE
.idea/
.vscode/
*.swp
*.swo
*~
# OS
.DS_Store
Thumbs.db

View file

@ -1,9 +1,9 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: gitbranches.git.k8s.io
name: gitbranches.git-k8s.imjasonh.com
spec:
group: git.k8s.io
group: git-k8s.imjasonh.com
names:
kind: GitBranch
listKind: GitBranchList

View file

@ -1,9 +1,9 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: gitpushtransactions.git.k8s.io
name: gitpushtransactions.git-k8s.imjasonh.com
spec:
group: git.k8s.io
group: git-k8s.imjasonh.com
names:
kind: GitPushTransaction
listKind: GitPushTransactionList

View file

@ -1,9 +1,9 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: gitrepositories.git.k8s.io
name: gitrepositories.git-k8s.imjasonh.com
spec:
group: git.k8s.io
group: git-k8s.imjasonh.com
names:
kind: GitRepository
listKind: GitRepositoryList

View file

@ -1,9 +1,9 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: gitreposyncs.git.k8s.io
name: gitreposyncs.git-k8s.imjasonh.com
spec:
group: git.k8s.io
group: git-k8s.imjasonh.com
names:
kind: GitRepoSync
listKind: GitRepoSyncList

View file

@ -5,9 +5,9 @@ metadata:
labels:
app.kubernetes.io/name: git-k8s
rules:
# Full access to all git.k8s.io custom resources.
# Full access to all git-k8s.imjasonh.com custom resources.
- apiGroups:
- git.k8s.io
- git-k8s.imjasonh.com
resources:
- gitrepositories
- gitbranches
@ -23,7 +23,7 @@ rules:
- delete
# Status subresource access.
- apiGroups:
- git.k8s.io
- git-k8s.imjasonh.com
resources:
- gitrepositories/status
- gitbranches/status

View file

@ -1,5 +1,5 @@
// Package v1alpha1 contains API Schema definitions for the git v1alpha1 API group.
//
// +k8s:deepcopy-gen=package,register
// +groupName=git.k8s.io
// +groupName=git-k8s.imjasonh.com
package v1alpha1

View file

@ -8,7 +8,7 @@ import (
const (
// GroupName is the name of the API group.
GroupName = "git.k8s.io"
GroupName = "git-k8s.imjasonh.com"
// Version is the version of the API group.
Version = "v1alpha1"

View file

@ -1,4 +1,4 @@
// Package client provides a typed Kubernetes client for the git.k8s.io API group.
// Package client provides a typed Kubernetes client for the git-k8s.imjasonh.com API group.
//
// In a full Knative injection setup, this package would be auto-generated and
// clients would be retrieved from context via injection (e.g., gitclient.Get(ctx)).
@ -20,7 +20,7 @@ import (
gitv1alpha1 "github.com/imjasonh/git-k8s/pkg/apis/git/v1alpha1"
)
// GitV1alpha1Client provides typed access to git.k8s.io/v1alpha1 resources.
// GitV1alpha1Client provides typed access to git-k8s.imjasonh.com/v1alpha1 resources.
type GitV1alpha1Client struct {
client dynamic.Interface
}

View file

@ -12,6 +12,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/dynamic"
"k8s.io/apimachinery/pkg/types"
"knative.dev/pkg/logging"
"knative.dev/pkg/reconciler"
@ -254,7 +255,7 @@ func splitKey(key string) (string, string, error) {
var _ reconciler.LeaderAware = (*Reconciler)(nil)
// Promote implements LeaderAware.
func (r *Reconciler) Promote(bkt reconciler.Bucket, enq func(bkt reconciler.Bucket, key string) error) error {
func (r *Reconciler) Promote(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error {
return nil
}

View file

@ -10,6 +10,7 @@ import (
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/dynamic"
"knative.dev/pkg/logging"
"knative.dev/pkg/reconciler"
@ -170,12 +171,12 @@ func (r *Reconciler) attemptMerge(ctx context.Context, repoURL, commitAHash, com
mergeCommit := &object.Commit{
Author: object.Signature{
Name: "git-k8s-resolver",
Email: "resolver@git.k8s.io",
Email: "resolver@git-k8s.imjasonh.com",
When: time.Now(),
},
Committer: object.Signature{
Name: "git-k8s-resolver",
Email: "resolver@git.k8s.io",
Email: "resolver@git-k8s.imjasonh.com",
When: time.Now(),
},
Message: fmt.Sprintf("Merge %s and %s\n\nAutomated merge by git-k8s conflict resolver.", commitAHash[:8], commitBHash[:8]),
@ -215,9 +216,9 @@ func (r *Reconciler) createMergePushTransactions(ctx context.Context, namespace
GenerateName: fmt.Sprintf("%s-merge-a-", syncObj.Name),
Namespace: namespace,
Labels: map[string]string{
"git.k8s.io/repo-sync": syncObj.Name,
"git.k8s.io/target": syncObj.Spec.RepoA.Name,
"git.k8s.io/merge": "true",
"git-k8s.imjasonh.com/repo-sync": syncObj.Name,
"git-k8s.imjasonh.com/target": syncObj.Spec.RepoA.Name,
"git-k8s.imjasonh.com/merge": "true",
},
OwnerReferences: []metav1.OwnerReference{
{
@ -247,9 +248,9 @@ func (r *Reconciler) createMergePushTransactions(ctx context.Context, namespace
GenerateName: fmt.Sprintf("%s-merge-b-", syncObj.Name),
Namespace: namespace,
Labels: map[string]string{
"git.k8s.io/repo-sync": syncObj.Name,
"git.k8s.io/target": syncObj.Spec.RepoB.Name,
"git.k8s.io/merge": "true",
"git-k8s.imjasonh.com/repo-sync": syncObj.Name,
"git-k8s.imjasonh.com/target": syncObj.Spec.RepoB.Name,
"git-k8s.imjasonh.com/merge": "true",
},
OwnerReferences: []metav1.OwnerReference{
{
@ -303,7 +304,7 @@ func splitKey(key string) (string, string, error) {
var _ reconciler.LeaderAware = (*Reconciler)(nil)
func (r *Reconciler) Promote(bkt reconciler.Bucket, enq func(bkt reconciler.Bucket, key string) error) error {
func (r *Reconciler) Promote(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error {
return nil
}

View file

@ -7,6 +7,7 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/dynamic"
"knative.dev/pkg/logging"
"knative.dev/pkg/reconciler"
@ -161,8 +162,8 @@ func (r *Reconciler) createPushTransaction(ctx context.Context, namespace string
GenerateName: fmt.Sprintf("%s-sync-", syncObj.Name),
Namespace: namespace,
Labels: map[string]string{
"git.k8s.io/repo-sync": syncObj.Name,
"git.k8s.io/target": targetRepo,
"git-k8s.imjasonh.com/repo-sync": syncObj.Name,
"git-k8s.imjasonh.com/target": targetRepo,
},
OwnerReferences: []metav1.OwnerReference{
{
@ -219,7 +220,7 @@ func splitKey(key string) (string, string, error) {
// Ensure Reconciler implements the reconciler interface.
var _ reconciler.LeaderAware = (*Reconciler)(nil)
func (r *Reconciler) Promote(bkt reconciler.Bucket, enq func(bkt reconciler.Bucket, key string) error) error {
func (r *Reconciler) Promote(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error {
return nil
}