api

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0 Imports: 85 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MaxMavenUploadBytes int64 = 1 << 30 // 1 GiB
View Source
const MaxNPMUploadBytes int64 = 200 << 20

Variables

This section is empty.

Functions

func RepositoryToResponse added in v0.3.0

func RepositoryToResponse(r *models.Repository) responses.RepositoryResponse

RepositoryToResponse converts a repository to its public API shape. It never includes upstream credentials; the MCP server reuses it.

func ValidateAIArtifactIdentity added in v0.6.0

func ValidateAIArtifactIdentity(format, name, version string) string

ValidateAIArtifactIdentity checks the artifact_format, artifact_name and artifact_version a caller supplies when triggering an analysis (REST and MCP share it) and returns a message for the first problem, "" when acceptable. The format is one of the repository formats, which are also the ids package listings report.

Types

type AIHandler

type AIHandler struct {
	// contains filtered or unexported fields
}

AIHandler handles AI analysis REST endpoints.

func NewAIHandler

func NewAIHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, aiWorker *worker.AIAnalysisWorker) *AIHandler

NewAIHandler creates a new AI analysis handler.

func (*AIHandler) RegisterRoutes

func (h *AIHandler) RegisterRoutes(router chi.Router, prefix string)

RegisterRoutes registers AI analysis routes.

type AdminAIHandler

type AdminAIHandler struct {
	// contains filtered or unexported fields
}

func NewAdminAIHandler

func NewAdminAIHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *AdminAIHandler

func (*AdminAIHandler) Register

func (h *AdminAIHandler) Register(r chi.Router)

func (*AdminAIHandler) WithRuntime added in v0.6.0

WithRuntime makes configuration changes take effect immediately: after every saved change the worker's client and auto-analysis switch are rebuilt from the stored settings layered over env (the env/YAML defaults).

type AdminAuditHandler

type AdminAuditHandler struct {
	// contains filtered or unexported fields
}

func NewAdminAuditHandler

func NewAdminAuditHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *AdminAuditHandler

func (*AdminAuditHandler) Register

func (h *AdminAuditHandler) Register(r chi.Router)

type AdminGPGHandler

type AdminGPGHandler struct {
	// contains filtered or unexported fields
}

func NewAdminGPGHandler

func NewAdminGPGHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *AdminGPGHandler

func (*AdminGPGHandler) Register

func (h *AdminGPGHandler) Register(r chi.Router)

type AdminGroupsHandler

type AdminGroupsHandler struct {
	// contains filtered or unexported fields
}

func NewAdminGroupsHandler

func NewAdminGroupsHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *AdminGroupsHandler

func (*AdminGroupsHandler) Register

func (h *AdminGroupsHandler) Register(r chi.Router)

type AdminPermissionsHandler

type AdminPermissionsHandler struct {
	// contains filtered or unexported fields
}

func NewAdminPermissionsHandler

func NewAdminPermissionsHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *AdminPermissionsHandler

func (*AdminPermissionsHandler) Register

func (h *AdminPermissionsHandler) Register(r chi.Router)

type AdminSSOHandler

type AdminSSOHandler struct {
	// contains filtered or unexported fields
}

func NewAdminSSOHandler

func NewAdminSSOHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, baseURL string, cfg *config.Config) *AdminSSOHandler

func (*AdminSSOHandler) RegisterAuthed

func (h *AdminSSOHandler) RegisterAuthed(authed chi.Router)

func (*AdminSSOHandler) RegisterPublic

func (h *AdminSSOHandler) RegisterPublic(r chi.Router)

type AdminStorageHandler

type AdminStorageHandler struct {
	// contains filtered or unexported fields
}

func NewAdminStorageHandler

func NewAdminStorageHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *AdminStorageHandler

func (*AdminStorageHandler) Register

func (h *AdminStorageHandler) Register(r chi.Router)

type AdminTieringHandler added in v0.7.0

type AdminTieringHandler struct {
	// contains filtered or unexported fields
}

AdminTieringHandler serves /api/v1/admin/tiering: tiers, lifecycle policies, dry runs and the mover status.

func NewAdminTieringHandler added in v0.7.0

func NewAdminTieringHandler(db TieringAdminDB, reg TierRegistry, planner TierPlanner, runner TierRunner, log *logger.Logger, evaluator *auth.Evaluator) *AdminTieringHandler

NewAdminTieringHandler creates the handler.

func (*AdminTieringHandler) Register added in v0.7.0

func (h *AdminTieringHandler) Register(r chi.Router)

Register mounts the routes.

type AdminTokensHandler

type AdminTokensHandler struct {
	// contains filtered or unexported fields
}

func NewAdminTokensHandler

func NewAdminTokensHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *AdminTokensHandler

func (*AdminTokensHandler) Register

func (h *AdminTokensHandler) Register(r chi.Router)

type AdminUsersHandler

type AdminUsersHandler struct {
	// contains filtered or unexported fields
}

func NewAdminUsersHandler

func NewAdminUsersHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *AdminUsersHandler

func (*AdminUsersHandler) Register

func (h *AdminUsersHandler) Register(r chi.Router)

type AuthHandler

type AuthHandler struct {
	// contains filtered or unexported fields
}

func NewAuthHandler

func NewAuthHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, trustedProxies *middleware.TrustedProxies) *AuthHandler

func (*AuthHandler) RegisterAuthed

func (h *AuthHandler) RegisterAuthed(r chi.Router)

func (*AuthHandler) RegisterPublic

func (h *AuthHandler) RegisterPublic(r chi.Router)

func (*AuthHandler) WithBaseURL added in v0.6.0

func (h *AuthHandler) WithBaseURL(baseURL string) *AuthHandler

WithBaseURL sets the public base URL; an https value forces Secure cookies.

type BackupHandler

type BackupHandler struct {
	// contains filtered or unexported fields
}

func NewBackupHandler

func NewBackupHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, backupEngine *backup.Engine) *BackupHandler

func (*BackupHandler) RegisterAuthed

func (h *BackupHandler) RegisterAuthed(r chi.Router)

type BundlesHandler

type BundlesHandler struct {
	// contains filtered or unexported fields
}

func NewBundlesHandler

func NewBundlesHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *BundlesHandler

func (*BundlesHandler) RegisterAuthed

func (h *BundlesHandler) RegisterAuthed(r chi.Router)

type CleanupHandler

type CleanupHandler struct {
	// contains filtered or unexported fields
}

func NewCleanupHandler

func NewCleanupHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, runner CleanupRunner) *CleanupHandler

func (*CleanupHandler) RegisterAuthed

func (h *CleanupHandler) RegisterAuthed(r chi.Router)

type CleanupRunner added in v0.2.0

type CleanupRunner interface {
	TriggerPolicy(ctx context.Context, policyID string) error
}

CleanupRunner starts an immediate run of a cleanup policy. It is satisfied by *worker.CleanupWorker.

type CompletePresignedUploadResponse added in v0.5.0

type CompletePresignedUploadResponse struct {
	ID     string `json:"id"`
	Path   string `json:"path"`
	SHA256 string `json:"sha256"`
	Size   int64  `json:"size"`
}

CompletePresignedUploadResponse mirrors the response of a raw PUT.

type CreatePresignedUploadRequest added in v0.5.0

type CreatePresignedUploadRequest struct {
	Path        string `json:"path"`
	Size        int64  `json:"size"`
	SHA256      string `json:"sha256"`
	ContentType string `json:"content_type,omitempty"`
}

CreatePresignedUploadRequest is the body of POST /repositories/{name}/uploads.

type CreatePresignedUploadResponse added in v0.5.0

type CreatePresignedUploadResponse struct {
	ID string `json:"id"`
	// UploadURL accepts one PUT of exactly Size bytes. Do not log it: the
	// query string is the credential.
	UploadURL string `json:"upload_url"`
	Method    string `json:"method"`
	// Headers must be sent with the PUT.
	Headers   map[string]string `json:"headers"`
	ExpiresAt time.Time         `json:"expires_at"`
}

CreatePresignedUploadResponse tells the client where and how to upload.

type DebUploadHandler

type DebUploadHandler struct {
	// contains filtered or unexported fields
}

func NewDebUploadHandler

func NewDebUploadHandler(log *logger.Logger, db database.Database, blobStore storage.BlobStore, reg *metrics.Registry) *DebUploadHandler

func (*DebUploadHandler) Register

func (h *DebUploadHandler) Register(router chi.Router)

func (*DebUploadHandler) SetDebWorker

func (h *DebUploadHandler) SetDebWorker(w *worker.DebMetadataWorker)

func (*DebUploadHandler) SetPublisher added in v0.2.0

func (h *DebUploadHandler) SetPublisher(p webhook.Publisher)

SetPublisher wires the webhook publisher used for artifact events.

type DeltaHandler

type DeltaHandler struct {
	// contains filtered or unexported fields
}

DeltaHandler handles package delta requests.

func NewDeltaHandler

func NewDeltaHandler(log *logger.Logger, db database.Database, blobStore storage.BlobStore) *DeltaHandler

NewDeltaHandler creates a new DeltaHandler.

func (*DeltaHandler) Register

func (h *DeltaHandler) Register(router chi.Router)

Register registers the delta routes on the given router.

type DockerGCHandler added in v0.4.0

type DockerGCHandler struct {
	// contains filtered or unexported fields
}

DockerGCHandler serves the admin endpoint that runs Docker registry garbage collection (untagged manifests and the blobs only they referenced) on demand.

func NewDockerGCHandler added in v0.4.0

func NewDockerGCHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, runner DockerGCRunner) *DockerGCHandler

func (*DockerGCHandler) RegisterAuthed added in v0.4.0

func (h *DockerGCHandler) RegisterAuthed(r chi.Router)

type DockerGCRunner added in v0.4.0

type DockerGCRunner interface {
	RunRepo(ctx context.Context, repo *models.Repository, opts worker.DockerGCOptions) (*worker.DockerGCReport, error)
	DefaultGrace() time.Duration
}

DockerGCRunner runs Docker registry garbage collection. It is satisfied by *worker.DockerGCWorker.

type ErrorResponse

type ErrorResponse struct {
	Error   string `json:"error"`
	Code    string `json:"code"`
	Details string `json:"details,omitempty"`
}

ErrorResponse represents an error response.

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

HTTPServer implements the Server interface.

func NewHTTPServer

func NewHTTPServer(addr string, log *logger.Logger) *HTTPServer

NewHTTPServer creates a new HTTP server. Defaults favor never truncating large artifact transfers: no read/write timeout, with only header reads bounded (slowloris mitigation) until SetTimeouts overrides them from config.

func (*HTTPServer) AddMiddleware

func (s *HTTPServer) AddMiddleware(middleware func(http.Handler) http.Handler)

AddMiddleware adds a middleware to the server.

func (*HTTPServer) EnableTLS added in v0.2.0

func (s *HTTPServer) EnableTLS(certFile, keyFile string)

EnableTLS makes Start serve HTTPS using the given certificate and key files.

func (*HTTPServer) GetRouter

func (s *HTTPServer) GetRouter() chi.Router

GetRouter returns the underlying chi router.

func (*HTTPServer) ServeErrors added in v0.4.0

func (s *HTTPServer) ServeErrors() <-chan error

ServeErrors delivers the error that ended the accept loop unexpectedly (anything but a graceful Stop). The caller must treat it as fatal.

func (*HTTPServer) SetTimeouts

func (s *HTTPServer) SetTimeouts(readTimeout, writeTimeout, readHeaderTimeout time.Duration)

SetTimeouts configures read, write, and read-header timeouts on the HTTP server. readTimeout/writeTimeout of 0 mean "no limit" (relevant for large artifact transfers); readHeaderTimeout should stay non-zero regardless — it bounds only the header-read phase, so it never truncates a body.

func (*HTTPServer) Start

func (s *HTTPServer) Start(ctx context.Context) error

Start binds the listen address and serves in the background. Everything that can be checked up front (the TLS key pair, the bind itself) fails here, so a misconfigured server never reports a successful start. A later failure of the accept loop is delivered on ServeErrors.

func (*HTTPServer) Stop

func (s *HTTPServer) Stop(ctx context.Context) error

Stop gracefully stops the server.

type LicenseHandler

type LicenseHandler struct {
	// contains filtered or unexported fields
}

func NewLicenseHandler

func NewLicenseHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, detector *license.Detector, blobs storage.BlobStore) *LicenseHandler

NewLicenseHandler returns the license scan and policy handler. blobs is the store the scan reads artifact files from to find their declared licenses.

func (*LicenseHandler) RegisterRoutes

func (h *LicenseHandler) RegisterRoutes(authedRouter chi.Router)

type MavenUploadHandler

type MavenUploadHandler struct {
	// contains filtered or unexported fields
}

func NewMavenUploadHandler

func NewMavenUploadHandler(log *logger.Logger, db database.Database, blobStore storage.BlobStore, reg *metrics.Registry) *MavenUploadHandler

func (*MavenUploadHandler) Register

func (h *MavenUploadHandler) Register(router chi.Router)

Register mounts PUT/DELETE using a true chi wildcard ("/*"), not a regexp param: chi's {name:regexp} params never span "/" (the tail delimiter defaults to '/', so the regexp is only ever tested against a single path segment), so {path:.*} can never match a multi-segment GAV path and silently 404s every real upload/delete.

func (*MavenUploadHandler) SetMavenWorker

func (h *MavenUploadHandler) SetMavenWorker(w *worker.MavenMetadataWorker)

SetMavenWorker wires the debounced maven-metadata.xml regeneration worker. Call NotifyStale(repoID, groupID, artifactID) after each successful upload.

func (*MavenUploadHandler) SetPublisher added in v0.2.0

func (h *MavenUploadHandler) SetPublisher(p webhook.Publisher)

SetPublisher wires the webhook publisher for artifact.* events.

type NPMUploadHandler

type NPMUploadHandler struct {
	// contains filtered or unexported fields
}

func NewNPMUploadHandler

func NewNPMUploadHandler(log *logger.Logger, db database.Database, blobStore storage.BlobStore, baseURL string, reg *metrics.Registry) *NPMUploadHandler

func (*NPMUploadHandler) HandlePublish added in v0.2.0

func (h *NPMUploadHandler) HandlePublish(w http.ResponseWriter, r *http.Request)

HandlePublish serves an npm publish (or `-rev` unpublish) PUT. It is exported for routers that share PUT "/*" with another format.

func (*NPMUploadHandler) Register

func (h *NPMUploadHandler) Register(router chi.Router)

Register mounts the publish/unpublish routes under /repos/{name} on a router that has no other /repos/{name} subrouter (tests). Production code shares the /repos/{name} subrouter with the other formats and calls RegisterRepoRoutes.

func (*NPMUploadHandler) RegisterRepoRoutes added in v0.2.0

func (h *NPMUploadHandler) RegisterRepoRoutes(r chi.Router)

RegisterRepoRoutes registers the routes relative to a /repos/{name} subrouter. They must live inside that subrouter: a sibling /repos/{repo}/* route is shadowed by the mount and every PUT/DELETE 404s.

func (*NPMUploadHandler) SetNPMWorker

func (h *NPMUploadHandler) SetNPMWorker(w *worker.NPMMetadataWorker)

SetNPMWorker wires the debounced npm packument regeneration worker. Call NotifyStale(packageID) after each successful publish.

func (*NPMUploadHandler) SetPublisher added in v0.2.0

func (h *NPMUploadHandler) SetPublisher(p webhook.Publisher)

SetPublisher wires the webhook publisher used for artifact.uploaded and artifact.deleted events. It must be called before the handler serves requests.

type OIDCHandler

type OIDCHandler struct {
	// contains filtered or unexported fields
}

func NewOIDCHandler

func NewOIDCHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, hmacKey []byte, baseURL string) *OIDCHandler

func (*OIDCHandler) RegisterPublic

func (h *OIDCHandler) RegisterPublic(public chi.Router)

func (*OIDCHandler) WithTrustedProxies added in v0.2.0

func (h *OIDCHandler) WithTrustedProxies(tp *middleware.TrustedProxies) *OIDCHandler

WithTrustedProxies sets the reverse-proxy allowlist used to resolve the client IP recorded on new sessions. Without it the TCP peer address is used.

type OpenAPIHandler

type OpenAPIHandler struct{}

func NewOpenAPIHandler

func NewOpenAPIHandler() *OpenAPIHandler

func (*OpenAPIHandler) RegisterRoutes

func (h *OpenAPIHandler) RegisterRoutes(router chi.Router)

type PresignedUploadHandler added in v0.5.0

type PresignedUploadHandler struct {
	*base.Handler
	// contains filtered or unexported fields
}

PresignedUploadHandler implements client-direct uploads: the client PUTs the bytes straight to the object store using a short-lived presigned URL, then calls complete so the server can verify size and sha256 and record the artifact. Only raw hosted repositories are supported.

func NewPresignedUploadHandler added in v0.5.0

func NewPresignedUploadHandler(log *logger.Logger, db database.Database, blobStore storage.BlobStore,
	evaluator *auth.Evaluator, urlTTL time.Duration, maxPending int, reg *metrics.Registry,
) *PresignedUploadHandler

NewPresignedUploadHandler builds the handler. blobStore may or may not support staging uploads; an unsupported backend answers 501 without recording anything. maxPending caps one user's outstanding uploads (0 = unlimited).

func (*PresignedUploadHandler) Register added in v0.5.0

func (h *PresignedUploadHandler) Register(router chi.Router)

Register mounts the routes.

type ProjectsHandler added in v0.6.0

type ProjectsHandler struct {
	// contains filtered or unexported fields
}

ProjectsHandler serves /api/v1/projects: projects, their members and the groups attached to them. The RBAC middleware is the first gate (project scope, 404 for non-members, 403 below the required role); the handler re-checks the same decision from the evaluator, so a route reached any other way is still protected, and adds the escalation guards the middleware cannot know (which role is granted to whom).

func NewProjectsHandler added in v0.6.0

func NewProjectsHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, settings *auth.ProjectSettings) *ProjectsHandler

NewProjectsHandler returns the projects handler. evaluator decides roles and who is a global admin (implicit owner of every project); settings holds the projects.self_create switch.

func (*ProjectsHandler) RegisterRoutes added in v0.6.0

func (h *ProjectsHandler) RegisterRoutes(r chi.Router)

type PropertiesHandler

type PropertiesHandler struct {
	// contains filtered or unexported fields
}

func NewPropertiesHandler

func NewPropertiesHandler(log *logger.Logger, db database.Database, blobs storage.BlobStore) *PropertiesHandler

NewPropertiesHandler returns the artifact properties handler. blobs is the store read to re-evaluate license policies on the artifact's own declared licenses when a license property changes.

func (*PropertiesHandler) RegisterRoutes

func (h *PropertiesHandler) RegisterRoutes(r chi.Router, pathPrefix string)

type QuotasHandler

type QuotasHandler struct {
	// contains filtered or unexported fields
}

func NewQuotasHandler

func NewQuotasHandler(log *logger.Logger, db database.Database, evaluator *auth.Evaluator) *QuotasHandler

func (*QuotasHandler) RegisterRoutes

func (h *QuotasHandler) RegisterRoutes(r chi.Router, pathPrefix string)

type RPMUploadHandler

type RPMUploadHandler struct {
	// contains filtered or unexported fields
}

func NewRPMUploadHandler

func NewRPMUploadHandler(log *logger.Logger, db database.Database, blobStore storage.BlobStore, reg *metrics.Registry) *RPMUploadHandler

func (*RPMUploadHandler) Register

func (h *RPMUploadHandler) Register(router chi.Router)

func (*RPMUploadHandler) SetDebWorker

func (h *RPMUploadHandler) SetDebWorker(w *worker.DebMetadataWorker)

func (*RPMUploadHandler) SetPublisher added in v0.2.0

func (h *RPMUploadHandler) SetPublisher(p webhook.Publisher)

SetPublisher wires the webhook publisher used for artifact events. It also covers the embedded deb handler that serves deb repositories on the same routes.

func (*RPMUploadHandler) SetRPMWorker

func (h *RPMUploadHandler) SetRPMWorker(w *worker.RPMetadataWorker)

type RepositoriesHandler

type RepositoriesHandler struct {
	// contains filtered or unexported fields
}

func NewRepositoriesHandler

func NewRepositoriesHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *RepositoriesHandler

func (*RepositoriesHandler) RegisterAuthed

func (h *RepositoriesHandler) RegisterAuthed(r chi.Router)

func (*RepositoriesHandler) WaitBackground added in v0.2.0

func (h *RepositoriesHandler) WaitBackground()

WaitBackground blocks until background orphan-blob collections finish.

func (*RepositoriesHandler) WithBlobStore added in v0.2.0

func (h *RepositoriesHandler) WithBlobStore(store storage.BlobStore) *RepositoriesHandler

WithBlobStore enables the package download endpoint.

func (*RepositoriesHandler) WithPublisher added in v0.2.0

WithPublisher enables repository.created / repository.deleted webhook events.

type Response

type Response struct {
	Success bool   `json:"success"`
	Data    any    `json:"data,omitempty"`
	Error   string `json:"error,omitempty"`
	Code    string `json:"code,omitempty"`
}

Response represents a standard API response.

type SAMLHandler

type SAMLHandler struct {
	// contains filtered or unexported fields
}

func NewSAMLHandler

func NewSAMLHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, hmacKey []byte, baseURL string, cfg *config.Config) *SAMLHandler

func (*SAMLHandler) RegisterPublic

func (h *SAMLHandler) RegisterPublic(public chi.Router)

func (*SAMLHandler) WithTrustedProxies added in v0.2.0

func (h *SAMLHandler) WithTrustedProxies(tp *middleware.TrustedProxies) *SAMLHandler

WithTrustedProxies overrides the reverse-proxy allowlist (default: the configured server.trustedProxies) used to resolve the client IP recorded on new sessions.

type SBOMHandler

type SBOMHandler struct {
	// contains filtered or unexported fields
}

func NewSBOMHandler

func NewSBOMHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, generator *sbom.Generator, blobStore storage.BlobStore) *SBOMHandler

func (*SBOMHandler) RegisterAuthed

func (h *SBOMHandler) RegisterAuthed(r chi.Router)

type SecretsHandler

type SecretsHandler struct {
	// contains filtered or unexported fields
}

func NewSecretsHandler

func NewSecretsHandler(db database.Database, log *logger.Logger, scanner *secrets.Scanner) *SecretsHandler

func (*SecretsHandler) RegisterRoutes

func (h *SecretsHandler) RegisterRoutes(authedRouter chi.Router, pathPrefix string)

type SelfTokensHandler

type SelfTokensHandler struct {
	// contains filtered or unexported fields
}

func NewSelfTokensHandler

func NewSelfTokensHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *SelfTokensHandler

func (*SelfTokensHandler) Register

func (h *SelfTokensHandler) Register(r chi.Router)

type SystemInfoHandler

type SystemInfoHandler struct {
	// contains filtered or unexported fields
}

func NewSystemInfoHandler

func NewSystemInfoHandler(version, commit, buildTime string, db database.Database, blobStore storage.BlobStore, storageType string) *SystemInfoHandler

func (*SystemInfoHandler) RegisterAuthed added in v0.2.0

func (h *SystemInfoHandler) RegisterAuthed(r chi.Router)

RegisterAuthed registers the detailed endpoint (behind the admin RBAC check).

func (*SystemInfoHandler) RegisterPublic

func (h *SystemInfoHandler) RegisterPublic(r chi.Router)

RegisterPublic registers the unauthenticated, trimmed endpoint: version and an overall status only.

func (*SystemInfoHandler) ServeHTTP

func (h *SystemInfoHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request)

type TierPlanner added in v0.7.0

type TierPlanner interface {
	Plan(ctx context.Context, draft *tiering.Policy, sampleLimit int) (*tiering.Plan, error)
}

TierPlanner simulates policies (the tiering engine).

type TierRegistry added in v0.7.0

type TierRegistry interface {
	Refresh(ctx context.Context) error
	Snapshot() *tiering.Snapshot
}

TierRegistry is the tier registry as the admin API sees it.

type TierRunner added in v0.7.0

type TierRunner interface {
	// Trigger asks for an immediate pass; it reports false when one is already running.
	Trigger() bool
	Status() tiering.RunnerStatus
}

TierRunner is the background mover as the admin API sees it.

type TieringAdminDB added in v0.7.0

type TieringAdminDB interface {
	ListStorageTiers(ctx context.Context) ([]*models.StorageTier, error)
	GetStorageTierByName(ctx context.Context, name string) (*models.StorageTier, error)
	CreateStorageTier(ctx context.Context, t *models.StorageTier) error
	UpdateStorageTier(ctx context.Context, t *models.StorageTier) error
	// DeleteStorageTierIfUnused checks and deletes atomically; it returns the
	// reason the tier is still in use, or "" once it is deleted.
	DeleteStorageTierIfUnused(ctx context.Context, id string) (string, error)
	GetStorageBackend(ctx context.Context, name string) (*models.StorageBackend, error)

	ListStoragePolicies(ctx context.Context) ([]*models.StoragePolicy, error)
	GetStoragePolicy(ctx context.Context, id string) (*models.StoragePolicy, error)
	CreateStoragePolicy(ctx context.Context, p *models.StoragePolicy) error
	UpdateStoragePolicy(ctx context.Context, p *models.StoragePolicy) error
	DeleteStoragePolicy(ctx context.Context, id string) (bool, error)

	StorageTierUsage(ctx context.Context) ([]models.TierUsage, error)
	ListStorageTierMoves(ctx context.Context, limit int) ([]*models.StorageTierMove, error)
	CountStorageTierMoves(ctx context.Context) (int64, error)
}

TieringAdminDB is the persistence the tiering admin API needs.

type TrashHandler added in v0.5.0

type TrashHandler struct {
	// contains filtered or unexported fields
}

TrashHandler serves the trash API: listing, restoring and purging soft-deleted packages and repositories.

The global routes (/api/v1/trash...) are admin only. The repository routes (/api/v1/repositories/{name}/trash...) need the repository-scoped `delete` permission and only ever touch items of that repository; emptying a repository's trash needs the repository-scoped `manage` permission.

func NewTrashHandler added in v0.5.0

func NewTrashHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator) *TrashHandler

func (*TrashHandler) RegisterAuthed added in v0.5.0

func (h *TrashHandler) RegisterAuthed(r chi.Router)

func (*TrashHandler) WaitBackground added in v0.5.0

func (h *TrashHandler) WaitBackground()

WaitBackground blocks until background orphan-blob collections finish.

func (*TrashHandler) WithBlobStore added in v0.5.0

func (h *TrashHandler) WithBlobStore(store storage.BlobStore) *TrashHandler

WithBlobStore enables freeing blobs when an item is purged.

func (*TrashHandler) WithPublisher added in v0.5.0

func (h *TrashHandler) WithPublisher(p webhook.Publisher) *TrashHandler

WithPublisher enables the artifact.restored/purged and repository.restored/purged events.

func (*TrashHandler) WithRegenerator added in v0.5.0

func (h *TrashHandler) WithRegenerator(r TrashRegenerator) *TrashHandler

WithRegenerator enables the metadata refresh after a restore.

type TrashRegenerator added in v0.5.0

type TrashRegenerator interface {
	NotifyDebStale(repoID string)
	NotifyRPMStale(repoID string)
	NotifyMavenStale(repoID, groupID, artifactID string)
	NotifyNPMStale(packageID string)
}

TrashRegenerator schedules the metadata refresh a restored item needs: a row that left the trash changes what the format's generated metadata lists, exactly like a fresh upload. Every method only enqueues work.

func NewWorkerRegenerator added in v0.5.0

func NewWorkerRegenerator(deb, rpm repoStaleNotifier, maven mavenStaleNotifier, npm npmStaleNotifier) TrashRegenerator

NewWorkerRegenerator builds the TrashRegenerator over the metadata workers constructed in main.go. Pass nil for a worker that is not running.

type VEXHandler added in v0.7.0

type VEXHandler struct {
	// contains filtered or unexported fields
}

VEXHandler serves VEX documents built from the scan results and manages the admin VEX decisions.

func NewVEXHandler added in v0.7.0

func NewVEXHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, generator *sbom.Generator) *VEXHandler

func (*VEXHandler) RegisterAuthed added in v0.7.0

func (h *VEXHandler) RegisterAuthed(r chi.Router)

type VulnHandler

type VulnHandler struct {
	// contains filtered or unexported fields
}

VulnHandler handles vulnerability scanning endpoints.

func NewVulnHandler

func NewVulnHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, scanners *vuln.Registry) *VulnHandler

NewVulnHandler creates a new vulnerability handler. scanners provides the scanner backends and their availability; nil means the defaults (trivy and grype from PATH, no database refresh).

func (*VulnHandler) RegisterOverviewRoutes added in v0.7.0

func (h *VulnHandler) RegisterOverviewRoutes(authedRouter chi.Router)

RegisterOverviewRoutes registers the cross-repository scan overview, which is not scoped to one repository. Administrative like every scan route: the RBAC middleware requires "manage" on /api/v1/ paths and the handlers check the admin flag again.

func (*VulnHandler) RegisterRoutes

func (h *VulnHandler) RegisterRoutes(authedRouter chi.Router, pathPrefix string)

RegisterRoutes registers vulnerability scanning routes.

type WebhooksHandler

type WebhooksHandler struct {
	// contains filtered or unexported fields
}

func NewWebhooksHandler

func NewWebhooksHandler(db database.Database, log *logger.Logger, evaluator *auth.Evaluator, dispatcher *webhook.Dispatcher) *WebhooksHandler

func (*WebhooksHandler) RegisterAuthed

func (h *WebhooksHandler) RegisterAuthed(r chi.Router)

Directories

Path Synopsis
Package responses provides typed response structs for all API handler endpoints.
Package responses provides typed response structs for all API handler endpoints.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL