registry

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package registry is an in-memory stand-in for api.krowk.com, so the CLI can be tested and demoed without Postgres, object storage or a Rails process.

It implements the same contract the real registry does — declare, upload, finalize; runs; the claim flow; one error envelope — including the parts that exist to catch a broken client: it refuses a finalize for bytes that never arrived, and refuses bytes whose length or digest is not what was declared. A client that passes against this one is exercising the real sequence.

The one thing it fakes is signing. Object storage is this same process on a /_storage path, and the "presigned" URL carries an opaque token rather than a SigV4 signature. Everything the CLI has to get right — the exact headers, the declared length, the digest — is still checked.

Index

Constants

View Source
const (
	// DefaultLimitBytes matches the registry's own max_upload_bytes.
	DefaultLimitBytes int64 = 100 << 20

	// UploadURLLifetime is how long a presigned URL this stand-in hands out stays
	// good, matching the real 15 minutes. Exported alongside HandlerWithClock
	// because the two together are how a test invalidates a signature: no other
	// seam makes 15 minutes elapse inside one, and the recovery from a lapsed
	// signature is a path worth exercising from outside this package.
	UploadURLLifetime = 15 * time.Minute
)

Variables

This section is empty.

Functions

func Handler

func Handler(limitBytes int64, siteURL string) http.Handler

Handler serves the stand-in registry. siteURL is the origin baked into the links it hands out; empty means "whatever host the request arrived on". limitBytes caps an upload the way the real registry's max_upload_bytes does.

func HandlerWithClock

func HandlerWithClock(limitBytes int64, siteURL string, now func() time.Time) http.Handler

HandlerWithClock is Handler with the clock injected, which is the only way a test can reach the expiry surface: a 24-hour lifetime and a 15-minute upload window are not going to elapse inside one.

Types

This section is empty.

Jump to

Keyboard shortcuts

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