conda

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindIndex   = "conda.repodata"
	PropName    = "conda.name"
	PropVersion = "conda.version"
	PropBuild   = "conda.build"
	PropSubdir  = "conda.subdir"
	PropChannel = "conda.channel"
)
View Source
const ShardIndexFilename = "repodata_shards.msgpack.zst"

Variables

View Source
var ErrInvalidPackage = errors.New("conda: invalid package")
View Source
var ErrInvalidRepodata = errors.New("conda: invalid repodata")

Functions

func EncodeRepodata

func EncodeRepodata(index Repodata, channel, subdir string) (map[string][]byte, error)

func EncodeShards

func EncodeShards(index Repodata, channel, subdir, baseURL string) (map[string][]byte, error)

func IndexPath

func IndexPath(channel, subdir, filename string) string

func IsMetadata

func IsMetadata(p string) bool

func IsShardFilename

func IsShardFilename(filename string) bool

func Serves

func Serves(t repo.PackageType) bool

Types

type Handler

type Handler struct {
	generic.Handler
	Settings Settings
}

func (Handler) Admit

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

func (Handler) Classify

func (Handler) Classify(_ repo.Config, p string) format.Class

func (Handler) Deleted

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

func (Handler) Deleting

func (Handler) Deleting(ctx context.Context, env format.Env, c repo.Config, it types.Item) error

func (Handler) Deployed

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

func (Handler) GuardTransferSource

func (Handler) GuardTransferSource(
	_ context.Context,
	_ format.Env,
	_ repo.Config,
	it types.Item,
) error

func (Handler) Inspect

func (Handler) Inspect(
	ctx context.Context,
	env format.Env,
	_ repo.Config,
	w format.Write,
) (any, error)

func (Handler) Owed

func (Handler) Owed(c repo.Config, cached bool, p string) []format.WorkRef

func (Handler) Reindex

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

func (Handler) Work

func (h Handler) Work(ctx context.Context, env format.Env, work types.WorkItem) error

func (Handler) WorkKinds

func (Handler) WorkKinds() []string

type MetadataPath

type MetadataPath struct {
	Path, Channel, Subdir, Filename string
}

MetadataPath is one channel/subdirectory index path.

func ParseMetadataPath

func ParseMetadataPath(p string) (MetadataPath, bool)

type PackagePath

type PackagePath struct {
	Path, Channel, Subdir, Filename string
	Name, Version, Build, Extension string
}

PackagePath is one channel-relative conda package file.

func ParsePackagePath

func ParsePackagePath(p string) (PackagePath, bool)

ParsePackagePath rejects ambiguous identity and arbitrary repository paths. Conda package filenames are <name>-<version>-<build> with one of two suffixes.

type Record

type Record struct {
	Name          string   `json:"name"`
	Version       string   `json:"version"`
	Build         string   `json:"build"`
	BuildNumber   int      `json:"build_number"`
	Depends       []string `json:"depends,omitempty"`
	Constrains    []string `json:"constrains,omitempty"`
	Noarch        string   `json:"noarch,omitempty"`
	Subdir        string   `json:"subdir,omitempty"`
	Arch          string   `json:"arch,omitempty"`
	Platform      string   `json:"platform,omitempty"`
	License       string   `json:"license,omitempty"`
	LicenseFamily string   `json:"license_family,omitempty"`
	Features      string   `json:"features,omitempty"`
	TrackFeatures string   `json:"track_features,omitempty"`
	Timestamp     int64    `json:"timestamp,omitempty"`
	Size          int64    `json:"size"`
	SHA256        string   `json:"sha256"`
	MD5           string   `json:"md5,omitempty"`
}

Record is the subset of info/index.json retained in the channel index. Checksums, size, filename and subdirectory are supplied from trusted stored content and path, never from fields embedded in a package.

func ReadPackage

func ReadPackage(
	ctx context.Context,
	body io.ReadSeeker,
	size int64,
	id PackagePath,
) (Record, error)

ReadPackage validates one complete legacy or modern Conda archive and extracts only its bounded info/index.json. It does not trust package metadata to choose the repository path or checksums.

type Repodata

type Repodata struct {
	Info struct {
		Subdir string `json:"subdir"`
	} `json:"info"`
	Packages        map[string]Record `json:"packages"`
	PackagesConda   map[string]Record `json:"packages.conda"` //nolint:tagliatelle // Conda wire field is packages.conda.
	Removed         []string          `json:"removed"`
	RepodataVersion int               `json:"repodata_version"`
}

Repodata is the Conda channel index for one platform subdirectory.

func DecodeRepodata

func DecodeRepodata(body []byte, path MetadataPath) (Repodata, error)

DecodeRepodata validates each disclosed package path and integrity claim before a remote index enters the cache or a virtual index includes it.

func DecodeShard

func DecodeShard(body []byte, id MetadataPath, name, digest string) (Repodata, error)

DecodeShard pins the compressed wire bytes before parsing, then validates every archive identity and digest using the classic repodata contract.

func EmptyRepodata

func EmptyRepodata(subdir string) Repodata

type Settings

type Settings struct{ ShardsEnabled bool }

type ShardIndex

type ShardIndex struct {
	BaseURL, ShardsBaseURL string
	Shards                 map[string][]byte
}

ShardIndex is CEP-16 version 1. Hashes are MessagePack binary values, not hex strings. The outward view always uses relative URLs into this channel.

func DecodeShardIndex

func DecodeShardIndex(body []byte) (ShardIndex, error)

Jump to

Keyboard shortcuts

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