resourceadapters

package
v0.0.0-...-9ec3720 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeployResources

func DeployResources(
	applicationID string,
	chID client.CharmID,
	csMac *macaroon.Macaroon,
	filesAndRevisions map[string]string,
	resources map[string]charmresource.Meta,
	conn base.APICallCloser,
	filesystem modelcmd.Filesystem,
) (ids map[string]string, err error)

DeployResources uploads the bytes for the given files to the server and creates pending resource metadata for the all resource mentioned in the metadata. It returns a map of resource name to pending resource IDs.

func NewAPIClient

func NewAPIClient(apiCaller base.APICallCloser) (*client.Client, error)

NewAPIClient is mostly a copy of the newClient code in component/all/resources.go. It lives here because it simplifies this code immensely.

func NewResourceOpener

func NewResourceOpener(st ResourceOpenerState, unitName string) (opener resource.Opener, err error)

NewResourceOpener returns a new resource.Opener for the given unit.

The caller owns the State provided. It is the caller's responsibility to close it.

func NewResourceOpenerForApplication

func NewResourceOpenerForApplication(st ResourceOpenerState, applicationName string) (opener resource.Opener, err error)

NewResourceOpenerForApplication returns a new resource.Opener for the given app.

The caller owns the State provided. It is the caller's responsibility to close it.

Types

type Application

type Application interface {
	CharmOrigin() *corestate.CharmOrigin
	CharmURL() (*charm.URL, bool)
	Name() string
	Tag() names.Tag
}

Application represents application methods required to open a resource.

type CharmHub

type CharmHub interface {
	DownloadResource(ctx context.Context, resourceURL *url.URL) (r io.ReadCloser, err error)
	Refresh(ctx context.Context, config charmhub.RefreshConfig) ([]transport.RefreshResponse, error)
}

CharmHub represents methods required from a charmhub client talking to the charmhub api used by the local CharmHubClient

type CharmHubClient

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

func (*CharmHubClient) GetResource

GetResource returns data about the resource including an io.ReadCloser to download the resource. The caller is responsible for closing it.

type DeployResourcesFunc

type DeployResourcesFunc func(
	applicationID string,
	chID client.CharmID,
	csMac *macaroon.Macaroon,
	filesAndRevisions map[string]string,
	resources map[string]charmresource.Meta,
	conn base.APICallCloser,
	filesystem modelcmd.Filesystem,
) (ids map[string]string, err error)

DeployResourcesFunc is the function type of DeployResources.

type Logger

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

type Model

type Model interface {
	Config() (*config.Config, error)
}

Model represents model methods required to open a resource.

type ResourceClient

type ResourceClient interface {
	GetResource(req repositories.ResourceRequest) (data charmstore.ResourceData, err error)
}

ResourceClient defines a set of functionality that a client needs to define to support resources.

type ResourceOpener

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

ResourceOpener is a ResourceOpener for the charm store.

func (*ResourceOpener) OpenResource

func (ro *ResourceOpener) OpenResource(name string) (o resource.Opened, err error)

OpenResource implements server.ResourceOpener.

type ResourceOpenerState

type ResourceOpenerState interface {
	// required for csClientState
	Charm(*charm.URL) (*corestate.Charm, error)
	ControllerConfig() (controller.Config, error)

	// required for the chClientState
	Model() (Model, error)

	// required for NewResourceOpener and OpenResource
	Resources() (Resources, error)
	Unit(string) (Unit, error)
	Application(string) (Application, error)
}

ResourceOpenerState represents methods from state required to implement a resource Opener.

func NewResourceOpenerState

func NewResourceOpenerState(st *corestate.State) ResourceOpenerState

NewResourceOpenerState wraps a State pointer for passing into NewResourceOpener/NewResourceOpenerForApplication.

type ResourceRetryClient

type ResourceRetryClient struct {
	ResourceClient
	// contains filtered or unexported fields
}

ResourceRetryClient is a wrapper around a Juju repository client that retries GetResource() calls.

func (ResourceRetryClient) GetResource

GetResource returns a reader for the resource's data.

type ResourceRetryClientGetter

type ResourceRetryClientGetter interface {
	NewClient() (*ResourceRetryClient, error)
}

ResourceRetryClientGetter defines an interface for creating a new resource retry clients.

type ResourceRetryClientGetterFn

type ResourceRetryClientGetterFn func(st ResourceOpenerState) ResourceRetryClientGetter

ResourceRetryClientGetterFn allows the creation of ResourceRetryClientGetter from a given state.

type Resources

type Resources interface {
	// GetResource returns the identified resource.
	GetResource(applicationID, name string) (resource.Resource, error)
	// OpenResource returns the metadata for a resource and a reader for the resource.
	OpenResource(applicationID, name string) (resource.Resource, io.ReadCloser, error)
	// OpenResourceForUniter returns the metadata for a resource and a reader for the resource.
	OpenResourceForUniter(unit resource.Unit, name string) (resource.Resource, io.ReadCloser, error)
	// SetResource adds the resource to blob storage and updates the metadata.
	SetResource(applicationID, userID string, res charmresource.Resource, r io.Reader) (resource.Resource, error)
}

Resources represents the methods used by resourceCache from state.Resources .

type Unit

type Unit interface {
	resource.Unit

	Application() (Application, error)
	Tag() names.Tag
}

Unit represents unit methods required to open a resource.

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