conan

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: 10 Imported by: 1 module, 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 conan holds what the Conan v2 proxy and group repositories share: the read paths of the REST API, and the JSON documents (revision lists, file lists, search results) they verify, cache and merge.

Index

Constants

View Source
const ManifestFile = "conanmanifest.txt"

ManifestFile is the file whose presence publishes a revision.

View Source
const (
	// SearchPath is the global recipe search.
	SearchPath = "v2/conans/search"
)

Variables

View Source
var ErrBadDocument = errors.New("invalid conan document")

ErrBadDocument is returned for a JSON document that is not what the Conan REST API sends.

Functions

func MergePackageSearch

func MergePackageSearch(docs ...map[string]json.RawMessage) []byte

MergePackageSearch unites package searches: a package id found by several keeps the entry of the first.

func NameOf

func NameOf(rel string) string

NameOf is the package name a Conan 1 or 2 read path addresses, "" when it names none (the searches, paths that are not read paths).

func ParseFileMap

func ParseFileMap(doc []byte) (map[string]string, error)

ParseFileMap reads a Conan 1 document that maps file names to a string: the snapshot (file to MD5) or the download and digest URLs (file to URL).

func ParseFiles

func ParseFiles(doc []byte) ([]string, bool, error)

ParseFiles reads the answer of a file list endpoint: the file names, and whether the revision is published (its manifest is listed).

func ParsePackageSearch

func ParsePackageSearch(doc []byte) (map[string]json.RawMessage, error)

ParsePackageSearch reads the answer of a package search: the object of each package id, kept as written (the client reads its settings and options).

func ParseSearch

func ParseSearch(doc []byte) ([]string, error)

ParseSearch reads the answer of the recipe search: references written as name/version, with @user/channel when they have them.

func RefName

func RefName(ref string) string

RefName is the package name of a reference as the search writes it (name/version@user/channel); "" when ref has no name/version form.

func RenderFileMap

func RenderFileMap(m map[string]string) []byte

RenderFileMap writes a document ParseFileMap reads.

func RenderRevision

func RenderRevision(rev Revision) []byte

RenderRevision writes the answer of a latest endpoint.

func RenderRevisions

func RenderRevisions(revs []Revision) []byte

RenderRevisions writes the answer of a revisions endpoint.

func RenderSearch

func RenderSearch(results []string) []byte

RenderSearch writes the answer of the recipe search.

func RepoURL

func RepoURL(origin, repo string) string

RepoURL is the URL of repository repo of the server at origin, which a client is configured with.

func V1FileURL

func V1FileURL(base string, ref Ref, rrev, pid, prev, file string) string

V1FileURL is the URL below base (the repository's URL, no trailing slash) of a file of a revision: the recipe's when pid is empty, else the package's.

func ValidFilename

func ValidFilename(name string) bool

ValidFilename reports whether name is a relative path of plain segments with no control characters, as Conan names its files (conanfile.py, metadata/sign/signature.json).

func ValidRevision

func ValidRevision(s string) bool

ValidRevision reports whether s is a revision or package id: letters, digits, ".", "_" and "-" (Conan's are hex digests), and no directory name.

Types

type Kind

type Kind int

Kind is the endpoint a Conan v2 read path addresses.

const (
	// KindOther is a path that is no Conan v2 read endpoint.
	KindOther Kind = iota
	// KindSearch is v2/conans/search: the recipes matching a pattern.
	KindSearch
	// KindRecipeLatest is .../latest of a recipe: its newest revision.
	KindRecipeLatest
	// KindRecipeRevisions is .../revisions of a recipe.
	KindRecipeRevisions
	// KindPackageSearch is the package search of a recipe (newest revision) or
	// of one recipe revision.
	KindPackageSearch
	// KindFiles is the file list of a recipe revision or package revision.
	KindFiles
	// KindFile is one file of a recipe revision or package revision.
	KindFile
	// KindPackageLatest is .../packages/{pid}/latest: the newest revision of a
	// package.
	KindPackageLatest
	// KindPackageRevisions is .../packages/{pid}/revisions.
	KindPackageRevisions
)

type Path

type Path struct {
	Kind Kind
	Ref  Ref
	RRev string
	PID  string
	PRev string
	File string
}

Path is a parsed Conan v2 read path. RRev, PID and PRev are set as far as the path names them; File is the file path of KindFile.

func ParsePath

func ParsePath(rel string) (Path, bool)

ParsePath classifies a path below the repository root, without a query. It accepts only well-formed Conan v2 read paths, so what it returns can be used to build an upstream URL, a cache key or a search pattern without further escaping: every component is a plain name of the characters Conan allows. ok is false for anything else, including the paths a Conan remote also serves but a read-only mirror does not (uploads, deletes).

func (Path) String

func (p Path) String() string

String is the canonical read path of p, without a leading slash.

type Ref

type Ref struct {
	Name, Version, User, Channel string
}

Ref is a recipe reference: name/version@user/channel, where "_" stands for an absent user or channel.

type Revision

type Revision struct {
	ID   string `json:"revision"`
	Time string `json:"time"`
}

Revision is a published recipe or package revision and when it was published. Time keeps the server's own spelling, which the client parses itself.

func MergeRevisions

func MergeRevisions(lists ...[]Revision) []Revision

MergeRevisions unites revision lists: a revision listed by several keeps the entry of the first list that has it, and the result is newest first (equal times keep their order of appearance).

func ParseRevision

func ParseRevision(doc []byte) (Revision, error)

ParseRevision reads the answer of a latest endpoint.

func ParseRevisions

func ParseRevisions(doc []byte) ([]Revision, error)

ParseRevisions reads the answer of a revisions endpoint.

func (Revision) At

func (r Revision) At() time.Time

At is the publication time of r.

type V1Kind

type V1Kind int

V1Kind is the endpoint a Conan 1 read path addresses.

const (
	// V1Other is a path that is no Conan 1 read endpoint.
	V1Other V1Kind = iota
	// V1Search is v1/conans/search.
	V1Search
	// V1Snapshot is v1/conans/{ref}: file name to MD5 of the newest revision.
	V1Snapshot
	// V1PackageSearch is v1/conans/{ref}/search.
	V1PackageSearch
	// V1DownloadURLs is v1/conans/{ref}/download_urls.
	V1DownloadURLs
	// V1Digest is v1/conans/{ref}/digest.
	V1Digest
	// V1PackageSnapshot is v1/conans/{ref}/packages/{pid}.
	V1PackageSnapshot
	// V1PackageDownloadURLs is v1/conans/{ref}/packages/{pid}/download_urls.
	V1PackageDownloadURLs
	// V1PackageDigest is v1/conans/{ref}/packages/{pid}/digest.
	V1PackageDigest
	// V1File is v1/files/{ref}/{rrev}/export/{file}: a file of a recipe revision.
	V1File
	// V1PackageFile is v1/files/{ref}/{rrev}/package/{pid}/{prev}/{file}.
	V1PackageFile
)

type V1Path

type V1Path struct {
	Kind V1Kind
	Ref  Ref
	RRev string
	PID  string
	PRev string
	File string
}

V1Path is a parsed Conan 1 read path. RRev, PID and PRev are set as far as the path names them; File is the file path of V1File and V1PackageFile.

func ParseV1Path

func ParseV1Path(rel string) (V1Path, bool)

ParseV1Path classifies a path below the repository root, without a query, with the guarantees of ParsePath: only well-formed Conan 1 read paths are accepted, and every component is a plain name.

func (V1Path) String

func (p V1Path) String() string

String is the canonical read path of p, without a leading slash.

func (V1Path) V2File

func (p V1Path) V2File() (Path, bool)

V2File is the Conan 2 path of the file a V1File or V1PackageFile addresses.

Jump to

Keyboard shortcuts

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