repository

package
v0.0.0-...-51a0f74 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CharmHubClient

type CharmHubClient interface {
	DownloadAndRead(ctx context.Context, resourceURL *url.URL, archivePath string, options ...charmhub.DownloadOption) (*charm.CharmArchive, error)
	ListResourceRevisions(ctx context.Context, charm, resource string) ([]transport.ResourceRevision, error)
	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(logger Logger, chClient CharmHubClient) *CharmHubRepository

NewCharmHubRepository returns a new repository instance using the provided charmhub client.

func (*CharmHubRepository) DownloadCharm

func (c *CharmHubRepository) DownloadCharm(charmName string, requestedOrigin corecharm.Origin, archivePath string) (corecharm.CharmArchive, corecharm.Origin, error)

DownloadCharm retrieves specified charm from the store and saves its contents to the specified path.

func (*CharmHubRepository) GetDownloadURL

func (c *CharmHubRepository) GetDownloadURL(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) GetEssentialMetadata

func (c *CharmHubRepository) GetEssentialMetadata(reqs ...corecharm.MetadataRequest) ([]corecharm.EssentialMetadata, error)

GetEssentialMetadata resolves each provided MetadataRequest and returns back a slice with the results. The results include the minimum set of metadata that is required for deploying each charm.

func (*CharmHubRepository) ListResources

func (c *CharmHubRepository) ListResources(charmName string, origin corecharm.Origin) ([]charmresource.Resource, error)

ListResources returns the resources for a given charm and origin.

func (*CharmHubRepository) ResolveForDeploy

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(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(charmName string, argOrigin corecharm.Origin) (*charm.URL, corecharm.Origin, []corecharm.Platform, 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 Logger

type Logger interface {
	Errorf(string, ...interface{})
	Tracef(string, ...interface{})
}

Logger describes a logging API.

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"
)

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