repository

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 23 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)
	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(charmURL *charm.URL, requestedOrigin corecharm.Origin, macaroons macaroon.Slice, 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(charmURL *charm.URL, requestedOrigin corecharm.Origin, macaroons macaroon.Slice) (*url.URL, corecharm.Origin, error)

GetDownloadURL returns the url from which to download the CharmHub charm/bundle defined by the provided curl and charm 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(charmURL *charm.URL, origin corecharm.Origin, macaroons macaroon.Slice) ([]charmresource.Resource, error)

ListResources returns the resources for a given charm and origin.

func (*CharmHubRepository) ResolveWithPreferredChannel

func (c *CharmHubRepository) ResolveWithPreferredChannel(charmURL *charm.URL, requestedOrigin corecharm.Origin, macaroons macaroon.Slice) (*charm.URL, corecharm.Origin, []string, error)

ResolveWithPreferredChannel defines a way using the given charm URL and charm origin (platform and channel) to locate a matching charm against the Charmhub API.

There are a few things to note in the attempt to resolve the charm and it's supporting series.

  1. The algorithm for this is terrible. For charmstore lookups, only one request is required, unfortunately for Charmhub the worst case for this will be 2. Most of the initial requests from the client will hit this first time around (think `juju deploy foo`) without a series (client can then determine what to call the real request with) will be default of 2 requests.
  2. Attempting to find the default series will require 2 requests so that we can find the correct charm ID ensure that the default series exists along with the revision.
  3. In theory we could just return most of this information without the re-request, but we end up with missing data and potential incorrect charm downloads later.

When charmstore goes, we could potentially rework how the client requests the store.

type CharmStoreClient

type CharmStoreClient interface {
	Get(charmURL *charm.URL, archivePath string) (*charm.CharmArchive, error)
	ResolveWithPreferredChannel(charmURL *charm.URL, channel csparams.Channel) (*charm.URL, csparams.Channel, []string, error)
	Meta(*charm.URL, interface{}) (*charm.URL, error)
	GetFileFromArchive(charmURL *charm.URL, filename string) (io.ReadCloser, error)
}

CharmStoreClient describes the API exposed by the charmstore client.

type CharmStoreRepository

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

CharmStoreRepository provides an API for charm-related operations using charmstore.

func NewCharmStoreRepository

func NewCharmStoreRepository(logger Logger, charmstoreURL string) *CharmStoreRepository

NewCharmStoreRepository returns a new repository instance using the provided charmstore client.

func (*CharmStoreRepository) DownloadCharm

func (c *CharmStoreRepository) DownloadCharm(charmURL *charm.URL, requestedOrigin corecharm.Origin, macaroons macaroon.Slice, archivePath string) (corecharm.CharmArchive, corecharm.Origin, error)

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

func (*CharmStoreRepository) GetDownloadURL

func (c *CharmStoreRepository) GetDownloadURL(charmURL *charm.URL, requestedOrigin corecharm.Origin, macaroons macaroon.Slice) (*url.URL, corecharm.Origin, error)

GetDownloadURL resolves the specified charm/bundle URL into a url.URL which can be used to download the blob associated with the charm/bundle.

func (*CharmStoreRepository) GetEssentialMetadata

func (c *CharmStoreRepository) 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 (*CharmStoreRepository) ListResources

func (c *CharmStoreRepository) ListResources(charmURL *charm.URL, _ corecharm.Origin, _ macaroon.Slice) ([]charmresource.Resource, error)

ListResources returns the resources for a given charm and origin. This is a no-op for charmstore.

func (*CharmStoreRepository) ResolveWithPreferredChannel

func (c *CharmStoreRepository) ResolveWithPreferredChannel(charmURL *charm.URL, requestedOrigin corecharm.Origin, macaroons macaroon.Slice) (*charm.URL, corecharm.Origin, []string, error)

ResolveWithPreferredChannel queries the store and resolves the provided charm URL/origin tuple to a charm URL that corresponds to a downloadable charm/bundle from the store.

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