repofetcher

package
v0.0.0-...-bb8a427 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownKind is returned when the repo kind is not supported
	ErrUnknownKind errUnknownKind
	// ErrInvalidRepoSpec is returned when the repo spec is invalid
	ErrInvalidRepoSpec errInvalidRepoSpec
	// ErrInvalidCache is returned when the cached repo is invalid
	ErrInvalidCache errInvalidCache
	// ErrNetworkRequired is returned when the network is required to complete the operation
	ErrNetworkRequired errNetworkRequired
)

Functions

func MerkelTreeHash

func MerkelTreeHash(
	fsys fs.FS,
	hasher h2streamhash.Hasher,
) (string, error)

func MerkelTreeVerify

func MerkelTreeVerify(
	fsys fs.FS,
	verifier *h2streamhash.Verifier,
	checksum string,
) (bool, error)

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a repo fetcher that caches results

func NewCache

func NewCache(fetchers Map, local map[string]struct{}, checksums map[string]string) *Cache

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, spec Spec) (fs.FS, error)

func (*Cache) Parse

func (c *Cache) Parse(kind string, repobytes []byte) (Spec, error)

func (*Cache) Sums

func (c *Cache) Sums() []RepoChecksum

type Map

type Map map[string]RepoFetcher

Map is a map from kinds to repo fetchers

func (Map) Fetch

func (m Map) Fetch(ctx context.Context, spec Spec) (fs.FS, error)

func (Map) Parse

func (m Map) Parse(kind string, repobytes []byte) (Spec, error)

type RepoChecksum

type RepoChecksum struct {
	Key string `json:"key"`
	Sum string `json:"sum"`
}

RepoChecksum is a checksum for a repo

type RepoFetcher

type RepoFetcher interface {
	Parse(repobytes []byte) (RepoSpec, error)
	Fetch(ctx context.Context, repospec RepoSpec) (fs.FS, error)
}

RepoFetcher fetches a repo of a particular kind

type RepoSpec

type RepoSpec interface {
	Key() (string, error)
}

RepoSpec are repo specific options

type Spec

type Spec struct {
	Kind     string
	RepoSpec RepoSpec
}

Spec is a repo specification

func (Spec) String

func (s Spec) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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