Skip to content

Git Forges

Faber supports GitHub, GitLab, Forgejo, and Gitea behind a unified internal/operator/forge interface (ForgePRSink and forge-agnostic PRFeedbackSyncer).

Every driver supports:

  • Downloading repository archives and recent commit history for offline sandbox injection
  • Creating or updating a single open PR or MR per deterministic agent/<policy>/<key> branch
  • Inspecting open PR or MR state, reviews, and inline comments for feedback loops
  • Closing stale PRs or MRs with an explanatory comment when a later run confirms noop

GitHub (GitHub App or Fine-Grained PAT Quickstart)

Section titled “GitHub (GitHub App or Fine-Grained PAT Quickstart)”

GitHub supports two authentication modes:

  1. GitHub App (Recommended for Production): Configured via spec.github (100% backwards-compatible) or spec.forge (provider: github) plus spec.github credentials. Mints short-lived 1-hour installation tokens from the PEM key referenced by privateKeySecretRef and produces GitHub-signed Verified commits via GraphQL createCommitOnBranch.
  2. Fine-Grained PAT Quickstart (spec.forge.tokenSecretRef): Configured via spec.forge (provider: github) and tokenSecretRef without creating a GitHub App. Ideal for getting Tier 1 PRs running in minutes. Upgrade to spec.github later when you want short-lived installation tokens and Verified commit signatures.
  • Required Permissions: contents: write, pull_requests: write, and metadata: read on the target repository only. Exclude the app or token from branch-protection bypass rules.
  • GitHub Enterprise: Set apiBaseUrl (or spec.forge.baseUrl) to your enterprise API URL (for example https://github.example.com/api/v3).

Fine-grained PAT quickstart example:

apiVersion: faberops.dev/v1alpha1
kind: GitOpsRepository
metadata:
name: cluster-gitops
namespace: faber
spec:
forge:
provider: github
owner: my-org
repo: cluster-gitops
defaultBranch: main
branchPrefix: agent/
tokenSecretRef:
name: faber-github-token
key: token

GitHub App production example (Verified GraphQL commits):

apiVersion: faberops.dev/v1alpha1
kind: GitOpsRepository
metadata:
name: home-ops
namespace: faber
spec:
github:
owner: my-org
repo: home-ops
defaultBranch: main
branchPrefix: agent/
appId: 123456
installationId: 78901234
privateKeySecretRef:
name: faber-github-app
key: private-key.pem

GitLab works with both https://gitlab.com (default when baseUrl is omitted) and self-hosted GitLab instances.

  • Authentication: Project or group access token supplied via spec.forge.tokenSecretRef and sent in the PRIVATE-TOKEN header.
  • Nested Group Paths: spec.forge.owner accepts multi-segment group paths (for example platform/infra/clusters) which are URL-encoded automatically in API requests.
  • Atomic Commits: Multi-file creations, updates, and deletions are submitted in a single atomic POST /api/v4/projects/:id/repository/commits call before creating or updating the Merge Request.
  • Draft MRs and Labels: Draft status uses GitLab’s Draft: title prefix, and feedback sync reads MR state, discussions, and inline diff notes.
apiVersion: faberops.dev/v1alpha1
kind: GitOpsRepository
metadata:
name: platform-gitops
namespace: faber
spec:
forge:
provider: gitlab
baseUrl: https://gitlab.example.com
owner: platform/infra
repo: cluster-fleet
defaultBranch: main
branchPrefix: agent/
tokenSecretRef:
name: faber-gitlab-token
key: token

Both forgejo and gitea use the REST API v1 driver (internal/operator/forge/gitea). spec.forge.baseUrl is required for self-hosted instances.

  • Authentication: Personal or bot access token supplied via spec.forge.tokenSecretRef and sent with Authorization: token <token>.
  • Batch Commits with Fallback: The driver uses the batch Contents API when supported by the server and falls back cleanly to sequential file operations on older servers.
  • Labels and Review Normalization: Repository label names are resolved to integer label IDs automatically. Review states (REQUEST_CHANGES) are normalized to CHANGES_REQUESTED, and per-review inline comments are fetched for PRFeedbackSyncer.
apiVersion: faberops.dev/v1alpha1
kind: GitOpsRepository
metadata:
name: homelab-gitops
namespace: faber
spec:
forge:
provider: forgejo
baseUrl: https://git.example.com
owner: ops
repo: homelab
defaultBranch: main
branchPrefix: agent/
tokenSecretRef:
name: faber-forgejo-token
key: token

CRD Validation and Backwards Compatibility

Section titled “CRD Validation and Backwards Compatibility”

GitOpsRepository enforces the CEL admission rule has(self.github) || has(self.forge) at kubectl apply time. spec.github is an optional pointer so spec.forge-only resources validate cleanly without zero-valued GitHub fields, while existing spec.github manifests continue working without changes.