resource

package
v7.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sort

func Sort(resources []Resource)

Sort sorts the provided resources.

Types

type Fingerprint

type Fingerprint struct {
	hash.Fingerprint
}

Fingerprint represents the unique fingerprint value of a resource's data.

func GenerateFingerprint

func GenerateFingerprint(reader io.Reader) (Fingerprint, error)

GenerateFingerprint returns the fingerprint for the provided data.

func NewFingerprint

func NewFingerprint(raw []byte) (Fingerprint, error)

NewFingerprint returns wraps the provided raw fingerprint bytes. This function roundtrips with Fingerprint.Bytes().

func ParseFingerprint

func ParseFingerprint(raw string) (Fingerprint, error)

ParseFingerprint returns wraps the provided raw fingerprint string. This function roundtrips with Fingerprint.String().

type FingerprintHash

type FingerprintHash struct {
	stdhash.Hash
}

Fingerprint is a hash that may be used to generate fingerprints.

func NewFingerprintHash

func NewFingerprintHash() *FingerprintHash

NewFingerprintHash returns a hash that may be used to create fingerprints.

func (FingerprintHash) Fingerprint

func (fph FingerprintHash) Fingerprint() Fingerprint

Fingerprint returns the current fingerprint of the hash.

type Meta

type Meta struct {
	// Name identifies the resource.
	Name string

	// Type identifies the type of resource (e.g. "file").
	Type Type

	// Path is the relative path of the file or directory where the
	// resource will be stored under the unit's data directory. The path
	// is resolved against a subdirectory assigned to the resource. For
	// example, given an application named "spam", a resource "eggs", and a
	// path "eggs.tgz", the fully resolved storage path for the resource
	// would be:
	//   /var/lib/juju/agent/spam-0/resources/eggs/eggs.tgz
	Path string

	// Description holds optional user-facing info for the resource.
	Description string
}

Meta holds the information about a resource, as stored in a charm's metadata.

func (Meta) Validate

func (meta Meta) Validate() error

Validate checks the resource metadata to ensure the data is valid.

type Origin

type Origin int

Origin identifies where a charm's resource comes from.

const (
	OriginUpload Origin
	OriginStore
)

These are the valid resource origins.

func ParseOrigin

func ParseOrigin(value string) (Origin, error)

ParseOrigin converts the provided string into an Origin. If it is not a known origin then an error is returned.

func (Origin) String

func (o Origin) String() string

String returns the printable representation of the origin.

func (Origin) Validate

func (o Origin) Validate() error

Validate ensures that the origin is correct.

type Resource

type Resource struct {
	Meta

	// Origin identifies where the resource will come from.
	Origin Origin

	// Revision is the charm store revision of the resource.
	Revision int

	// Fingerprint is the SHA-384 checksum for the resource blob.
	Fingerprint Fingerprint

	// Size is the size of the resource, in bytes.
	Size int64
}

Resource describes a charm's resource in the charm store.

func (Resource) Validate

func (res Resource) Validate() error

Validate checks the payload class to ensure its data is valid.

type Type

type Type int

Type enumerates the recognized resource types.

const (
	TypeFile Type
	TypeContainerImage
)

These are the valid resource types (except for unknown).

func ParseType

func ParseType(value string) (Type, error)

ParseType converts a string to a Type. If the given value does not match a recognized type then an error is returned.

func (Type) String

func (rt Type) String() string

String returns the printable representation of the type.

func (Type) Validate

func (rt Type) Validate() error

Validate ensures that the type is valid.

Jump to

Keyboard shortcuts

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