resources

package
v0.0.0-...-439fd0a Latest Latest
Warning

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

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

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

func NewContentChecker(content Content) *Checker

NewContentChecker returns a Checker for the provided data.

func (Checker) Verify

func (c Checker) Verify() error

Verify implements ContentChecker.

func (Checker) WrapReader

func (c Checker) WrapReader(reader io.Reader) io.Reader

WrapReader implements ContentChecker.

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 Logger

type Logger interface {
	// Errorf formats the provided log message and writes it to the log.
	Errorf(string, ...interface{})
}

Logger exposes the logger functionality needed by closeAndLog.

type OpenedResource

type OpenedResource struct {
	resources.Resource
	io.ReadCloser
}

OpenedResource wraps the resource info and reader returned from the API.

func OpenResource

func OpenResource(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(resourceName string) (resources.Resource, io.ReadCloser, error)
}

OpenedResourceClient exposes the API functionality needed by OpenResource.

type ResourcesHookContext

type ResourcesHookContext struct {
	Client       OpenedResourceClient
	ResourcesDir string
	Logger       Logger
}

ResourcesHookContext is the implementation of runner.ContextResources.

func (*ResourcesHookContext) DownloadResource

func (ctx *ResourcesHookContext) DownloadResource(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.

Jump to

Keyboard shortcuts

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