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

package resource

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

The resource package provides the functionality of the "resources" feature in Juju. The various pieces are connected to the Juju machinery in component/all/resource.go.

The resource package provides the functionality of the "resources" feature in Juju.

Index

Package Files

application.go component.go content.go opened.go resource.go serialization.go sort.go unit.go

Constants

const ComponentName = "resources"

ComponentName is the name of the Juju component for resource management.

const FacadeName = "Resources"

FacadeName is the name of the api server facade.

func AsMap Uses

func AsMap(resources []Resource) map[string]Resource

AsMap returns the mapping of resource name to info for each of the given resources.

func DeserializeFingerprint Uses

func DeserializeFingerprint(fpSum []byte) (resource.Fingerprint, error)

DeserializeFingerprint converts the serialized fingerprint back into a Fingerprint. "zero" values are treated appropriately.

func Sort Uses

func Sort(resources []Resource)

Sort sorts the provided resources.

type ApplicationResources Uses

type ApplicationResources struct {
    // Resources are the current version of the resource for the application that
    // resource-get will retrieve.
    Resources []Resource

    // CharmStoreResources provides the resource info from the charm
    // store for each of the application's resources. The information from
    // the charm store is current as of the last time the charm store
    // was polled. Each entry here corresponds to the same indexed entry
    // in the Resources field.
    CharmStoreResources []resource.Resource

    // UnitResources reports the currently-in-use version of resources for each
    // unit.
    UnitResources []UnitResources
}

ApplicationResources contains the list of resources for the application and all its units.

func (ApplicationResources) Updates Uses

func (sr ApplicationResources) Updates() ([]resource.Resource, error)

Updates returns the list of charm store resources corresponding to the application's resources that are out of date. Note that there must be a charm store resource for each of the application resources and vice-versa. If they are out of sync then an error is returned.

type Content Uses

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 GenerateContent Uses

func GenerateContent(reader io.ReadSeeker) (Content, error)

GenerateContent returns a new Content for the given data stream.

type Opened Uses

type Opened struct {
    Resource
    io.ReadCloser
}

Opened provides both the resource info and content.

func (Opened) Close Uses

func (o Opened) Close() error

func (Opened) Content Uses

func (o Opened) Content() Content

Content returns the "content" for the opened resource.

type Opener Uses

type Opener interface {
    // OpenResource returns an opened resource with a reader that will
    // stream the resource content.
    OpenResource(name string) (Opened, error)
}

Opener exposes the functionality for opening a resource.

type Resource Uses

type Resource struct {
    resource.Resource

    // ID uniquely identifies a resource-application pair within the model.
    // Note that the model ignores pending resources (those with a
    // pending ID) except for in a few clearly pending-related places.
    // ID may be empty if the ID (assigned by the model) is not known.
    ID  string

    // PendingID identifies that this resource is pending and
    // distinguishes it from other pending resources with the same model
    // ID (and from the active resource). The active resource for the
    // applications will not have PendingID set.
    PendingID string

    // ApplicationID identifies the application for the resource.
    ApplicationID string

    // Username is the ID of the user that added the revision
    // to the model (whether implicitly or explicitly).
    Username string

    // Timestamp indicates when the resource was added to the model.
    Timestamp time.Time
}

Resource defines a single resource within a Juju model.

Each application will have have exactly the same resources associated with it as are defined in the charm's metadata, no more, no less. When associated with the application the resource may have additional information associated with it.

A resource may be a "placeholder", meaning it is only partially populated before an upload (whether local or from the charm store). In that case the following fields are not set:

Timestamp
Username

For "upload" placeholders, the following additional fields are not set:

Fingerprint
Size

A resource may also be added to the model as "pending", meaning it is queued up to be used as a resource for the application. Until it is "activated", a pending resources is virtually invisible. There may be more that one pending resource for a given resource ID.

func (Resource) IsPlaceholder Uses

func (res Resource) IsPlaceholder() bool

IsPlaceholder indicates whether or not the resource is a "placeholder" (partially populated pending an upload).

func (Resource) RevisionString Uses

func (res Resource) RevisionString() string

RevisionString returns the human-readable revision for the resource.

func (Resource) TimestampGranular Uses

func (res Resource) TimestampGranular() time.Time

TimestampGranular returns the timestamp at a resolution of 1 second.

func (Resource) Validate Uses

func (res Resource) Validate() error

Validate ensures that the spec is valid.

type Unit Uses

type Unit interface {
    // Name is the name of the Unit.
    Name() string

    // ApplicationName is the name of the application to which the unit belongs.
    ApplicationName() string

    // CharmURL returns the unit's charm URL.
    CharmURL() (*charm.URL, bool)
}

Unit represents a Juju unit.

type UnitResources Uses

type UnitResources struct {
    // Tag is the tag of the unit.
    Tag names.UnitTag

    // Resources are the resource versions currently in use by this unit.
    Resources []Resource

    // DownloadProgress indicates the number of bytes of the unit's
    // resources, identified by name, that have been downloaded so far
    // by the uniter. This only applies to resources that are currently
    // being downloaded to the unit. All other resources for the unit
    // will not be found in the map.
    DownloadProgress map[string]int64
}

UnitResources conains the list of resources used by a unit.

Directories

PathSynopsis
api
api/client
api/private
api/private/client
charmstore
context
context/cmd
context/internal
resourceadapters
resourcetestingThis package provides helpers for testing with resources.
workers

Package resource imports 10 packages (graph) and is imported by 343 packages. Updated 2019-09-14. Refresh now. Tools for package owners.