conan

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package conan owns Conan's on-disk revision layout and write policy. A recipe revision's files are stored under user/name/version/channel/recipe-revision/export/ and a binary package revision's under recipe-revision/package/id/package-revision/, the conan-default layout Artifactory documents (ParseStored). A revision is committed once its conanmanifest.txt is stored, and only committed revisions enter the package index.

Role

artifacts module, ecosystem layer: the Conan revision layout and write policy of the Conan slice. Its Handler plugs into the item service through the format hooks (decision 0032); the slice's http package (artifacts/ecosystem/conan/http) serves the Conan revision protocol over what it keeps.

Inputs

  • Driving: the format registry (artifacts/ecosystem), which hands the item service's hooks for conan repositories to Handler, and the work queue, which runs every format's reindex through it; and the protocol, which builds and parses revision paths (Reference, FilePath, ParseStored, Component, SafeFile), lists a repository's folders (Files) and marks its own writes (Native).
  • Driven: the format hooks' environment (format.Env), through whose store Handler lists a repository's files and keeps the package index (artifacts/core/pkgindex); and the generic deploy policy (artifacts/ecosystem/generic), which Handler embeds and applies first.
  • Settings: none.

Outputs

  • Handler: the hooks that admit a revision file only from the native protocol and only in the layout (Admit), and rebuild the index after a revision file is stored or removed (Deployed, Deleted, Reindex).
  • The package index: a package per name@user/channel, with a version per recipe version whose files are those of its committed recipe and package revisions.
  • The layout rules the protocol shares: Manifest, Reference, FilePath, ParseStored, Component, SafeFile, Files, Native and IsNative.

Invariants

  • A generic item write cannot create a Conan revision by choosing its storage path: only a write the protocol marked Native, or a remote's cached write, is admitted.
  • The index lists only committed revisions: a recipe revision with its manifest, and a package revision with its own and its recipe revision's.
  • A path component is refused before it becomes an item path if it could traverse or carries a control character.

References

Status

Implemented P9c, which delivered the plan's P31 group (issues #770 to #775). Moved here in P9d.

Testing

  • path_test.go: the stored layout's recipe and package paths, and the components and file names it refuses.

The hooks are also tested end to end through the protocol, from the Conan suites in test/server/artifacts/conan (docs/testing/conan.md).

Index

Constants

View Source
const Manifest = "conanmanifest.txt"

Manifest is the file name of a revision's manifest, which the Conan client uploads last and which commits the revision: until it is stored, the revision's files are hidden from search, download and the index.

Variables

This section is empty.

Functions

func Component

func Component(s string) bool

Component rejects traversal and control characters before a protocol segment can become an item path. Conan references do not contain slashes.

func Files

func Files(
	ctx context.Context,
	st format.Store,
	c repo.Config,
	folder string,
) ([]model.Item, error)

Files walks one storage folder with bounded keyset pagination. The caller must filter by its principal before returning any name or metadata.

func IsNative

func IsNative(ctx context.Context) bool

IsNative reports whether ctx carries the mark Native sets, which Admit requires of every revision write that is not a remote's cached one.

func Native

func Native(
	ctx context.Context,
) context.Context

Native marks a write that entered through /api/conan. A generic item PUT cannot claim a Conan revision simply by choosing its storage path.

func SafeFile

func SafeFile(name string) bool

SafeFile permits Conan's metadata subfolders but no empty, dot, encoded separator or exceptionally long path component.

func Serves

func Serves(t repo.PackageType) bool

Serves reports whether t is the Conan package type.

Types

type FilePath

type FilePath struct {
	Ref      Reference
	Package  bool
	ID, PRev string
	File     string
}

FilePath is the item-tree interpretation of a native Conan file URL.

func ParseStored

func ParseStored(path string) (FilePath, bool)

ParseStored recognizes the documented Artifactory conan-default layout: user/name/version/channel/recipe-revision/{export/file or package/id/package-revision/file}. It is deliberately independent of the HTTP route so restore and reindex use the same identity rules.

func (FilePath) Path

func (f FilePath) Path() string

Path is f's item path: its File below Root.

func (FilePath) Root

func (f FilePath) Root() string

Root is the folder of the revision f belongs to: the package revision's folder for a package file, and the recipe revision's export folder otherwise.

type Handler

type Handler struct{ generic.Handler }

Handler keeps the common package index tied to committed Conan manifests. Files uploaded before a manifest are invisible to search and resolution; the Conan client uploads the manifest last for each revision.

func (Handler) Admit

func (h Handler) Admit(
	ctx context.Context, env format.Env, c repo.Config, w format.Write,
) (format.Write, error)

Admit applies the generic deploy policy (black-out and include and exclude patterns) first, keeping its refusal's status, then passes a remote's cached write. Any other write must carry the Native mark, or a generic item write could create a revision by choosing its path (409), and its path must be in the stored layout (400).

func (Handler) Deleted

func (h Handler) Deleted(
	ctx context.Context, env format.Env, c repo.Config, removed []model.Item,
) error

Deleted rebuilds the repository's index with Reindex when any removed item was a hosted file in the layout, so a deleted revision leaves the index.

func (Handler) Deleting

Deleting does nothing: Deleted rebuilds the index once the items are gone.

func (Handler) Deployed

func (h Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it model.Item) error

Deployed rebuilds the repository's index with Reindex once a hosted file in the layout is stored, since that file may be the manifest that commits its revision. Folders, a remote's cached files and paths outside the layout change nothing.

func (Handler) Reindex

func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error

Reindex rebuilds repository c's package index from its files (a remote's from its cache): a package per name@user/channel, a version per recipe version, and as each version's files those of its committed recipe revisions and of their committed package revisions. A version and a package take their oldest file's creation time. It fails rather than index part of a repository that holds more than 50,000 items.

type Reference

type Reference struct {
	Name, Version, User, Channel, Revision string
}

Reference is the Conan identity of a recipe. Missing user and channel are represented by underscores on the wire, as the Conan client does.

func (Reference) IsValid

func (r Reference) IsValid() bool

IsValid reports whether every part of r, the revision included, is a valid Component.

func (Reference) PackageRoot

func (r Reference) PackageRoot(id, revision string) string

PackageRoot is the folder of binary package id at package revision revision, built from the recipe revision r.

func (Reference) RecipeRoot

func (r Reference) RecipeRoot() string

RecipeRoot is the folder of the recipe revision's own files, the export folder under Root.

func (Reference) Root

func (r Reference) Root() string

Root is the folder that holds every file of the recipe revision r, user/name/version/channel/revision: the conan-default layout puts the user first, unlike the reference's name/version@user/channel form.

Directories

Path Synopsis
Package conanhttp serves the Conan revision protocol at /artifactory/api/conan/{repoKey}, for Conan 2 and for Conan 1 with revisions enabled: ping, the credential exchange and check, recipe search, recipe and package revision lists and latest revisions, file lists, file download and upload, package search, and revision deletion.
Package conanhttp serves the Conan revision protocol at /artifactory/api/conan/{repoKey}, for Conan 2 and for Conan 1 with revisions enabled: ping, the credential exchange and check, recipe search, recipe and package revision lists and latest revisions, file lists, file download and upload, package search, and revision deletion.

Jump to

Keyboard shortcuts

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