Phase 5 (OCI pull): internal/oci/ package with manifest GET/HEAD by tag/digest, blob GET/HEAD with repo membership check, tag listing with OCI pagination, catalog listing. Multi-segment repo names via parseOCIPath() right-split routing. DB query layer in internal/db/repository.go. Phase 6 (OCI push): blob uploads (monolithic and chunked) with uploadManager tracking in-progress BlobWriters, manifest push implementing full ARCHITECTURE.md §5 flow in a single SQLite transaction (create repo, upsert manifest, populate manifest_blobs, atomic tag move). Digest verification on both blob commit and manifest push-by-digest. Phase 8 (admin REST): /v1 endpoints for auth (login/logout/health), repository management (list/detail/delete), policy CRUD with engine reload, audit log listing with filters, GC trigger/status stubs. RequireAdmin middleware, platform-standard error format. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"git.wntrmute.dev/kyle/mcr/internal/db"
|
|
)
|
|
|
|
// AdminListAuditHandler handles GET /v1/audit.
|
|
func AdminListAuditHandler(database *db.DB) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
q := r.URL.Query()
|
|
|
|
limit := 50
|
|
if n := q.Get("n"); n != "" {
|
|
if v, err := strconv.Atoi(n); err == nil && v > 0 {
|
|
limit = v
|
|
}
|
|
}
|
|
offset := 0
|
|
if o := q.Get("offset"); o != "" {
|
|
if v, err := strconv.Atoi(o); err == nil && v >= 0 {
|
|
offset = v
|
|
}
|
|
}
|
|
|
|
filter := db.AuditFilter{
|
|
EventType: q.Get("event_type"),
|
|
ActorID: q.Get("actor_id"),
|
|
Repository: q.Get("repository"),
|
|
Since: q.Get("since"),
|
|
Until: q.Get("until"),
|
|
Limit: limit,
|
|
Offset: offset,
|
|
}
|
|
|
|
events, err := database.ListAuditEvents(filter)
|
|
if err != nil {
|
|
writeAdminError(w, http.StatusInternalServerError, "internal error")
|
|
return
|
|
}
|
|
if events == nil {
|
|
events = []db.AuditEvent{}
|
|
}
|
|
writeJSON(w, http.StatusOK, events)
|
|
}
|
|
}
|