Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCharmHubOpener ¶
func NewCharmHubOpener(modelConfigService ModelConfigService) resourceClientGetter
Types ¶
type CharmHub ¶
type CharmHub 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) // Refresh gets the recommended revisions to install/refresh for the given // charms, including resource revisions. Refresh(ctx context.Context, config charmhub.RefreshConfig) ([]transport.RefreshResponse, error) }
CharmHub represents methods required from a charmhub lient talking to the charmhub api used by the local CharmHubClient
type CharmHubClient ¶
type CharmHubClient struct {
// contains filtered or unexported fields
}
func (*CharmHubClient) GetResource ¶
func (ch *CharmHubClient) GetResource(ctx context.Context, req ResourceRequest) (ResourceData, error)
GetResource returns data about the resource including an io.ReadCloser to download the resource. The caller is responsible for closing it.
type CharmID ¶
type CharmID struct { // URL of the given charm, includes the reference name and a revision. // Old style charm URLs are also supported i.e. charmstore. URL *charm.URL // Origin holds the origin of a charm. This includes the source of the // charm, along with the revision and channel to identify where the charm // originated from. Origin state.CharmOrigin }
CharmID represents the underlying charm for a given application. This includes both the URL and the origin.
type Downloader ¶
type Downloader interface { // Download looks up the requested resource using the appropriate store, // downloads it to a temporary file and returns a ReadCloser that deletes the // temporary file on closure. // // The resulting resource is verified to have the right hash and size. // // Returns [ErrUnexpectedHash] if the hash of the downloaded resource does not // match the expected hash. // Returns [ErrUnexpectedSize] if the size of the downloaded resource does not // match the expected size. Download(ctx context.Context, url *url.URL, sha384 string, size int64) (io.ReadCloser, error) }
Downloader defines an API for downloading and storing charms.
type ModelConfigService ¶
type ModelConfigService interface { // ModelConfig returns the current config for the model. ModelConfig(context.Context) (*config.Config, error) }
ModelConfigService provides access to the model configuration.
type ResourceClient ¶
type ResourceClient interface { // GetResource returns a reader for the resource's data. That data // is streamed from the charm store. The charm's revision, if any, // is ignored. GetResource(context.Context, ResourceRequest) (ResourceData, error) }
ResourceClient provides the functionality for getting a resource file.
type ResourceData ¶
type ResourceData struct { // ReadCloser holds the bytes for the resource. io.ReadCloser // Resource holds the metadata for the resource. Resource charmresource.Resource }
ResourceData represents the response from store about a request for resource bytes.
type ResourceRequest ¶
type ResourceRequest struct { // Channel is the channel from which to request the resource info. CharmID CharmID // Name is the name of the resource we're asking about. Name string // Revision is the specific revision of the resource we're asking about. Revision int }
ResourceRequest represents a request for information about a resource.
type ResourceRetryClient ¶
type ResourceRetryClient struct { ResourceClient // RetryArgs defines the behaviour of the Call function. RetryArgs retry.CallArgs // contains filtered or unexported fields }
ResourceRetryClient is a wrapper around a Juju repository client that retries GetResource() calls.
func NewRetryClient ¶
func NewRetryClient(client ResourceClient, logger logger.Logger) *ResourceRetryClient
NewRetryClient creates a new retry client for getting the resources with the resource getter.
func (ResourceRetryClient) GetResource ¶
func (client ResourceRetryClient) GetResource(ctx context.Context, req ResourceRequest) (ResourceData, error)
GetResource returns a reader for the resource's data.