Documentation
¶
Overview ¶
Package charmdownloader is responsible for downloading charms and bundles from the charm store. It ensures that the downloaded charm is the correct hash and that it is stored in a location that is suitable for access by other parts of the system.
Index ¶
Constants ¶
const ( // ErrInvalidDigestHash is returned when the hash of the downloaded charm // does not match the expected hash. ErrInvalidDigestHash = errors.ConstError("invalid origin hash") // ErrInvalidOriginHash is returned when the hash of the actual origin // does not match the expected hash. ErrInvalidOriginHash = errors.ConstError("invalid origin hash") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CharmDownloader ¶
type CharmDownloader struct {
// contains filtered or unexported fields
}
CharmDownloader implements store-agnostic download and persistence of charm blobs.
func NewCharmDownloader ¶
func NewCharmDownloader(client DownloadClient, logger logger.Logger) *CharmDownloader
NewCharmDownloader returns a new charm downloader instance.
func (*CharmDownloader) Download ¶
func (d *CharmDownloader) Download(ctx context.Context, url *url.URL, hash string) (_ *DownloadResult, err error)
Download 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 resulting charm is verified to be the right hash. It expected that the origin will always have the correct hash following this call.
Returns [ErrInvalidHash] if the hash of the downloaded charm does not match the expected hash.
type DownloadClient ¶
type DownloadClient interface { // Download retrieves the specified charm from the store and saves its // contents to the specified path. Read the path to get the contents of the // charm. Download(ctx context.Context, url *url.URL, path string, options ...charmhub.DownloadOption) (*charmhub.Digest, error) }
DownloadClient describes the API exposed by the charmhub client.