downloader

package
v0.0.0-...-439fd0a Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCharmAlreadyStoredError

func NewCharmAlreadyStoredError(charmURL string) error

NewCharmAlreadyStoredError creates an error that indicates that a charm has already been stored.

Types

type CharmArchive

type CharmArchive interface {
	corecharm.CharmArchive
}

CharmArchive provides information about a downloaded charm archive.

type CharmRepository

type CharmRepository interface {
	GetDownloadURL(string, corecharm.Origin) (*url.URL, corecharm.Origin, error)
	ResolveWithPreferredChannel(charmName string, requestedOrigin corecharm.Origin) (*charm.URL, corecharm.Origin, []corecharm.Platform, error)
	DownloadCharm(charmName string, requestedOrigin corecharm.Origin, archivePath string) (corecharm.CharmArchive, corecharm.Origin, error)
}

CharmRepository provides an API for downloading charms/bundles.

type DownloadedCharm

type DownloadedCharm struct {
	// Charm provides information about the charm contents.
	Charm charm.Charm

	// The charm version.
	CharmVersion string

	// CharmData provides byte-level access to the downloaded charm data.
	CharmData io.Reader

	// The Size of the charm data in bytes.
	Size int64

	// SHA256 is the hash of the bytes in Data.
	SHA256 string

	// The LXD profile or nil if no profile specified by the charm.
	LXDProfile *charm.LXDProfile
}

DownloadedCharm encapsulates the details of a downloaded charm.

type Downloader

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

Downloader implements store-agnostic download and pesistence of charm blobs.

func NewDownloader

func NewDownloader(logger Logger, storage Storage, repoGetter RepositoryGetter) *Downloader

NewDownloader returns a new charm downloader instance.

func (*Downloader) DownloadAndStore

func (d *Downloader) DownloadAndStore(charmURL *charm.URL, requestedOrigin corecharm.Origin, force bool) (corecharm.Origin, error)

DownloadAndStore looks up the requested charm using the appropriate store, downloads it to a temporary file and passes it to the configured storage API so it can be persisted.

The method ensures that all temporary resources are cleaned up before returning.

type Logger

type Logger interface {
	Tracef(string, ...interface{})
	Debugf(string, ...interface{})
	Warningf(string, ...interface{})
}

Logger defines the logging methods that the package uses.

type RepositoryGetter

type RepositoryGetter interface {
	GetCharmRepository(corecharm.Source) (CharmRepository, error)
}

RepositoryGetter returns a suitable CharmRepository for the specified Source.

type Storage

type Storage interface {
	PrepareToStoreCharm(string) error
	Store(string, DownloadedCharm) error
}

Storage provides an API for storing downloaded charms.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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