charms

package
v0.0.0-...-ac56535 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 28 Imported by: 2

Documentation

Overview

Package charms provides a client for accessing the charms API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCharmDownloader

func NewCharmDownloader(apiCaller base.APICaller) *downloader.Downloader

NewCharmDownloader returns a new charm downloader that wraps the provided API caller.

func NewS3CharmDownloader

func NewS3CharmDownloader(charmGetter CharmGetter, apiCaller base.APICaller) *downloader.Downloader

NewS3CharmDownloader returns a new charm downloader that wraps a s3Caller client for the provided endpoint.

Types

type CharmGetter

type CharmGetter interface {
	// GetCharm returns an io.ReadCloser for the specified object within the
	// specified bucket.
	GetCharm(ctx context.Context, modelUUID, charmName string) (io.ReadCloser, error)
}

CharmGetter defines a way to get charms from a bucket.

type CharmOpener

type CharmOpener interface {
	OpenCharm(curl string) (io.ReadCloser, error)
}

CharmOpener provides the OpenCharm method.

func NewCharmOpener

func NewCharmOpener(apiConn base.APICaller) (CharmOpener, error)

NewCharmOpener returns a charm opener for the specified caller.

type CharmPutter

type CharmPutter interface {
	PutCharm(ctx context.Context, modelUUID, charmRef, curl string, body io.Reader) (string, error)
}

CharmPutter uploads a local charm blob to the controller

type CharmToResolve

type CharmToResolve struct {
	URL         *charm.URL
	Origin      apicharm.Origin
	SwitchCharm bool
}

CharmToResolve holds the charm url and it's channel to be resolved.

type Client

type Client struct {
	base.ClientFacade
	*commoncharms.CharmInfoClient
	// contains filtered or unexported fields
}

Client allows access to the charms API endpoint.

func NewClient

func NewClient(st base.APICallCloser) *Client

NewClient creates a new client for accessing the charms API.

func (*Client) AddCharm

func (c *Client) AddCharm(curl *charm.URL, origin apicharm.Origin, force bool) (apicharm.Origin, error)

AddCharm adds the given charm URL (which must include revision) to the model, if it does not exist yet. Local charms are not supported, only charm store and charm hub URLs. See also AddLocalCharm().

If the AddCharm API call fails because of an authorization error when retrieving the charm from the charm store, an error satisfying params.IsCodeUnauthorized will be returned.

func (*Client) CheckCharmPlacement

func (c *Client) CheckCharmPlacement(applicationName string, curl *charm.URL) error

CheckCharmPlacement checks to see if a charm can be placed into the application. If the application doesn't exist then it is considered fine to be placed there.

func (*Client) GetDownloadInfo

func (c *Client) GetDownloadInfo(curl *charm.URL, origin apicharm.Origin) (DownloadInfo, error)

GetDownloadInfo will get a download information from the given charm URL using the appropriate charm store.

func (*Client) ListCharmResources

func (c *Client) ListCharmResources(curl string, origin apicharm.Origin) ([]charmresource.Resource, error)

ListCharmResources returns a list of associated resources for a given charm.

func (*Client) ResolveCharms

func (c *Client) ResolveCharms(charms []CharmToResolve) ([]ResolvedCharm, error)

ResolveCharms resolves the given charm URLs with an optionally specified preferred channel.

type DownloadInfo

type DownloadInfo struct {
	URL    string
	Origin apicharm.Origin
}

DownloadInfo holds the URL and Origin for a charm that requires downloading on the client side. This is mainly for bundles as we don't resolve bundles on the server.

type LocalCharmClient

type LocalCharmClient struct {
	base.ClientFacade
	// contains filtered or unexported fields
}

LocalCharmClient allows access to the API endpoints required to add a local charm

func NewLocalCharmClient

func NewLocalCharmClient(st base.APICallCloser) (*LocalCharmClient, error)

func (*LocalCharmClient) AddLocalCharm

func (c *LocalCharmClient) AddLocalCharm(curl *charm.URL, ch charm.Charm, force bool, agentVersion version.Number) (*charm.URL, error)

AddLocalCharm prepares the given charm with a local: schema in its URL, and uploads it via the API server, returning the assigned charm URL.

type ResolvedCharm

type ResolvedCharm struct {
	URL            *charm.URL
	Origin         apicharm.Origin
	SupportedBases []corebase.Base
	Error          error
}

ResolvedCharm holds resolved charm data.

type S3CharmOpener

type S3CharmOpener interface {
	OpenCharm(req downloader.Request) (io.ReadCloser, error)
}

CharmOpener provides the OpenCharm method.

func NewS3CharmOpener

func NewS3CharmOpener(charmGetter CharmGetter, apiCaller base.APICaller) S3CharmOpener

NewS3CharmOpener returns a charm opener for the specified s3Caller.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL