Documentation
¶
Overview ¶
Package resources contains API calls for functionality related to listing and indicating which resource an application should use.
AddPendingResource handles 2 main scenarios:
- A resource is provided to juju before the application exists. With the current juju cli, this can happen during bundle or local charm deployment.
- A resource needs to be updated by running the `juju refresh` command.
In juju 4.x, AddPendingResource returns the resource UUID for use by the juju client to optionally provide to the Upload method. In prior juju versions, a pending resource UUID was return and later reconciled in mongo when the application was created or during upload.
The actual upload of a resource from the juju cli for deploy, refresh or attach-storage is done via the apiserver/internal/handlers/resources package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(registry facade.FacadeRegistry)
Register is called to expose a package of facades onto a given registry.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is the public API facade for resources.
func NewFacade ¶
func NewFacade(ctx facade.ModelContext) (*API, error)
NewFacade creates a public API facade for resources. It is used for API registration.
func NewResourcesAPI ¶
func NewResourcesAPI( applicationService ApplicationService, resourceService ResourceService, factory func(context.Context, *charm.URL) (NewCharmRepository, error), logger corelogger.Logger, ) (*API, error)
NewResourcesAPI returns a new resources API facade.
func (*API) AddPendingResources ¶
func (a *API) AddPendingResources( ctx context.Context, args params.AddPendingResourcesArgsV2, ) (params.AddPendingResourcesResult, error)
AddPendingResources handles 2 scenarios
- Adds the provided resources (info) to the Juju model before the application exists. These resources are resolved when the application is created using the returned Resource UUIDs.
- Updates which resource revision an application uses, changing the origin to store. No Resource IDs are returned.
Handles CharmHub and Local charms.
func (*API) ListResources ¶
func (a *API) ListResources(ctx context.Context, args params.ListResourcesArgs) (params.ResourcesResults, error)
ListResources returns the list of resources for the given application.
type ApplicationService ¶
type ApplicationService interface { // GetApplicationIDByName returns an application ID by application name. GetApplicationIDByName(ctx context.Context, name string) (coreapplication.ID, error) }
ApplicationService defines methods to manage application.
type NewCharmRepository ¶
type NewCharmRepository interface {
ResolveResources(ctx context.Context, resources []charmresource.Resource, id corecharm.CharmID) ([]charmresource.Resource, error)
}
NewCharmRepository defines methods required by the resources facade specific to an individual repository type.
type ResourceService ¶
type ResourceService interface { // AddResourcesBeforeApplication adds the details of which resource // revision to use before the application exists in the model. The // charm and resource metadata must exist. These resources are resolved // when the application is created using the returned Resource UUIDs. AddResourcesBeforeApplication(ctx context.Context, arg resource.AddResourcesBeforeApplicationArgs) ([]coreresource.UUID, error) // GetApplicationResourceID returns the ID of the application resource // specified by natural key of application and resource name. GetApplicationResourceID( ctx context.Context, args resource.GetApplicationResourceIDArgs, ) (coreresource.UUID, error) // ListResources returns the resources for the given application. ListResources(ctx context.Context, applicationID coreapplication.ID) (coreresource.ApplicationResources, error) // UpdateResourceRevision adds a new entry for the revision in the resource // table with the desired parameters and sets it on the application. Any // previous resource blob is removed. The new resource UUID is returned. UpdateResourceRevision(ctx context.Context, args resource.UpdateResourceRevisionArgs) (coreresource.UUID, error) // UpdateUploadResource adds a new entry for an uploaded blob in the resource // table with the desired parameters and sets it on the application. Any // previous resource blob is removed. The new resource UUID is returned. UpdateUploadResource(ctx context.Context, resourceToUpdate coreresource.UUID) (coreresource.UUID, error) }
ResourceService defines methods for managing application resources.