$ show goharbor/harbor
Harbor is an open-source, cloud-native container registry platform for managing OCI/Docker images, Helm charts, and other artifacts. It provides a full-stack solution with a Go backend, Angular web portal, PostgreSQL database, and Redis/ValKey job queue. The system supports artifact storage, vulnerability scanning (Trivy integration), SBOM generation, multi-registry replication (Docker Hub, Quay, JFrog, cloud CRs), tag retention policies, immutable tags, RBAC with LDAP/OIDC, robot accounts, webhook/notification pipelines, P2P preheat, and audit logging. The architecture follows a layered pattern: REST API handlers (v2.0) → controllers → managers → DAOs, with middleware chains for security, quota, and content trust. Key entry points include the core API server, job service for background tasks, registry controller for blob/manifest management, and the Angular portal for administration. External dependencies include PostgreSQL, Redis, Trivy scanner, and various cloud registry APIs. The codebase is well-structured with extensive unit and integration tests, though it exhibits some technical debt from generated mocks and legacy components.
The LLM identified 6 files worth highlighting for reuse:
Provides a generic cache interface with memory and Redis backends, supporting TTL-based FetchOrSave with singleflight deduplication. The codec layer handles serialization/deserialization. This module is self-contained and can be extracted for any Go project needing a pluggable cache with deduplication.
Implements a retry utility with configurable exponential backoff, jitter, and abort conditions. Supports both synchronous and asynchronous operations. The interface is clean and dependency-free, making it reusable across any Go application requiring resilient retry logic.
A family of selector implementations (doublestar glob, label, severity, signature) for filtering artifacts based on metadata. Each selector implements a common interface and can be registered dynamically. This pattern is reusable for any system needing pluggable filtering criteria, such as retention policies or access control.
Defines the event building and publishing pipeline for Harbor's notification system. Events are constructed with metadata resolvers and dispatched to handlers (webhook, Slack, audit log). The pattern decouples event producers from consumers and supports asynchronous processing. The interface is generic and could be adapted for other event-driven systems.
A lightweight ORM layer built on Beego that provides model registration, metadata parsing (table names, columns, relations), and query building with snake_case conversion. It includes transaction support via PostgreSQL savepoints. This module encapsulates ORM boilerplate and can be reused in any Go project using Beego or similar databases.
A generic query abstraction supporting keywords, sorting, pagination, range filters, OR lists, and fuzzy matching. It is used across the codebase for API query parameters. The module is self-contained and can be extracted for any Go project needing a flexible query DSL.