repotype

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: AGPL-3.0 Imports: 3 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

Overview

Package repotype is the registry of package formats and the policy derived from it: which formats exist, which can be served as proxy, group or federated repositories, and the per-format facts that more than one package needs (default upstream, signing, URL namespace, Package URL type, vuln ecosystem, version rules). It is the single policy shared by repository creation (reject what cannot be served) and request dispatch (serve what was accepted).

Adding a format starts here: add one Spec to the registry, then follow the checklist in docs/development/README.md. internal/formats then registers the format's plugin (internal/format/plugin), which the server mounts from this Spec; a test there fails until the plugin and the Spec agree.

Index

Constants

View Source
const (
	Hosted = "hosted"
	Proxy  = "proxy"
	Group  = "group"
)
View Source
const DockerHubUpstream = "https://registry-1.docker.io"

DockerHubUpstream is the upstream of a docker proxy repository created without an explicit upstream_url.

Variables

This section is empty.

Functions

func DefaultUpstreamURL added in v0.6.0

func DefaultUpstreamURL(format string) string

DefaultUpstreamURL is the upstream a proxy repository of format uses when none is given, "" for formats without a well-known public upstream.

func FederationFormats added in v0.9.0

func FederationFormats() string

FederationFormats lists the federation-capable formats for error messages.

func FederationSupported added in v0.9.0

func FederationSupported(format string) bool

FederationSupported reports whether hosted repositories of format can be federated (docs/design/federation.md): the formats whose units the federation codecs (internal/federation) replicate.

func GPGFormats added in v0.13.1

func GPGFormats() string

GPGFormats lists the formats signed with an OpenPGP key for error messages.

func GPGSigned added in v0.13.1

func GPGSigned(format string) bool

GPGSigned reports whether hosted repositories of format are signed with an OpenPGP key an admin can assign.

func GeneratedGroupMetadata added in v0.13.0

func GeneratedGroupMetadata(format string) bool

GeneratedGroupMetadata reports whether the groups of format serve metadata the group worker generates from their members (apk, deb, pacman and rpm) rather than resolving requests member by member.

func GeneratedGroupMetadataFormats added in v0.15.0

func GeneratedGroupMetadataFormats() []string

GeneratedGroupMetadataFormats returns the formats whose groups serve generated metadata (GeneratedGroupMetadata), sorted by name.

func GroupDeployFormats added in v0.26.0

func GroupDeployFormats() string

GroupDeployFormats lists the formats whose groups can have a deploy target for error messages.

func GroupDeploySupported added in v0.26.0

func GroupDeploySupported(format string) bool

GroupDeploySupported reports whether a group of format may name a hosted member as its deploy target (Spec.GroupDeploy).

func GroupFormats

func GroupFormats() string

GroupFormats lists the group-capable formats for error messages.

func GroupSupported

func GroupSupported(format string) bool

GroupSupported reports whether group repositories of format can be served. Groups resolve members by path (and merge Maven metadata, npm packuments, NuGet registrations, PyPI project pages, Go version lists, Conan revision lists and searches and the RubyGems compact index; ivy, raw and sbt groups answer from the first member that has the file), for docker by OCI manifest/blob, and for apk, deb, pacman and rpm by generating the Release/Packages indexes, repodata or databases of the group from all members (internal/worker's GroupMetadataWorker) and serving each package from the member that owns it.

func HostedFormats added in v0.17.0

func HostedFormats() string

HostedFormats lists the formats that have hosted repositories for error messages.

func HostedSupported added in v0.17.0

func HostedSupported(format string) bool

HostedSupported reports whether hosted repositories of format can be created: every format but the proxy-only ones (Spec.NoHosted). An unknown format is not.

func Isolated added in v0.13.1

func Isolated(format string) bool

Isolated reports whether format is served under /repos/<format>/{repo}/... (the isolated namespaces) instead of /repos/{repo}/....

func Names added in v0.13.1

func Names() []string

Names returns the registered format ids in display (alphabetical) order.

func PURLEscape added in v0.15.0

func PURLEscape(s string) string

PURLEscape percent-encodes one Package URL component: everything but the unreserved characters (letters, digits, "." "-" "_" "~"), a ':' included ("1:2.0" is "1%3A2.0"). It is the strictest form, which every purl parser decodes; the SBOM and the vulnerability side both build their purls with it, so the two name a package alike.

func PackageSigning added in v0.15.0

func PackageSigning(format string) bool

PackageSigning reports whether hosted repositories of format can sign the packages they store (Spec.PackageSigning).

func ProxyFormats

func ProxyFormats() string

ProxyFormats lists the proxy-capable formats for error messages.

func ProxySupported

func ProxySupported(format string) bool

ProxySupported reports whether proxy repositories of format can be served: the formats whose upstream files are mirrored by path, and docker, which is pulled through the OCI distribution protocol.

func ReservedName added in v0.13.1

func ReservedName(name string) bool

ReservedName reports names that can never be repository names: they collide with Vue router pages (/repos/new, /repos/settings, /repos/trash) or with the isolated /repos/<format>/{name} namespaces, which would make the repository's own pages and native URLs unreachable. Every path that creates a repository (API, declarative manifests, backup restore) applies it.

func RestUploadEndpoint added in v0.15.0

func RestUploadEndpoint(format string) string

RestUploadEndpoint is the REST upload endpoint of format (Spec.RestUploadEndpoint), "" when the format is uploaded through its native routes.

func SortedNames added in v0.13.1

func SortedNames() []string

SortedNames returns the registered format ids in alphabetical order, the order of error messages and API enums.

func UploadRoutes added in v0.15.0

func UploadRoutes() map[string]UploadRoute

UploadRoutes returns the classification of every write route of every format, keyed by chi route pattern, with Format set to the owning format. A pattern that two formats share (the shared PUT) has one class.

func Valid added in v0.13.1

func Valid(name string) bool

Valid reports whether name is a registered format: the values the chk_repo_format constraint of the repositories table accepts.

Types

type Mount added in v0.15.0

type Mount string

Mount is where a format's hosted routes are served.

const (
	// MountShared formats are served under /repos/{repo}/..., on the one
	// subrouter every shared format registers its routes on.
	MountShared Mount = ""
	// MountGuarded formats are served on the shared /repos/{repo} subrouter too,
	// but only through the handler's guard middleware: their paths (nix
	// /<hash>.narinfo, composer /p2/...) clash with the parameter routes of the
	// other formats, so the guard serves them for repositories of the format
	// only and no route of the format is registered there.
	MountGuarded Mount = "guarded"
	// MountIsolated formats are served under /repos/<format>/{repo}/..., so the
	// format name can never be a repository name.
	MountIsolated Mount = "isolated"
	// MountDispatcher formats have no route of their own: the repository
	// dispatcher serves their hosted repositories itself (apk: free-form
	// <branch>/<repo>/<arch>/<file> paths that no route of the shared
	// subrouter can express without shadowing other formats).
	MountDispatcher Mount = "dispatcher"
	// MountOCI is the registry protocol under /v2/ (docker).
	MountOCI Mount = "oci"
)

func MountOf added in v0.15.0

func MountOf(format string) Mount

MountOf is where format's hosted routes are served; MountShared for an unknown format.

type Signing added in v0.13.1

type Signing string

Signing is how a format's repository metadata is signed.

const (
	// SigningNone is a format whose metadata is not signed.
	SigningNone Signing = ""
	// SigningGPG is a format signed with an OpenPGP key (admin GPG keys can be
	// assigned to its hosted repositories).
	SigningGPG Signing = "gpg"
	// SigningRSA is a format signed with the RSA key of its own admin endpoint
	// (the APKINDEX key of apk).
	SigningRSA Signing = "rsa"
	// SigningEd25519 is a format signed with an ed25519 key of its own admin
	// endpoint (the narinfo key of nix).
	SigningEd25519 Signing = "ed25519"
)

type Spec added in v0.13.1

type Spec struct {
	Name string
	// Proxy and Group report whether proxy or group repositories of the format
	// can be served.
	Proxy bool
	Group bool
	// NoHosted marks a format that has no hosted repositories: it can only be
	// created as a proxy (or a group of proxies). Such a format stores no package
	// rows, keeps everything in the proxy cache and registers no hosted routes
	// (huggingface).
	NoHosted bool
	// Federation reports whether hosted repositories can be federated
	// (docs/design/federation.md): the formats whose units the federation
	// codecs replicate.
	Federation bool
	// GeneratedGroupMetadata is set for formats whose groups serve metadata the
	// group worker generates from their members (apk, deb, pacman, rpm) rather
	// than resolving requests member by member.
	GeneratedGroupMetadata bool
	// GroupDeploy marks a format whose groups may name a hosted member as their
	// deploy target (repositories.deploy_target_id): a publish is one or more
	// independent requests under the repository path (PUT or POST), so a group
	// can serve it as its target. Docker (a push is a session), the REST-upload
	// formats (apk, deb, pacman, rpm) and proxy-only formats are not.
	GroupDeploy bool
	// DefaultUpstream is the upstream a proxy repository uses when none is
	// given, "" for formats without a well-known public upstream.
	DefaultUpstream string
	// Signing is how the format's metadata is signed.
	Signing Signing
	// Mount is where the format's hosted routes are served. The isolated
	// formats (MountIsolated) are served under /repos/<format>/{repo}/..., so
	// the format name can never be a repository name.
	Mount Mount
	// RestUploadEndpoint is the REST upload endpoint, relative to
	// /api/v1/repositories/{repo}/, of a format that is not uploaded through a
	// route under /repos/{repo} (deb: "debs", rpm: "packages"); "" for every
	// other format. A POST to /repos/{repo}/upload of such a repository is
	// answered with this hint.
	RestUploadEndpoint string
	// PackageSigning is set for the formats whose hosted repositories can sign
	// the packages they store, not only their metadata (rpm sign_packages).
	PackageSigning bool
	// Uploads classifies the format's write routes for the upload counter.
	Uploads []UploadRoute
	// Versioning is the version scheme.
	Versioning Versioning
	// PURLType is the Package URL type of the format's packages, "" for
	// formats without one (their packages use the "generic" type).
	PURLType string
	// OSVEcosystem is the OSV ecosystem name the OSV scanner queries, "" for
	// formats OSV has no ecosystem for.
	OSVEcosystem string
	// GrypeScan reports whether grype can scan the format's packages through
	// their Package URL.
	GrypeScan bool
	// NoCuration marks a proxy format whose requests the curation gate does not
	// cover (nix, terraform): a curation_mode other than off would promise a
	// block nothing enforces, so the API refuses it.
	NoCuration bool
	// DistroScoped formats (deb, rpm) are only meaningful inside a distribution
	// release: scanners need it to match advisories.
	DistroScoped bool
}

Spec describes one package format. Name is the repository format id: the value of repositories.format and of the API's format field.

func Lookup added in v0.13.1

func Lookup(name string) (Spec, bool)

Lookup returns the Spec of the format and whether it is registered. The name is matched exactly (formats are lower case).

type UploadCount added in v0.15.0

type UploadCount int

UploadCount says who counts a write route in openartifact_uploads_total.

const (
	// CountedByMiddleware routes are counted by the metrics middleware from the
	// HTTP status, under the format's name.
	CountedByMiddleware UploadCount = iota
	// CountedByHandler routes are counted by the handler itself
	// (metrics.Registry.CountUpload): the route is shared by several formats or
	// the outcome is not the HTTP status (the presigned completion).
	CountedByHandler
	// NotAnUpload routes publish no package (yank, delete batches, upload
	// negotiation, metadata).
	NotAnUpload
)

type UploadRoute added in v0.15.0

type UploadRoute struct {
	Pattern string
	Count   UploadCount
	// Method is the HTTP method that uploads (CountedByMiddleware only); other
	// methods on the same route are not counted. "" is the OCI registry route,
	// which the middleware classifies by the endpoint the path addresses.
	Method string
	// Format is the owning format, set by UploadRoutes; leave it empty in a
	// Spec. It is the format label of a CountedByMiddleware route.
	Format string
}

UploadRoute classifies one write route (PUT, POST or PATCH) of a format by its chi route pattern, as chi.Context.RoutePattern reports it (no trailing slash). A route that writes and is not listed here is a test failure, so a new format cannot forget to count its uploads.

type Versioning added in v0.13.1

type Versioning string

Versioning is the version scheme of a format; it decides what counts as a release and how versions compare.

const (
	// VersionOpaque is a format without a snapshot or pre-release concept:
	// every version is a release (apk, conan, conda, deb, docker, pacman, raw,
	// rpm).
	VersionOpaque Versioning = ""
	// VersionMaven is the Maven scheme: "-SNAPSHOT" versions are not releases,
	// and versions compare with the Maven comparator (ivy, maven, sbt).
	VersionMaven Versioning = "maven"
	// VersionSemver is semantic versioning: a "-" pre-release part is not a
	// release (cargo, go, helm, npm, nuget, terraform).
	VersionSemver Versioning = "semver"
	// VersionPEP440 is the Python scheme: a/b/rc/dev segments are not releases.
	VersionPEP440 Versioning = "pep440"
	// VersionGem is the RubyGems scheme: a letter in the version makes it a
	// pre-release.
	VersionGem Versioning = "gem"
)

Directories

Path Synopsis
Package repotypetest holds the exhaustiveness helpers of the format registry: tests of every place that branches on a format use them, so adding a format to internal/repotype fails each place that does not decide on it yet.
Package repotypetest holds the exhaustiveness helpers of the format registry: tests of every place that branches on a format use them, so adding a format to internal/repotype fails each place that does not decide on it yet.

Jump to

Keyboard shortcuts

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