Documentation ¶
Index ¶
- func BasePath(checksum, uri string) string
- type Cache
- func (c *Cache) Clean() error
- func (c *Cache) Create(checksum, uri string) (*os.File, error)
- func (c *Cache) Download(b *ui.Task, checksum, uri string, mirrors ...string) (path string, etag string, actualChecksum string, err error)
- func (c *Cache) ETag(b *ui.Task, uri string, mirrors ...string) (etag string, err error)
- func (c *Cache) Evict(b *ui.Task, checksum, uri string) error
- func (c *Cache) IsCached(checksum, uri string) bool
- func (c *Cache) Mkdir(uri string) (string, error)
- func (c *Cache) Open(b *ui.Task, checksum, uri string, mirrors ...string) (*os.File, error)
- func (c *Cache) OpenLocal(checksum, uri string) (*os.File, error)
- func (c *Cache) Path(checksum, uri string) string
- func (c *Cache) Root() string
- type PackageSource
- type PackageSourceSelector
- type RepoMatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct { // GetSource determines how to retrieve packages. GetSource PackageSourceSelector // contains filtered or unexported fields }
Cache manages the Hermit cache.
func Open ¶
func Open(stateDir string, selector PackageSourceSelector, client *http.Client, fastFailClient *http.Client) (*Cache, error)
Open or create a Cache at the given directory, using the given http client.
"stateDir" is the root of the Hermit state directory.
"selector" is used to select a PackageSource for retrieving packages
"fastFailClient" is a HTTP client configured to fail quickly if a remote server is unavailable, for use in optional checks.
"strategies" are used to download URLS, attempted in order. A default raw HTTP download strategy will always be the first strategy attempted.
func (*Cache) Download ¶
func (c *Cache) Download(b *ui.Task, checksum, uri string, mirrors ...string) (path string, etag string, actualChecksum string, err error)
Download a local or remote artifact, transparently caching it.
If checksum is present it must be the SHA256 hash of the downloaded artifact.
func (*Cache) ETag ¶
ETag fetches the etag from given URI if available. Otherwise an empty string is returned
func (*Cache) Open ¶
Open a local or remote artifact, transparently caching it. Subsequent accesses will use the cached copy.
If checksum is present it must be the SHA256 hash of the downloaded artifact.
type PackageSource ¶ added in v0.2.23
type PackageSource interface { OpenLocal(cache *Cache, checksum string) (*os.File, error) Download(b *ui.Task, cache *Cache, checksum string) (path string, etag string, actualChecksum string, err error) ETag(b *ui.Task) (etag string, err error) // Validate that a source is accessible. Validate() error }
PackageSource for a specific version / system of a package
func GetSource ¶ added in v0.2.23
func GetSource(client *http.Client, uri string) (PackageSource, error)
GetSource for the given uri, or an error if the uri can not be parsed as a source
func HTTPSource ¶ added in v0.10.0
func HTTPSource(client *http.Client, url string) PackageSource
HTTPSource is a PackageSource for a HTTP URL.
type PackageSourceSelector ¶ added in v0.10.0
type PackageSourceSelector func(client *http.Client, uri string) (PackageSource, error)
PackageSourceSelector selects a PackageSource for a URI.
If not provided to the Cache, GetSource() will be used.
func GitHubSourceSelector ¶ added in v0.10.0
func GitHubSourceSelector(getSource PackageSourceSelector, ghclient *github.Client, match RepoMatcher) PackageSourceSelector
GitHubSourceSelector can download private release assets from GitHub using an authenticated GitHub client.
type RepoMatcher ¶ added in v0.10.0
RepoMatcher is used to determine which repositories will use authenticated requests.