Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker provides the functionality for verifying that read data is correct.
func NewContentChecker ¶
NewContentChecker returns a Checker for the provided data.
type Content ¶
type Content struct { // Data holds the resource content, ready to be read (once). Data io.Reader // Size is the byte count of the data. Size int64 // Fingerprint holds the checksum of the data. Fingerprint charmresource.Fingerprint }
Content holds a reader for the content of a resource along with details about that content.
func (Content) Verify ¶
func (c Content) Verify(size int64, fp charmresource.Fingerprint) error
Verify ensures that the actual resource content details match the expected ones.
type OpenedResource ¶
type OpenedResource struct { resource.Resource io.ReadCloser }
OpenedResource wraps the resource info and reader returned from the API.
func OpenResource ¶
func OpenResource(ctx context.Context, name string, client OpenedResourceClient) (*OpenedResource, error)
OpenResource opens the identified resource using the provided client.
func (OpenedResource) Content ¶
func (or OpenedResource) Content() Content
Content returns the "content" for the opened resource.
type OpenedResourceClient ¶
type OpenedResourceClient interface { // GetResource returns the resource info and content for the given // name (and unit-implied application). GetResource(ctx context.Context, resourceName string) (resource.Resource, io.ReadCloser, error) }
OpenedResourceClient exposes the API functionality needed by OpenResource.
type ResourcesHookContext ¶
type ResourcesHookContext struct { Client OpenedResourceClient ResourcesDir string Logger logger.Logger }
ResourcesHookContext is the implementation of runner.ContextResources.
func (*ResourcesHookContext) DownloadResource ¶
func (ctx *ResourcesHookContext) DownloadResource(stdCtx context.Context, name string) (filePath string, _ error)
DownloadResource downloads the named resource and returns the path to which it was downloaded. If the resource does not exist or has not been uploaded yet then errors.NotFound is returned.
Note that the downloaded file is checked for correctness.