Documentation
¶
Index ¶
- Constants
- func Commit(req *http.Request, h *base.Handler, repoName string, a *models.RawArtifact, ...) (*models.RawArtifact, error)
- func CommitPromoted(req *http.Request, h *base.Handler, repoName string, a *models.RawArtifact, ...) (*models.RawArtifact, error)
- func StoredID(a, previous *models.RawArtifact) string
- type HTTPHandler
- type HTTPStore
Constants ¶
const MaxUploadBytes = maxRawUploadBytes
MaxUploadBytes bounds a single raw upload.
Variables ¶
This section is empty.
Functions ¶
func Commit ¶ added in v0.5.0
func Commit(req *http.Request, h *base.Handler, repoName string, a *models.RawArtifact, blob storage.Blob) (*models.RawArtifact, error)
Commit records a raw artifact: it stores blob (the content a.SHA256, see storage.CommitBlob), sets a.BlobKey to its storage key and upserts the artifact row under the per-blob lock, so a concurrent unpublish cannot delete the blob in between; then it releases the blob an overwrite left unreferenced and publishes artifact.uploaded. It returns the artifact row that was overwritten, or nil for a new path. A.ID is the new row's id; an overwrite keeps the previous row's id (see StoredID).
It is the single write path shared by the streaming PUT and the presigned upload completion, so both behave identically after the bytes are in place, and both enforce immutable_releases: overwriting an existing path of such a repository fails with trash.ErrImmutableRelease, before the blob is stored, unless req carries an admin's ?force=true. Storage quota is reserved after those checks and before the blob is stored: a reservation that does not fit fails with quota.ErrExceeded, any later failure returns the reservation, and an overwrite releases the replaced row's usage. req supplies the principal and the force flag; its context is used for every operation, so a caller that must outlive the HTTP request passes a request carrying a detached context.
func CommitPromoted ¶ added in v0.10.0
func CommitPromoted( req *http.Request, h *base.Handler, repoName string, a *models.RawArtifact, promote func(ctx context.Context) error, ) (*models.RawArtifact, error)
CommitPromoted is Commit for content already in the blob store's staging area (the presigned upload completion): promote makes the blob a.SHA256 present under the per-blob lock instead of a stored Blob.
func StoredID ¶ added in v0.5.0
func StoredID(a, previous *models.RawArtifact) string
StoredID is the id of the row an upload ended up in: an overwrite keeps the existing row (and its id).
Types ¶
type HTTPHandler ¶
func NewHTTPHandler ¶
func (*HTTPHandler) RegisterRepoRoutes ¶
func (h *HTTPHandler) RegisterRepoRoutes(r chi.Router)
RegisterRepoRoutes registers Raw-specific routes on the provided sub-router. It does NOT wrap in r.Route() — callers are responsible for the path prefix. Routes use a true chi wildcard ("/*"): {name:regexp} params never span "/".
func (*HTTPHandler) RegisterRoutes ¶
func (h *HTTPHandler) RegisterRoutes(r chi.Router, prefix string)
type HTTPStore ¶ added in v0.15.0
type HTTPStore interface {
quarantine.Checker
BlobReferenceCount(ctx context.Context, sha256 string) (int, error)
DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
DeleteRawArtifact(ctx context.Context, repoID string, path string) error
GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)
GetRawArtifact(ctx context.Context, repoID string, path string) (*models.RawArtifact, error)
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
ListRawArtifacts(ctx context.Context, repoID string, prefix string) ([]*models.RawArtifact, error)
ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)
UpsertRawArtifact(ctx context.Context, artifact *models.RawArtifact) error
}
HTTPStore is the part of the database HTTPHandler needs.