resource

package
v0.0.0-...-0a271de Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: AGPL-3.0 Imports: 8 Imported by: 3

Documentation

Overview

Package resource provides the domain types for handling charm resources once associated with application. Resource creation and link to an application is done at the creation of the application, so the logic for resource creation belongs to application domain.

Every resource is either a file resource or an OCI image resource. They are defined in the charm metadata. After deployment, the specific resource details are associated with the application deployed from the charm.

For each resource, we keep track of 4 pieces of information:

  • resources are instantiations of the resource definitions from the charm metadata. They hold the origin and revision and can be linked to a blob. They have the state "available".

  • application resources represent which resource revision or blob the application is currently using.

  • unit resources represent which resource instance the unit is currently using.

  • repository resources represent the latest revision available in charm repository. These have the state "potential".

Resources can be refreshed independently of charm revisions, but must exist in the current charm version used by the application.

Resources can be uploaded by a client. In this case, they will not be downloaded from charm repository, will not have revision, and their potential updated revision will not be tracked (as it cannot be known).

Resource types are stored in this package to ensure correct handling and representation within the domain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddResourceDetails

type AddResourceDetails struct {
	// Name is resource name.
	Name string
	// Origin is where the resource comes from.
	Origin charmresource.Origin
	// Revision is a optional revision value, not required for uploaded resources.
	Revision *int
}

AddResourceDetails contains details of the resource to be added before the application exists.

type AddResourcesBeforeApplicationArgs

type AddResourcesBeforeApplicationArgs struct {
	// ApplicationName is the unique name of the application.
	ApplicationName string
	// CharmLocator is the unique identifier of the charm.
	CharmLocator charm.CharmLocator
	// ResourceDetails contains individual resource details.
	ResourceDetails []AddResourceDetails
}

AddResourcesBeforeApplicationArgs holds arguments to indicate a resources revision or upload before the application has been created.

type GetApplicationResourceIDArgs

type GetApplicationResourceIDArgs struct {
	ApplicationID application.ID
	Name          string
}

GetApplicationResourceIDArgs holds the arguments for the GetApplicationResourceID method.

type ImportResourceInfo

type ImportResourceInfo struct {
	// Name is the name of the resource.
	Name string
	// Origin identifies where the resource will come from.
	Origin charmresource.Origin
	// Revision is the charm store revision of the resource.
	Revision int
	// Timestamp is the time the resource was added to the model.
	Timestamp time.Time
}

ImportResourceInfo contains information about a single resource for the ImportResources method.

type ImportResourcesArg

type ImportResourcesArg struct {
	// ApplicationName is the name of the application these resources are
	// associated with.
	ApplicationName string
	// ApplicationResources are the available resources on the application.
	Resources []ImportResourceInfo
	// UnitResources contains information about the units using the resources in
	// ApplicationResources.
	UnitResources []ImportUnitResourceInfo
}

ImportResourcesArg is a single argument for the ImportResources method.

type ImportResourcesArgs

type ImportResourcesArgs []ImportResourcesArg

ImportResourcesArgs are the arguments for SetResource.

type ImportUnitResourceInfo

type ImportUnitResourceInfo struct {
	ImportResourceInfo

	// UnitName is the name of the unit using the resource.
	UnitName string
}

ImportUnitResourceInfo contains information about a single unit resource for the ImportResources method.

type RecordStoredResourceArgs

type RecordStoredResourceArgs struct {
	// ResourceUUID is the unique identifier of the resource.
	ResourceUUID coreresource.UUID
	// StorageID is the store ID of the resources' blob.
	StorageID coreresourcestore.ID
	// RetrievedBy is the identity of the entity that retrieved the resource.
	// This field is optional.
	RetrievedBy string
	// RetrievedByType is the type of entity that retrieved the resource. This
	// field is optional.
	RetrievedByType coreresource.RetrievedByType
	// ResourceType is the type of the resource
	ResourceType charmresource.Type
	// IncrementCharmModifiedVersion indicates weather the charm modified
	// version should be incremented or not.
	IncrementCharmModifiedVersion bool
	// Size is the size in bytes of the resource blob.
	Size int64
	// SHA384 is the hash of the resource blob.
	SHA384 string
}

RecordStoredResourceArgs holds the arguments for record stored resource state method.

type SetRepositoryResourcesArgs

type SetRepositoryResourcesArgs struct {
	// ApplicationID is the id of the application having these resources.
	ApplicationID application.ID
	// CharmID is the unique identifier for a charm to update resources.
	CharmID corecharm.ID
	// Info is a slice of resource data received from the repository.
	Info []charmresource.Resource
	// LastPolled indicates when the resource data was last polled.
	LastPolled time.Time
}

SetRepositoryResourcesArgs holds the arguments for the SetRepositoryResources method.

type StateType

type StateType string

StateType indicates if a resource is available to be used on the controller or not.

const (
	// StatePotential indicates that a resource refers to a version that could
	// potentially be downloaded from charmhub. Potential resources are used to
	// let users know a resource can be upgraded.
	StatePotential StateType = "potential"
	// StateAvailable indicates that a resource refers to an active resource on
	// the controller that may be used by applications and units.
	StateAvailable StateType = "available"
)

func (StateType) String

func (s StateType) String() string

type StateUpdateUploadResourceArgs

type StateUpdateUploadResourceArgs struct {
	// ResourceType is the type of the resource
	ResourceType charmresource.Type
	// ResourceUUID is the unique identifier of the resource.
	ResourceUUID coreresource.UUID
}

StateUpdateUploadResourceArgs holds arguments for the state method to update the resource to expect a new blob to be uploaded.

type StoreResourceArgs

type StoreResourceArgs struct {
	// ResourceUUID is the unique identifier of the resource.
	ResourceUUID coreresource.UUID
	// Reader is a reader for the resource blob.
	Reader io.Reader
	// RetrievedBy is the identity of the entity that retrieved the resource.
	// This field is optional.
	RetrievedBy string
	// RetrievedByType is the type of entity that retrieved the resource. This
	// field is optional.
	RetrievedByType coreresource.RetrievedByType
	// Size is the size in bytes of the resource blob.
	Size int64
	// Fingerprint is the hash of the resource blob.
	Fingerprint charmresource.Fingerprint
}

StoreResourceArgs holds the arguments for resource storage methods.

type UpdateResourceRevisionArgs

type UpdateResourceRevisionArgs struct {
	// ResourceUUID is the unique identifier of the resource.
	ResourceUUID coreresource.UUID
	// Revision is the revision of the resource to use.
	Revision int
}

UpdateResourceRevisionArgs holds arguments to update a resource to have a new revision.

type UpdateUploadResourceArgs

type UpdateUploadResourceArgs struct {
	// ApplicationID is the ID of the application this resource belongs to.
	ApplicationID application.ID
	// Name is the resource name.
	Name string
}

UpdateUploadResourceArgs holds arguments to update the resource to expect a new blob to be uploaded.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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