Documentation
¶
Overview ¶
Package git mounts the Hanzo Cloud /v1/git surface: S3-backed Git hosting native in the unified cloud binary — the "internal Gitea" foundation agents push code into.
A repo is the Git LAYER (source code, buildable/deployable) that lives UNDER an IAM project. It is NOT the IAM project itself: `project` is a tenancy CONTEXT (org → project → env); a repo is scoped BY that context. Every repo belongs to exactly one org (the gateway-minted X-Org-Id, HIP-0026) and an optional project sub-scope (X-Project-Id), enforced on every query, so one tenant can never read, clone, push to, or delete another's repos.
Surface:
POST /v1/git/repos create a bare repo -> repoView (201)
GET /v1/git/repos list the tenant's repos -> {data:[repoView]}
GET /v1/git/repos/:name repo detail (branches, HEAD) -> repoView
DELETE /v1/git/repos/:name delete + purge storage -> 204
GET /v1/git/usage per-repo + total bytes -> usageView
Smart-HTTP git protocol (so `git clone` / `git push` work natively):
GET /v1/git/:org/:repo/info/refs?service=git-upload-pack|git-receive-pack POST /v1/git/:org/:repo/git-upload-pack (clone/fetch) POST /v1/git/:org/:repo/git-receive-pack (push)
Storage is a go-billy filesystem holding bare go-git repos; go-git's server transport reads/writes it for clone AND push. The billy home is osfs rooted under {DataDir}/git in the MVP; see storage.go for the hanzoai/vfs (S3) seam.
Billing: every repo tracks sizeBytes, re-measured on create and after each push. /v1/git/usage exposes per-repo + total bytes per tenant, and each measurement emits a "git.usage" log line a metering consumer can bill on.
Index ¶
- func Mount(app *zip.App, deps cloud.Deps) error
- func Shutdown() error
- type Repo
- type Store
- func (s *Store) Close() error
- func (s *Store) Create(ctx context.Context, r Repo) error
- func (s *Store) Delete(ctx context.Context, org, project, name string) (bool, error)
- func (s *Store) Get(ctx context.Context, org, project, name string) (Repo, error)
- func (s *Store) List(ctx context.Context, org, project string) ([]Repo, error)
- func (s *Store) ListOrg(ctx context.Context, org string) ([]Repo, error)
- func (s *Store) SetSize(ctx context.Context, org, project, name string, sizeBytes, updatedAt int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Repo ¶
type Repo struct {
ID string
Org string
Project string // may be "" (org-level repo)
Name string
Description string
DefaultBranch string
SizeBytes int64
CreatedAt int64
UpdatedAt int64
}
Repo is the org-scoped, canonical metadata record for one Git repository. Tenant isolation is the (org, project) pair, enforced at the query layer; the gateway-minted X-Org-Id (HIP-0026) selects the tenant and X-Project-Id an optional sub-scope. The repo's OBJECTS (packs, refs) live on the billy-backed storage under the same (org, project, name) path — this row is only the metadata + the last-measured storage size that commerce meters on.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the repo-metadata database. ONE SQLite file ({DataDir}/git.db) holds every org's repo rows; tenancy is the (org, project) columns. MaxOpenConns(1) serializes writes against the file lock.
func (*Store) Create ¶
Create inserts a new repo row. Returns errConflict when (org,project,name) already exists in the tenant.
func (*Store) ListOrg ¶
ListOrg returns every repo across ALL projects for org (usage rollup), most-recently-updated first.
func (*Store) SetSize ¶
func (s *Store) SetSize(ctx context.Context, org, project, name string, sizeBytes, updatedAt int64) error
SetSize records the last-measured storage size for a repo and bumps updated_at. Called on create and after each push, so the metered number is always the real on-disk size, never a fabricated rollup.