Documentation
¶
Index ¶
- func EssentialMetadataFromResponse(charmName string, refreshResult transport.RefreshResponse) (corecharm.EssentialMetadata, error)
- type CharmHubClient
- type CharmHubRepository
- func (c *CharmHubRepository) Download(ctx context.Context, name string, requestedOrigin corecharm.Origin, ...) (corecharm.Origin, *charmhub.Digest, error)
- func (c *CharmHubRepository) GetDownloadURL(ctx context.Context, charmName string, requestedOrigin corecharm.Origin) (*url.URL, corecharm.Origin, error)
- func (c *CharmHubRepository) ListResources(ctx context.Context, charmName string, origin corecharm.Origin) ([]charmresource.Resource, error)
- func (c *CharmHubRepository) ResolveForDeploy(ctx context.Context, arg corecharm.CharmID) (corecharm.ResolvedDataForDeploy, error)
- func (c *CharmHubRepository) ResolveResources(ctx context.Context, resources []charmresource.Resource, id corecharm.CharmID) ([]charmresource.Resource, error)
- func (c *CharmHubRepository) ResolveWithPreferredChannel(ctx context.Context, charmName string, argOrigin corecharm.Origin) (corecharm.ResolvedData, error)
- type CharmHubRepositoryConfig
- type Method
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EssentialMetadataFromResponse ¶
func EssentialMetadataFromResponse(charmName string, refreshResult transport.RefreshResponse) (corecharm.EssentialMetadata, error)
EssentialMetadataFromResponse extracts the essential metadata from the provided charmhub refresh response.
Types ¶
type CharmHubClient ¶
type CharmHubClient 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) // ListResourceRevisions returns a list of resources associated with a given // charm. ListResourceRevisions(ctx context.Context, charm, resource string) ([]transport.ResourceRevision, error) // Refresh retrieves the specified charm from the store and returns the // metadata and configuration. Refresh(ctx context.Context, config charmhub.RefreshConfig) ([]transport.RefreshResponse, error) }
CharmHubClient describes the API exposed by the charmhub client.
type CharmHubRepository ¶
type CharmHubRepository struct {
// contains filtered or unexported fields
}
CharmHubRepository provides an API for charm-related operations using charmhub.
func NewCharmHubRepository ¶
func NewCharmHubRepository(cfg CharmHubRepositoryConfig) (*CharmHubRepository, error)
NewCharmHubRepository returns a new repository instance using the provided charmhub client.
func (*CharmHubRepository) Download ¶
func (c *CharmHubRepository) Download(ctx context.Context, name string, requestedOrigin corecharm.Origin, path string) (corecharm.Origin, *charmhub.Digest, error)
Download retrieves a blob from the store and saves its contents to the specified path.
To get the contents of the blob, read the path on success.
func (*CharmHubRepository) GetDownloadURL ¶
func (c *CharmHubRepository) GetDownloadURL(ctx context.Context, charmName string, requestedOrigin corecharm.Origin) (*url.URL, corecharm.Origin, error)
GetDownloadURL returns the url from which to download the CharmHub charm/bundle defined by the provided charm name and origin. An updated charm origin is also returned with the ID and hash for the charm to be downloaded. If the provided charm origin has no ID, it is assumed that the charm is being installed, not refreshed.
func (*CharmHubRepository) ListResources ¶
func (c *CharmHubRepository) ListResources(ctx context.Context, charmName string, origin corecharm.Origin) ([]charmresource.Resource, error)
ListResources returns the resources for a given charm and origin.
func (*CharmHubRepository) ResolveForDeploy ¶
func (c *CharmHubRepository) ResolveForDeploy(ctx context.Context, arg corecharm.CharmID) (corecharm.ResolvedDataForDeploy, error)
ResolveForDeploy combines ResolveWithPreferredChannel, GetEssentialMetadata and best effort for repositoryResources into 1 call for server side charm deployment. Reducing the number of required calls to a repository.
func (*CharmHubRepository) ResolveResources ¶
func (c *CharmHubRepository) ResolveResources(ctx context.Context, resources []charmresource.Resource, id corecharm.CharmID) ([]charmresource.Resource, error)
ResolveResources looks at the provided charmhub and backend (already downloaded) resources to determine which to use. Provided (uploaded) take precedence. If charmhub has a newer resource than the back end, use that.
func (*CharmHubRepository) ResolveWithPreferredChannel ¶
func (c *CharmHubRepository) ResolveWithPreferredChannel(ctx context.Context, charmName string, argOrigin corecharm.Origin) (corecharm.ResolvedData, error)
ResolveWithPreferredChannel defines a way using the given charm name and charm origin (platform and channel) to locate a matching charm against the Charmhub API.
type CharmHubRepositoryConfig ¶
type CharmHubRepositoryConfig struct { // An HTTP client that is injected when making Charmhub API calls. CharmhubHTTPClient charmhub.HTTPClient // CharmHubURL is the URL to use for CharmHub API calls. CharmhubURL string Logger logger.Logger }
CharmHubRepositoryConfig holds the config options require to construct a CharmHubRepository.
type Method ¶
type Method string
Method describes the method for requesting the charm using the RefreshAPI.
const ( // MethodRevision utilizes an install action by the revision only. A // channel must be in the origin, however it's not used in this request, // but saved in the origin for future use. MethodRevision Method = "revision" // MethodChannel utilizes an install action by the channel only. MethodChannel Method = "channel" // MethodID utilizes an refresh action by the id, revision and // channel (falls back to latest/stable if channel is not found). MethodID Method = "id" )