charm: github.com/juju/charm/resource Index | Files

package resource

import "github.com/juju/charm/resource"

Index

Package Files

fingerprint.go meta.go origin.go resource.go sort.go type.go

func Sort Uses

func Sort(resources []Resource)

Sort sorts the provided resources.

type Fingerprint Uses

type Fingerprint struct {
    hash.Fingerprint
}

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

func GenerateFingerprint Uses

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

GenerateFingerprint returns the fingerprint for the provided data.

func NewFingerprint Uses

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

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

func ParseFingerprint Uses

func ParseFingerprint(raw string) (Fingerprint, error)

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

type FingerprintHash Uses

type FingerprintHash struct {
    stdhash.Hash
}

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

func NewFingerprintHash Uses

func NewFingerprintHash() *FingerprintHash

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

func (FingerprintHash) Fingerprint Uses

func (fph FingerprintHash) Fingerprint() Fingerprint

Fingerprint returns the current fingerprint of the hash.

type Meta Uses

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 Uses

func (meta Meta) Validate() error

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

type Origin Uses

type Origin int

Origin identifies where a charm's resource comes from.

const (
    OriginUpload Origin
    OriginStore
)

These are the valid resource origins.

func ParseOrigin Uses

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 Uses

func (o Origin) String() string

String returns the printable representation of the origin.

func (Origin) Validate Uses

func (o Origin) Validate() error

Validate ensures that the origin is correct.

type Resource Uses

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 Uses

func (res Resource) Validate() error

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

type Type Uses

type Type int

Type enumerates the recognized resource types.

const (
    TypeFile Type
    TypeContainerImage
)

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

func ParseType Uses

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 Uses

func (rt Type) String() string

String returns the printable representation of the type.

func (Type) Validate Uses

func (rt Type) Validate() error

Validate ensures that the type is valid.

Package resource imports 7 packages (graph). Updated 2018-09-14. Refresh now. Tools for package owners.