Documentation
¶
Index ¶
- type AddApplicationArgs
- type AddUnitArg
- type AddressParams
- type AgentVersionGetter
- type ApplicationState
- type Broker
- type CharmState
- type CharmStore
- type ImportApplicationArgs
- type ImportUnitArg
- type MigrationService
- func (s *MigrationService) GetApplicationConfigAndSettings(ctx context.Context, name string) (config.ConfigAttributes, application.ApplicationSettings, error)
- func (s *MigrationService) GetApplicationConstraints(ctx context.Context, name string) (coreconstraints.Value, error)
- func (s *MigrationService) GetApplicationStatus(ctx context.Context, name string) (*corestatus.StatusInfo, error)
- func (s *MigrationService) GetCharmByApplicationName(ctx context.Context, name string) (internalcharm.Charm, charm.CharmLocator, error)
- func (s *MigrationService) GetCharmID(ctx context.Context, args charm.GetCharmArgs) (corecharm.ID, error)
- func (s *MigrationService) ImportApplication(ctx context.Context, name string, args ImportApplicationArgs) error
- func (s *MigrationService) RemoveImportedApplication(context.Context, string) error
- type Provider
- type ProviderService
- type ResolvedResource
- type ResolvedResources
- type ScalingState
- type Service
- func (s *Service) AddStorageForUnit(ctx context.Context, storageName corestorage.Name, unitName coreunit.Name, ...) ([]corestorage.ID, error)
- func (s *Service) AddUnits(ctx context.Context, appName string, units ...AddUnitArg) error
- func (s *Service) AttachStorage(ctx context.Context, storageID corestorage.ID, unitName coreunit.Name) error
- func (s *Service) CAASUnitTerminating(ctx context.Context, appName string, unitNum int, broker Broker) (bool, error)
- func (s *Service) ChangeApplicationScale(ctx context.Context, appName string, scaleChange int) (int, error)
- func (s *Service) CreateApplication(ctx context.Context, name string, charm internalcharm.Charm, ...) (coreapplication.ID, error)
- func (s *Service) DeleteApplication(ctx context.Context, name string) error
- func (s *Service) DeleteCharm(ctx context.Context, locator charm.CharmLocator) error
- func (s *Service) DeleteUnit(ctx context.Context, unitName coreunit.Name) error
- func (s *Service) DestroyApplication(ctx context.Context, appName string) error
- func (s *Service) DestroyUnit(ctx context.Context, unitName coreunit.Name) error
- func (s *Service) DetachStorage(ctx context.Context, storageID corestorage.ID) error
- func (s *Service) DetachStorageForUnit(ctx context.Context, storageID corestorage.ID, unitName coreunit.Name) error
- func (s *Service) EnsureUnitDead(ctx context.Context, unitName coreunit.Name, ...) error
- func (s *Service) GetApplicationConfig(ctx context.Context, appID coreapplication.ID) (config.ConfigAttributes, error)
- func (s *Service) GetApplicationConstraints(ctx context.Context, appID coreapplication.ID) (coreconstraints.Value, error)
- func (s *Service) GetApplicationDisplayStatus(ctx context.Context, appID coreapplication.ID) (*corestatus.StatusInfo, error)
- func (s *Service) GetApplicationIDByName(ctx context.Context, name string) (coreapplication.ID, error)
- func (s *Service) GetApplicationIDByUnitName(ctx context.Context, unitName coreunit.Name) (coreapplication.ID, error)
- func (s *Service) GetApplicationLife(ctx context.Context, appName string) (corelife.Value, error)
- func (s *Service) GetApplicationScale(ctx context.Context, appName string) (int, error)
- func (s *Service) GetApplicationScalingState(ctx context.Context, appName string) (ScalingState, error)
- func (s *Service) GetApplicationStatus(ctx context.Context, appID coreapplication.ID) (*corestatus.StatusInfo, error)
- func (s *Service) GetApplicationTrustSetting(ctx context.Context, appID coreapplication.ID) (bool, error)
- func (s *Service) GetApplicationsForRevisionUpdater(ctx context.Context) ([]application.RevisionUpdaterApplication, error)
- func (s *Service) GetApplicationsWithPendingCharmsFromUUIDs(ctx context.Context, uuids []coreapplication.ID) ([]coreapplication.ID, error)
- func (s *Service) GetAsyncCharmDownloadInfo(ctx context.Context, appID coreapplication.ID) (application.CharmDownloadInfo, error)
- func (s *Service) GetAvailableCharmArchiveSHA256(ctx context.Context, locator charm.CharmLocator) (string, error)
- func (s *Service) GetCharm(ctx context.Context, locator charm.CharmLocator) (internalcharm.Charm, charm.CharmLocator, bool, error)
- func (s *Service) GetCharmActions(ctx context.Context, locator charm.CharmLocator) (internalcharm.Actions, error)
- func (s *Service) GetCharmArchive(ctx context.Context, locator charm.CharmLocator) (io.ReadCloser, string, error)
- func (s *Service) GetCharmArchiveBySHA256Prefix(ctx context.Context, sha256Prefix string) (io.ReadCloser, error)
- func (s *Service) GetCharmArchivePath(ctx context.Context, locator charm.CharmLocator) (string, error)
- func (s *Service) GetCharmByApplicationID(ctx context.Context, id coreapplication.ID) (internalcharm.Charm, charm.CharmLocator, error)
- func (s *Service) GetCharmConfig(ctx context.Context, locator charm.CharmLocator) (internalcharm.Config, error)
- func (s *Service) GetCharmDownloadInfo(ctx context.Context, locator charm.CharmLocator) (*charm.DownloadInfo, error)
- func (s *Service) GetCharmLXDProfile(ctx context.Context, locator charm.CharmLocator) (internalcharm.LXDProfile, charm.Revision, error)
- func (s *Service) GetCharmLocatorByApplicationName(ctx context.Context, name string) (charm.CharmLocator, error)
- func (s *Service) GetCharmManifest(ctx context.Context, locator charm.CharmLocator) (internalcharm.Manifest, error)
- func (s *Service) GetCharmMetadata(ctx context.Context, locator charm.CharmLocator) (internalcharm.Meta, error)
- func (s *Service) GetCharmMetadataDescription(ctx context.Context, locator charm.CharmLocator) (string, error)
- func (s *Service) GetCharmMetadataName(ctx context.Context, locator charm.CharmLocator) (string, error)
- func (s *Service) GetCharmMetadataResources(ctx context.Context, locator charm.CharmLocator) (map[string]resource.Meta, error)
- func (s *Service) GetCharmMetadataStorage(ctx context.Context, locator charm.CharmLocator) (map[string]internalcharm.Storage, error)
- func (s *Service) GetCharmModifiedVersion(ctx context.Context, id coreapplication.ID) (int, error)
- func (s *Service) GetLatestPendingCharmhubCharm(ctx context.Context, name string, arch arch.Arch) (charm.CharmLocator, error)
- func (s *Service) GetUnitDisplayStatus(ctx context.Context, unitName coreunit.Name) (*corestatus.StatusInfo, error)
- func (s *Service) GetUnitLife(ctx context.Context, unitName coreunit.Name) (corelife.Value, error)
- func (s *Service) GetUnitUUID(ctx context.Context, unitName coreunit.Name) (coreunit.UUID, error)
- func (s *Service) GetUnitWorkloadStatus(ctx context.Context, unitName coreunit.Name) (*corestatus.StatusInfo, error)
- func (s *Service) GetUnitWorkloadStatusesForApplication(ctx context.Context, appID coreapplication.ID) (map[coreunit.Name]corestatus.StatusInfo, error)
- func (s *Service) IsCharmAvailable(ctx context.Context, locator charm.CharmLocator) (bool, error)
- func (s *Service) IsControllerCharm(ctx context.Context, locator charm.CharmLocator) (bool, error)
- func (s *Service) IsSubordinateCharm(ctx context.Context, locator charm.CharmLocator) (bool, error)
- func (s *Service) ListCharmLocators(ctx context.Context, names ...string) ([]charm.CharmLocator, error)
- func (s *Service) MarkApplicationDead(ctx context.Context, appName string) error
- func (s *Service) RegisterCAASUnit(ctx context.Context, appName string, args application.RegisterCAASUnitArg) error
- func (s *Service) RemoveUnit(ctx context.Context, unitName coreunit.Name, ...) error
- func (s *Service) ReserveCharmRevision(ctx context.Context, args charm.ReserveCharmRevisionArgs) (corecharm.ID, []string, error)
- func (s *Service) ResolveCharmDownload(ctx context.Context, appID coreapplication.ID, ...) error
- func (s *Service) ResolveControllerCharmDownload(ctx context.Context, resolve application.ResolveControllerCharmDownload) (application.ResolvedControllerCharmDownload, error)
- func (s *Service) ResolveUploadCharm(ctx context.Context, args charm.ResolveUploadCharm) (charm.CharmLocator, error)
- func (s *Service) SetApplicationCharm(ctx context.Context, name string, params UpdateCharmParams) error
- func (s *Service) SetApplicationConfig(ctx context.Context, appID coreapplication.ID, newConfig map[string]string) error
- func (s *Service) SetApplicationScale(ctx context.Context, appName string, scale int) error
- func (s *Service) SetApplicationScalingState(ctx context.Context, appName string, scaleTarget int, scaling bool) error
- func (s *Service) SetApplicationStatus(ctx context.Context, applicationID coreapplication.ID, ...) error
- func (s *Service) SetApplicationStatusForUnitLeader(ctx context.Context, unitName coreunit.Name, status *corestatus.StatusInfo) error
- func (s *Service) SetCharm(ctx context.Context, args charm.SetCharmArgs) (corecharm.ID, []string, error)
- func (s *Service) SetCharmAvailable(ctx context.Context, locator charm.CharmLocator) error
- func (s *Service) SetUnitPassword(ctx context.Context, unitName coreunit.Name, password string) error
- func (s *Service) SetUnitWorkloadStatus(ctx context.Context, unitName coreunit.Name, status *corestatus.StatusInfo) error
- func (s *Service) SupportsContainers(ctx context.Context, locator charm.CharmLocator) (bool, error)
- func (s *Service) UnsetApplicationConfigKeys(ctx context.Context, appID coreapplication.ID, keys []string) error
- func (s *Service) UpdateCAASUnit(ctx context.Context, unitName coreunit.Name, params UpdateCAASUnitParams) error
- func (s *Service) UpdateCloudService(ctx context.Context, appName, providerID string, sAddrs network.SpaceAddresses) error
- type State
- type StorageState
- type UpdateCAASUnitParams
- type UpdateCharmParams
- type WatchableService
- func (s *WatchableService) WatchApplication(ctx context.Context, name string) (watcher.NotifyWatcher, error)
- func (s *WatchableService) WatchApplicationConfig(ctx context.Context, name string) (watcher.NotifyWatcher, error)
- func (s *WatchableService) WatchApplicationConfigHash(ctx context.Context, name string) (watcher.StringsWatcher, error)
- func (s *WatchableService) WatchApplicationScale(ctx context.Context, appName string) (watcher.NotifyWatcher, error)
- func (s *WatchableService) WatchApplicationUnitLife(appName string) (watcher.StringsWatcher, error)
- func (s *WatchableService) WatchApplicationsWithPendingCharms(ctx context.Context) (watcher.StringsWatcher, error)
- func (s *WatchableService) WatchCharms() (watcher.StringsWatcher, error)
- type WatcherFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddApplicationArgs ¶
type AddApplicationArgs struct { // ReferenceName is the given name of the charm that is stored in the // persistent storage. The proxy name should either be the application // name or the charm metadata name. // // The name of a charm can differ from the charm name stored in the metadata // in the cases where the application name is selected by the user. // In order to select that charm again via the name, we need to use the // proxy name to locate it. You can't go via the application and select it // via the application name, as no application might be referencing it at // that specific revision. The only way to then locate the charm directly // via the name is use the proxy name. ReferenceName string // CharmStoragePath is the path to the charm in the storage. CharmStoragePath string // CharmObjectStoreUUID is the UUID of the object store where the charm is // stored. CharmObjectStoreUUID objectstore.UUID // Storage contains the application's storage directives. Storage map[string]storage.Directive // DownloadInfo contains the download information for the charm. DownloadInfo *domaincharm.DownloadInfo // ResolvedResources contains a list of ResolvedResource instances, // which allows to define a revision and an origin for each resource. ResolvedResources ResolvedResources // PendingResources are the uuids of resources added before the // application is created. PendingResources []resource.UUID // ApplicationConfig contains the application config. ApplicationConfig config.ConfigAttributes // ApplicationSettings contains the application settings. ApplicationSettings application.ApplicationSettings // ApplicationStatus contains the application status. It's optional // and if not provided, the application will be started with no status. ApplicationStatus *status.StatusInfo }
AddApplicationArgs contains arguments for adding an application to the model.
type AddUnitArg ¶
AddUnitArg contains parameters for adding a unit to the model.
type AddressParams ¶
type AddressParams struct { Value string AddressType string Scope string Origin string SpaceID string }
AddressParams contains parameters for a unit/cloud container address.
type AgentVersionGetter ¶
type AgentVersionGetter interface { // GetTargetAgentVersion returns the agent version // for the current model. GetTargetAgentVersion(context.Context) (version.Number, error) }
AgentVersionGetter is responsible for retrieving the target agent version for the current model.
type ApplicationState ¶
type ApplicationState interface { // GetApplicationIDByName returns the application ID for the named application. // If no application is found, an error satisfying // [applicationerrors.ApplicationNotFound] is returned. GetApplicationIDByName(ctx context.Context, name string) (coreapplication.ID, error) // CreateApplication creates an application, returning an error satisfying // [applicationerrors.ApplicationAlreadyExists] if the application already // exists. If returns as error satisfying [applicationerrors.CharmNotFound] // if the charm for the application is not found. CreateApplication(context.Context, string, application.AddApplicationArg, []application.AddUnitArg) (coreapplication.ID, error) // AddUnits adds the specified units to the application. AddUnits(context.Context, coreapplication.ID, []application.AddUnitArg) error // InsertCAASUnit inserts the specified CAAS application unit, returning an // error satisfying [applicationerrors.UnitAlreadyExists] if the unit exists. InsertCAASUnit(context.Context, coreapplication.ID, application.RegisterCAASUnitArg) error // UpdateCAASUnit updates the cloud container for specified unit, // returning an error satisfying [applicationerrors.UnitNotFoundError] // if the unit doesn't exist. UpdateCAASUnit(context.Context, coreunit.Name, application.UpdateCAASUnitParams) error // InsertUnit insert the specified application unit, returning an error // satisfying [applicationerrors.UnitAlreadyExists] // if the unit exists. InsertUnit(context.Context, coreapplication.ID, application.InsertUnitArg) error // SetUnitPassword updates the password for the specified unit UUID. SetUnitPassword(context.Context, coreunit.UUID, application.PasswordInfo) error // GetUnitWorkloadStatus returns the workload status of the specified unit, returning: // - an error satisfying [applicationerrors.UnitNotFound] if the unit doesn't exist or; // - an error satisfying [applicationerrors.UnitStatusNotFound] if the status is not set. GetUnitWorkloadStatus(context.Context, coreunit.UUID) (*application.StatusInfo[application.WorkloadStatusType], error) // SetUnitWorkloadStatus sets the workload status of the specified unit, returning an // error satisfying [applicationerrors.UnitNotFound] if the unit doesn't exist. SetUnitWorkloadStatus(context.Context, coreunit.UUID, *application.StatusInfo[application.WorkloadStatusType]) error // GetUnitCloudContainerStatus returns the cloud container status of the specified // unit. It returns; // - an error satisfying [applicationerrors.UnitNotFound] if the unit doesn't exist or; // - an error satisfying [applicationerrors.UnitStatusNotFound] if the status is not set. GetUnitCloudContainerStatus(context.Context, coreunit.UUID) (*application.StatusInfo[application.CloudContainerStatusType], error) // GetUnitWorkloadStatusesForApplication returns the workload statuses for all units // of the specified application, returning: // - an error satisfying [applicationerrors.ApplicationNotFound] if the application // doesn't exist or; // - error satisfying [applicationerrors.ApplicationIsDead] if the application // is dead. GetUnitWorkloadStatusesForApplication(context.Context, coreapplication.ID) (map[coreunit.Name]application.StatusInfo[application.WorkloadStatusType], error) // GetUnitCloudContainerStatusesForApplication returns the cloud container // statuses for all units of the specified application, returning: // - an error satisfying [applicationerrors.ApplicationNotFound] if the application // doesn't exist or; // - an error satisfying [applicationerrors.ApplicationIsDead] if the application // is dead. GetUnitCloudContainerStatusesForApplication(context.Context, coreapplication.ID) (map[coreunit.Name]application.StatusInfo[application.CloudContainerStatusType], error) // DeleteUnit deletes the specified unit. // If the unit's application is Dying and no // other references to it exist, true is returned to // indicate the application could be safely deleted. // It will fail if the unit is not Dead. DeleteUnit(context.Context, coreunit.Name) (bool, error) // GetModelType returns the model type for the underlying model. If the // model does not exist then an error satisfying [modelerrors.NotFound] will // be returned. GetModelType(context.Context) (coremodel.ModelType, error) // StorageDefaults returns the default storage sources for a model. StorageDefaults(context.Context) (domainstorage.StorageDefaults, error) // GetStoragePoolByName returns the storage pool with the specified name, // returning an error satisfying [storageerrors.PoolNotFoundError] if it // doesn't exist. GetStoragePoolByName(ctx context.Context, name string) (domainstorage.StoragePoolDetails, error) // GetUnitUUIDByName returns the UUID for the named unit, returning an // error satisfying [applicationerrors.UnitNotFound] if the unit doesn't // exist. GetUnitUUIDByName(context.Context, coreunit.Name) (coreunit.UUID, error) // UpsertCloudService updates the cloud service for the specified // application, returning an error satisfying // [applicationerrors.ApplicationNotFoundError] if the application doesn't // exist. UpsertCloudService(ctx context.Context, appName, providerID string, sAddrs network.SpaceAddresses) error // GetApplicationScaleState looks up the scale state of the specified // application, returning an error satisfying // [applicationerrors.ApplicationNotFound] if the application is not found. GetApplicationScaleState(context.Context, coreapplication.ID) (application.ScaleState, error) // GetApplicationUnitLife returns the life values for the specified units of // the given application. The supplied ids may belong to a different // application; the application name is used to filter. GetApplicationUnitLife(ctx context.Context, appName string, unitUUIDs ...coreunit.UUID) (map[coreunit.UUID]life.Life, error) // GetApplicationLife looks up the life of the specified application, // returning an error satisfying // [applicationerrors.ApplicationNotFoundError] if the application is not // found. GetApplicationLife(ctx context.Context, appName string) (coreapplication.ID, life.Life, error) // SetApplicationLife sets the life of the specified application. SetApplicationLife(context.Context, coreapplication.ID, life.Life) error // SetApplicationScalingState sets the scaling details for the given caas // application Scale is optional and is only set if not nil. SetApplicationScalingState(ctx context.Context, appID coreapplication.ID, scale *int, targetScale int, scaling bool) error // SetDesiredApplicationScale updates the desired scale of the specified // application. SetDesiredApplicationScale(context.Context, coreapplication.ID, int) error // DeleteApplication deletes the specified application, returning an error // satisfying [applicationerrors.ApplicationNotFoundError] if the // application doesn't exist. If the application still has units, as error // satisfying [applicationerrors.ApplicationHasUnits] is returned. DeleteApplication(context.Context, string) error // GetCharmByApplicationID returns the charm, charm origin and charm // platform for the specified application ID. // // If the application does not exist, an error satisfying // [applicationerrors.ApplicationNotFoundError] is returned. // If the charm for the application does not exist, an error satisfying // [applicationerrors.CharmNotFoundError] is returned. GetCharmByApplicationID(context.Context, coreapplication.ID) (charm.Charm, error) // GetCharmIDByApplicationName returns a charm ID by application name. It // returns an error if the charm can not be found by the name. This can also // be used as a cheap way to see if a charm exists without needing to load // the charm metadata. GetCharmIDByApplicationName(context.Context, string) (corecharm.ID, error) // GetApplicationIDByUnitName returns the application ID for the named unit, // returning an error satisfying [applicationerrors.UnitNotFound] if the // unit doesn't exist. GetApplicationIDByUnitName(ctx context.Context, name coreunit.Name) (coreapplication.ID, error) // GetApplicationIDAndNameByUnitName returns the application ID and name for // the named unit, returning an error satisfying // [applicationerrors.UnitNotFound] if the unit doesn't exist. GetApplicationIDAndNameByUnitName(ctx context.Context, name coreunit.Name) (coreapplication.ID, string, error) // GetCharmModifiedVersion looks up the charm modified version of the given // application. Returns [applicationerrors.ApplicationNotFound] if the // application is not found. GetCharmModifiedVersion(ctx context.Context, id coreapplication.ID) (int, error) // GetApplicationsWithPendingCharmsFromUUIDs returns the applications // with pending charms for the specified UUIDs. If the application has a // different status, it's ignored. GetApplicationsWithPendingCharmsFromUUIDs(ctx context.Context, uuids []coreapplication.ID) ([]coreapplication.ID, error) // GetAsyncCharmDownloadInfo reserves the charm download for the specified // application, returning an error satisfying // [applicationerrors.AlreadyDownloadingCharm] if the application is already // downloading a charm. GetAsyncCharmDownloadInfo(ctx context.Context, appID coreapplication.ID) (application.CharmDownloadInfo, error) // ResolveCharmDownload resolves the charm download for the specified // application, updating the charm with the specified charm information. ResolveCharmDownload(ctx context.Context, charmID corecharm.ID, info application.ResolvedCharmDownload) error // GetApplicationsForRevisionUpdater returns all the applications for the // revision updater. This will only return charmhub charms, for applications // that are alive. // This will return an empty slice if there are no applications. GetApplicationsForRevisionUpdater(ctx context.Context) ([]application.RevisionUpdaterApplication, error) // GetCharmConfigByApplicationID returns the charm config for the specified // application ID. // If no application is found, an error satisfying // [applicationerrors.ApplicationNotFound] is returned. // If the charm for the application does not exist, an error satisfying // [applicationerrors.CharmNotFoundError] is returned. GetCharmConfigByApplicationID(ctx context.Context, appID coreapplication.ID) (corecharm.ID, charm.Config, error) // GetApplicationConfigAndSettings returns the application config and // settings attributes for the application ID. // // If no application is found, an error satisfying // [applicationerrors.ApplicationNotFound] is returned. GetApplicationConfigAndSettings(ctx context.Context, appID coreapplication.ID) ( map[string]application.ApplicationConfig, application.ApplicationSettings, error, ) // GetApplicationTrustSetting returns the application trust setting. // If no application is found, an error satisfying // [applicationerrors.ApplicationNotFound] is returned. GetApplicationTrustSetting(ctx context.Context, appID coreapplication.ID) (bool, error) // SetApplicationConfigAndSettings sets the application config attributes // using the configuration, and sets the trust setting as part of the // application. // If no application is found, an error satisfying // [applicationerrors.ApplicationNotFound] is returned. SetApplicationConfigAndSettings( ctx context.Context, appID coreapplication.ID, charmID corecharm.ID, config map[string]application.ApplicationConfig, settings application.ApplicationSettings, ) error // UnsetApplicationConfigKeys removes the specified keys from the application // config. If the key does not exist, it is ignored. // If no application is found, an error satisfying // [applicationerrors.ApplicationNotFound] is returned. UnsetApplicationConfigKeys(ctx context.Context, appID coreapplication.ID, keys []string) error // GetUnitLife looks up the life of the specified unit, returning an error // satisfying [applicationerrors.UnitNotFound] if the unit is not found. GetUnitLife(context.Context, coreunit.Name) (life.Life, error) // SetUnitLife sets the life of the specified unit. SetUnitLife(context.Context, coreunit.Name, life.Life) error // GetApplicationConfigHash returns the SHA256 hash of the application config // for the specified application ID. // If no application is found, an error satisfying // [applicationerrors.ApplicationNotFound] is returned. GetApplicationConfigHash(ctx context.Context, appID coreapplication.ID) (string, error) // InitialWatchStatementUnitLife returns the initial namespace query for the // application unit life watcher. InitialWatchStatementUnitLife(appName string) (string, eventsource.NamespaceQuery) // InitialWatchStatementApplicationsWithPendingCharms returns the initial // namespace query for the applications with pending charms watcher. InitialWatchStatementApplicationsWithPendingCharms() (string, eventsource.NamespaceQuery) // InitialWatchStatementApplicationConfigHash returns the initial namespace // query for the application config hash watcher. InitialWatchStatementApplicationConfigHash(appName string) (string, eventsource.NamespaceQuery) // GetApplicationConstraints returns the application constraints for the // specified application ID. // Empty constraints are returned if no constraints exist for the given // application ID. // If no application is found, an error satisfying // [applicationerrors.ApplicationNotFound] is returned. GetApplicationConstraints(ctx context.Context, appID coreapplication.ID) (constraints.Constraints, error) // SetApplicationConstraints sets the application constraints for the // specified application ID. // This method overwrites the full constraints on every call. // If invalid constraints are provided (e.g. invalid container type or // non-existing space), a [applicationerrors.InvalidApplicationConstraints] // error is returned. // If no application is found, an error satisfying // [applicationerrors.ApplicationNotFound] is returned. SetApplicationConstraints(ctx context.Context, appID coreapplication.ID, cons constraints.Constraints) error // GetApplicationStatus looks up the status of the specified application, // returning an error satisfying [applicationerrors.ApplicationNotFound] if the // application is not found. GetApplicationStatus(ctx context.Context, appID coreapplication.ID) (*application.StatusInfo[application.WorkloadStatusType], error) // SetApplicationStatus saves the given application status, overwriting any // current status data. If returns an error satisfying // [applicationerrors.ApplicationNotFound] if the application doesn't exist. SetApplicationStatus( ctx context.Context, applicationID coreapplication.ID, status *application.StatusInfo[application.WorkloadStatusType], ) error }
ApplicationState describes retrieval and persistence methods for applications.
type Broker ¶
type Broker interface {
Application(string, caas.DeploymentType) caas.Application
}
Broker provides access to the k8s cluster to guery the scale of a specified application.
type CharmState ¶
type CharmState interface { // GetCharmID returns the charm ID by the natural key, for a // specific revision and source. If the charm does not exist, a // [applicationerrors.CharmNotFound] error is returned. GetCharmID(ctx context.Context, name string, revision int, source charm.CharmSource) (corecharm.ID, error) // IsControllerCharm returns whether the charm is a controller charm. If the // charm does not exist, a [applicationerrors.CharmNotFound] error is // returned. IsControllerCharm(ctx context.Context, id corecharm.ID) (bool, error) // IsSubordinateCharm returns whether the charm is a subordinate charm. If // the charm does not exist, a [applicationerrors.CharmNotFound] error is // returned. IsSubordinateCharm(ctx context.Context, charmID corecharm.ID) (bool, error) // SupportsContainers returns whether the charm supports containers. If the // charm does not exist, a [applicationerrors.CharmNotFound] error is // returned. SupportsContainers(ctx context.Context, charmID corecharm.ID) (bool, error) // GetCharmMetadata returns the metadata for the charm using the charm ID. // If the charm does not exist, a [applicationerrors.CharmNotFound] error is // returned. GetCharmMetadata(context.Context, corecharm.ID) (charm.Metadata, error) // GetCharmMetadataName returns the name for the charm using the charm ID. GetCharmMetadataName(context.Context, corecharm.ID) (string, error) // GetCharmMetadataDescription returns the description for the charm using // the charm ID. GetCharmMetadataDescription(context.Context, corecharm.ID) (string, error) // GetCharmMetadataStorage returns the storage specification for the charm // using the charm ID. GetCharmMetadataStorage(context.Context, corecharm.ID) (map[string]charm.Storage, error) // GetCharmMetadataResources returns the specifications for the resources for // the charm using the charm ID. GetCharmMetadataResources(ctx context.Context, id corecharm.ID) (map[string]charm.Resource, error) // GetCharmManifest returns the manifest for the charm using the charm ID. // If the charm does not exist, a [applicationerrors.CharmNotFound] error is // returned. GetCharmManifest(context.Context, corecharm.ID) (charm.Manifest, error) // GetCharmActions returns the actions for the charm using the charm ID. If // the charm does not exist, a [applicationerrors.CharmNotFound] error is // returned. GetCharmActions(context.Context, corecharm.ID) (charm.Actions, error) // GetCharmConfig returns the config for the charm using the charm ID. If // the charm does not exist, a [applicationerrors.CharmNotFound] error is // returned. GetCharmConfig(context.Context, corecharm.ID) (charm.Config, error) // GetCharmLXDProfile returns the LXD profile along with the revision of the // charm using the charm ID. The revision // // If the charm does not exist, a [applicationerrors.CharmNotFound] error is // returned. GetCharmLXDProfile(context.Context, corecharm.ID) ([]byte, charm.Revision, error) // GetCharmArchivePath returns the archive storage path for the charm using // the charm ID. If the charm does not exist, a // [applicationerrors.CharmNotFound] error is returned. GetCharmArchivePath(context.Context, corecharm.ID) (string, error) // GetCharmArchiveMetadata returns the archive storage path and hash for the // charm using the charm ID. // If the charm does not exist, a [errors.CharmNotFound] error is returned. GetCharmArchiveMetadata(context.Context, corecharm.ID) (archivePath string, hash string, err error) // IsCharmAvailable returns whether the charm is available for use. If the // charm does not exist, a [applicationerrors.CharmNotFound] error is // returned. IsCharmAvailable(ctx context.Context, charmID corecharm.ID) (bool, error) // SetCharmAvailable sets the charm as available for use. If the charm does // not exist, a [applicationerrors.CharmNotFound] error is returned. SetCharmAvailable(ctx context.Context, charmID corecharm.ID) error // GetCharm returns the charm using the charm ID. GetCharm(ctx context.Context, id corecharm.ID) (charm.Charm, *charm.DownloadInfo, error) // SetCharm persists the charm metadata, actions, config and manifest to // state. If the charm requires sequencing, the revision must be set to // -1 and the requiredSequencing flag must be set to true. If the charm // does not require sequencing, the revision must be set to the desired // revision and the requiredSequencing flag must be set to false. SetCharm(ctx context.Context, ch charm.Charm, downloadInfo *charm.DownloadInfo, requiresSequencing bool) (corecharm.ID, charm.CharmLocator, error) // DeleteCharm removes the charm from the state. If the charm does not // exist, a [applicationerrors.CharmNotFound] error is returned. DeleteCharm(ctx context.Context, id corecharm.ID) error // ListCharmLocators returns a list of charm locators. The locator allows // the reconstruction of the charm URL for the client response. ListCharmLocators(ctx context.Context) ([]charm.CharmLocator, error) // ListCharmLocatorsByNames returns a list of charm locators for the // specified charm names. The locator allows the reconstruction of the charm // URL for the client response. If no names are provided, then nothing is // returned. ListCharmLocatorsByNames(ctx context.Context, names []string) ([]charm.CharmLocator, error) // GetCharmDownloadInfo returns the download info for the charm using the // charm ID. Returns [applicationerrors.CharmNotFound] if the charm is not // found. GetCharmDownloadInfo(ctx context.Context, id corecharm.ID) (*charm.DownloadInfo, error) // GetAvailableCharmArchiveSHA256 returns the SHA256 hash of the charm // archive for the given charm id. If the charm is not available, // [applicationerrors.CharmNotResolved] is returned. Returns // [applicationerrors.CharmNotFound] if the charm is not found. GetAvailableCharmArchiveSHA256(ctx context.Context, id corecharm.ID) (string, error) // ResolveMigratingUploadedCharm resolves the charm that is migrating from // the uploaded state to the available state. If the charm is not found, a // [applicationerrors.CharmNotFound] error is returned. ResolveMigratingUploadedCharm(context.Context, corecharm.ID, charm.ResolvedMigratingUploadedCharm) (charm.CharmLocator, error) // GetLatestPendingCharmhubCharm returns the latest charm that is pending // from the charmhub store. If there are no charms, returns is not found, as // [applicationerrors.CharmNotFound]. If there are multiple charms, then the // latest created at date is returned first. GetLatestPendingCharmhubCharm(ctx context.Context, name string, arch architecture.Architecture) (charm.CharmLocator, error) // GetCharmLocatorByCharmID returns a charm locator for the given charm ID. // The locator allows the reconstruction of the charm URL for the client // response. // If the charm does not exist, a [errors.CharmNotFound] error is returned. GetCharmLocatorByCharmID(ctx context.Context, id corecharm.ID) (charm.CharmLocator, error) }
CharmState describes retrieval and persistence methods for charms.
type CharmStore ¶
type CharmStore interface { // Store the charm at the specified path into the object store. It is // expected that the archive already exists at the specified path. If the // file isn't found, a [ErrNotFound] is returned. Store(ctx context.Context, path string, size int64, hash string) (store.StoreResult, error) // StoreFromReader stores the charm from the provided reader into the object // store. The caller is expected to remove the temporary file after the // call. // sha256Prefix is the prefix characters of the SHA256 hash of the charm // archive. StoreFromReader(ctx context.Context, reader io.Reader, sha256Prefix string) (store.StoreFromReaderResult, store.Digest, error) // GetCharm retrieves a ReadCloser for the charm archive at the give path // from the underlying storage. Get(ctx context.Context, archivePath string) (io.ReadCloser, error) // GetBySHA256Prefix retrieves a ReadCloser for a charm archive who's SHA256 // hash starts with the provided prefix. GetBySHA256Prefix(ctx context.Context, sha256Prefix string) (io.ReadCloser, error) }
CharmStore defines the interface for storing and retrieving charms archive blobs from the underlying storage.
type ImportApplicationArgs ¶
type ImportApplicationArgs struct { // Charm is the charm to import. Charm charm.Charm // CharmOrigin is the origin of the charm. CharmOrigin corecharm.Origin // ReferenceName is the given name of the charm that is stored in the // persistent storage. The proxy name should either be the application // name or the charm metadata name. // // The name of a charm can differ from the charm name stored in the metadata // in the cases where the application name is selected by the user. // In order to select that charm again via the name, we need to use the // proxy name to locate it. You can't go via the application and select it // via the application name, as no application might be referencing it at // that specific revision. The only way to then locate the charm directly // via the name is use the proxy name. ReferenceName string // DownloadInfo contains the download information for the charm. DownloadInfo *domaincharm.DownloadInfo // ApplicationConfig contains the application config. ApplicationConfig config.ConfigAttributes // ApplicationSettings contains the application settings. ApplicationSettings application.ApplicationSettings // ApplicationStatus contains the application status. It's optional // and if not provided, the application will be started with no status. ApplicationStatus *status.StatusInfo // ResolvedResources contains a list of ResolvedResource instances, // TODO (stickupkid): This isn't currently wired up. ResolvedResources ResolvedResources // Units contains the units to import. Units []ImportUnitArg // ApplicationConstraints contains the application constraints. ApplicationConstraints constraints.Value // CharmUpgradeOnError indicates whether the charm must be upgraded // even when on error. CharmUpgradeOnError bool }
ImportApplicationArgs contains arguments for importing an application to the model.
type ImportUnitArg ¶
type ImportUnitArg struct { UnitName coreunit.Name PasswordHash *string AgentStatus status.StatusInfo WorkloadStatus status.StatusInfo CloudContainer *application.CloudContainerParams }
ImportUnitArg contains parameters for inserting a fully populated unit into the model, eg during migration.
type MigrationService ¶
type MigrationService struct {
// contains filtered or unexported fields
}
MigrationService provides the API for migrating applications.
func NewMigrationService ¶
func NewMigrationService( st State, storageRegistryGetter corestorage.ModelStorageRegistryGetter, clock clock.Clock, logger logger.Logger, ) *MigrationService
NewMigrationService returns a new service reference wrapping the input state.
func (*MigrationService) GetApplicationConfigAndSettings ¶
func (s *MigrationService) GetApplicationConfigAndSettings(ctx context.Context, name string) (config.ConfigAttributes, application.ApplicationSettings, error)
GetApplicationConfigAndSettings returns the application config and settings for the specified application. This will return the application config and the settings in one config.ConfigAttributes object.
If the application does not exist, a applicationerrors.ApplicationNotFound error is returned. If no config is set for the application, an empty config is returned.
func (*MigrationService) GetApplicationConstraints ¶
func (s *MigrationService) GetApplicationConstraints(ctx context.Context, name string) (coreconstraints.Value, error)
GetApplicationConstraints returns the application constraints for the specified application name. Empty constraints are returned if no constraints exist for the given application ID. If no application is found, an error satisfying applicationerrors.ApplicationNotFound is returned.
func (*MigrationService) GetApplicationStatus ¶
func (s *MigrationService) GetApplicationStatus(ctx context.Context, name string) (*corestatus.StatusInfo, error)
GetApplicationStatus returns the status of the specified application. If the application does not exist, a applicationerrors.ApplicationNotFound error is returned.
func (*MigrationService) GetCharmByApplicationName ¶
func (s *MigrationService) GetCharmByApplicationName(ctx context.Context, name string) (internalcharm.Charm, charm.CharmLocator, error)
GetCharmByApplicationName returns the charm using the application name. Calling this method will return all the data associated with the charm. It is not expected to call this method for all calls, instead use the move focused and specific methods. That's because this method is very expensive to call. This is implemented for the cases where all the charm data is needed; model migration, charm export, etc.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*MigrationService) GetCharmID ¶
func (s *MigrationService) GetCharmID(ctx context.Context, args charm.GetCharmArgs) (corecharm.ID, error)
GetCharmID returns a charm ID by name. It returns an error if the charm can not be found by the name. This can also be used as a cheap way to see if a charm exists without needing to load the charm metadata. Returns applicationerrors.CharmNameNotValid if the name is not valid, and applicationerrors.CharmNotFound if the charm is not found.
func (*MigrationService) ImportApplication ¶
func (s *MigrationService) ImportApplication(ctx context.Context, name string, args ImportApplicationArgs) error
ImportApplication imports the specified application and units if required, returning an error satisfying applicationerrors.ApplicationAlreadyExists if the application already exists.
func (*MigrationService) RemoveImportedApplication ¶
func (s *MigrationService) RemoveImportedApplication(context.Context, string) error
RemoveImportedApplication removes an application that was imported. The application might be in an incomplete state, so it's important to remove as much of the application as possible, even on failure.
type Provider ¶
type Provider interface { environs.SupportedFeatureEnumerator environs.ConstraintsChecker }
Provider defines the interface for interacting with the underlying model provider.
type ProviderService ¶
type ProviderService struct { *Service // contains filtered or unexported fields }
ProviderService defines a service for interacting with the underlying model state.
func NewProviderService ¶
func NewProviderService( st State, leaderEnsurer leadership.Ensurer, storageRegistryGetter corestorage.ModelStorageRegistryGetter, modelID coremodel.UUID, agentVersionGetter AgentVersionGetter, provider providertracker.ProviderGetter[Provider], charmStore CharmStore, clock clock.Clock, logger logger.Logger, ) *ProviderService
NewProviderService returns a new Service for interacting with a models state.
func (*ProviderService) GetSupportedFeatures ¶
func (s *ProviderService) GetSupportedFeatures(ctx context.Context) (assumes.FeatureSet, error)
GetSupportedFeatures returns the set of features that the model makes available for charms to use. If the agent version cannot be found, an error satisfying [modelerrors.NotFound] will be returned.
func (*ProviderService) SetApplicationConstraints ¶
func (s *ProviderService) SetApplicationConstraints(ctx context.Context, appID coreapplication.ID, cons coreconstraints.Value) error
SetApplicationConstraints sets the application constraints for the specified application ID. This method overwrites the full constraints on every call. If invalid constraints are provided (e.g. invalid container type or non-existing space), a applicationerrors.InvalidApplicationConstraints error is returned. If no application is found, an error satisfying applicationerrors.ApplicationNotFound is returned.
type ResolvedResource ¶
type ResolvedResource struct { Name string Origin charmresource.Origin Revision *int }
ResolvedResource represents a resource with a given name, origin, and optional revision.
func (ResolvedResource) Validate ¶
func (r ResolvedResource) Validate() error
Validate checks the ResolvedResource's attributes for validity and returns an error if invalid. Returns a apperrors.InvalidResourceArgs if: - the resource name is empty, - the resource origin is not valid, - the revision is not defined for a resource originated from store - the revision is defined for a resource originated from upload
type ResolvedResources ¶
type ResolvedResources []ResolvedResource
ResolvedResources is a collection of ResolvedResource elements.
func (ResolvedResources) Validate ¶
func (r ResolvedResources) Validate() error
Validate checks the validity of each ResolvedResource in the collection. It accumulates errors and returns a combined error, if any invalid resources are encountered.
type ScalingState ¶
ScalingState contains attributes that describes the scaling state of a CAAS application.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides the API for working with applications.
func NewService ¶
func NewService( st State, leaderEnsurer leadership.Ensurer, storageRegistryGetter corestorage.ModelStorageRegistryGetter, charmStore CharmStore, clock clock.Clock, logger logger.Logger, ) *Service
NewService returns a new service reference wrapping the input state.
func (*Service) AddStorageForUnit ¶
func (s *Service) AddStorageForUnit( ctx context.Context, storageName corestorage.Name, unitName coreunit.Name, directive storage.Directive, ) ([]corestorage.ID, error)
AddStorageForUnit adds storage instances to the given unit. Missing storage constraints are populated based on model defaults. The following error types can be expected: - github.com/juju/juju/core/unit.InvalidUnitName: when the unit name is not valid. - github.com/juju/juju/core/storage.InvalidStorageName: when the storage name is not valid. - github.com/juju/juju/domain/storage/errors.StorageNotFound when the storage doesn't exist. - github.com/juju/juju/domain/application/errors.UnitNotFound: when the unit does not exist. - github.com/juju/juju/domain/application/errors.UnitNotAlive: when the unit is not alive. - github.com/juju/juju/domain/application/errors.StorageNotAlive: when the storage is not alive. - github.com/juju/juju/domain/application/errors.StorageNameNotSupported: when storage name is not defined in charm metadata. - github.com/juju/juju/domain/application/errors.InvalidStorageCount: when the allowed attachment count would be violated. - github.com/juju/juju/domain/application/errors.InvalidStorageMountPoint: when the filesystem being attached to the unit's machine has a mount point path conflict.
func (*Service) AddUnits ¶
AddUnits adds the specified units to the application, returning an error satisfying applicationerrors.ApplicationNotFoundError if the application doesn't exist. If no units are provided, it will return nil.
func (*Service) AttachStorage ¶
func (s *Service) AttachStorage(ctx context.Context, storageID corestorage.ID, unitName coreunit.Name) error
AttachStorage attached the specified storage to the specified unit. If the attachment already exists, the result is a no op. The following error types can be expected: - github.com/juju/juju/core/unit.InvalidUnitName: when the unit name is not valid. - github.com/juju/juju/core/storage.InvalidStorageID: when the storage ID is not valid. - github.com/juju/juju/domain/storage/errors.StorageNotFound when the storage doesn't exist. - github.com/juju/juju/domain/application/errors.FilesystemAlreadyAttached: when the filesystem is already attached. - github.com/juju/juju/domain/application/errors.VolumeAlreadyAttached: when the volume is already attached. - github.com/juju/juju/domain/application/errors.UnitNotFound: when the unit does not exist. - github.com/juju/juju/domain/application/errors.UnitNotAlive: when the unit is not alive. - github.com/juju/juju/domain/application/errors.StorageNotAlive: when the storage is not alive. - github.com/juju/juju/domain/application/errors.StorageNameNotSupported: when storage name is not defined in charm metadata. - github.com/juju/juju/domain/application/errors.InvalidStorageCount: when the allowed attachment count would be violated. - github.com/juju/juju/domain/application/errors.InvalidStorageMountPoint: when the filesystem being attached to the unit's machine has a mount point path conflict.
func (*Service) CAASUnitTerminating ¶
func (s *Service) CAASUnitTerminating(ctx context.Context, appName string, unitNum int, broker Broker) (bool, error)
CAASUnitTerminating should be called by the CAASUnitTerminationWorker when the agent receives a signal to exit. UnitTerminating will return how the agent should shutdown. We pass in a CAAS broker to get app details from the k8s cluster - we will probably make it a service attribute once more use cases emerge.
func (*Service) ChangeApplicationScale ¶
func (s *Service) ChangeApplicationScale(ctx context.Context, appName string, scaleChange int) (int, error)
ChangeApplicationScale alters the existing scale by the provided change amount, returning the new amount. It returns an error satisfying applicationerrors.ApplicationNotFoundError if the application doesn't exist. This is used on CAAS models.
func (*Service) CreateApplication ¶
func (s *Service) CreateApplication( ctx context.Context, name string, charm internalcharm.Charm, origin corecharm.Origin, args AddApplicationArgs, units ...AddUnitArg, ) (coreapplication.ID, error)
CreateApplication creates the specified application and units if required, returning an error satisfying applicationerrors.ApplicationAlreadyExists if the application already exists.
func (*Service) DeleteApplication ¶
DeleteApplication deletes the specified application, returning an error satisfying applicationerrors.ApplicationNotFoundError if the application doesn't exist. If the application still has units, as error satisfying applicationerrors.ApplicationHasUnits is returned.
func (*Service) DeleteCharm ¶
DeleteCharm removes the charm from the state. Returns an error if the charm does not exist.
func (*Service) DeleteUnit ¶
DeleteUnit deletes the specified unit. TODO(units) - rework when dual write is refactored This method is called (mostly during cleanup) after a unit has been removed from mongo. The mongo calls are DestroyMaybeRemove, DestroyWithForce, RemoveWithForce.
func (*Service) DestroyApplication ¶
DestroyApplication prepares an application for removal from the model returning an error satisfying applicationerrors.ApplicationNotFoundError if the application doesn't exist.
func (*Service) DestroyUnit ¶
DestroyUnit prepares a unit for removal from the model returning an error satisfying applicationerrors.UnitNotFoundError if the unit doesn't exist.
func (*Service) DetachStorage ¶
DetachStorage detaches the specified storage from whatever node it is attached to. The following error types can be expected: - github.com/juju/juju/core/storage.InvalidStorageID: when the storage ID is not valid. - github.com/juju/juju/domain/storage/errors.StorageNotFound when the storage doesn't exist. - github.com/juju/juju/domain/application/errors.StorageNotDetachable: when the type of storage is not detachable.
func (*Service) DetachStorageForUnit ¶
func (s *Service) DetachStorageForUnit(ctx context.Context, storageID corestorage.ID, unitName coreunit.Name) error
DetachStorageForUnit detaches the specified storage from the specified unit. The following error types can be expected: - github.com/juju/juju/core/unit.InvalidUnitName: when the unit name is not valid. - github.com/juju/juju/core/storage.InvalidStorageID: when the storage ID is not valid. - github.com/juju/juju/domain/storage/errors.StorageNotFound when the storage doesn't exist. - github.com/juju/juju/domain/application/errors.UnitNotFound: when the unit does not exist. - github.com/juju/juju/domain/application/errors.StorageNotDetachable: when the type of storage is not detachable.
func (*Service) EnsureUnitDead ¶
func (s *Service) EnsureUnitDead(ctx context.Context, unitName coreunit.Name, leadershipRevoker leadership.Revoker) error
EnsureUnitDead is called by the unit agent just before it terminates. TODO(units): revisit his existing logic ported from mongo Note: the agent only calls this method once it gets notification that the unit has become dead, so there's strictly no need to call this method as the unit is already dead. This method is also called during cleanup from various cleanup jobs. If the unit is not found, an error satisfying applicationerrors.UnitNotFound is returned.
func (*Service) GetApplicationConfig ¶
func (s *Service) GetApplicationConfig(ctx context.Context, appID coreapplication.ID) (config.ConfigAttributes, error)
GetApplicationConfig returns the application config attributes for the configuration. If no application is found, an error satisfying applicationerrors.ApplicationNotFound is returned.
func (*Service) GetApplicationConstraints ¶
func (s *Service) GetApplicationConstraints(ctx context.Context, appID coreapplication.ID) (coreconstraints.Value, error)
GetApplicationConstraints returns the application constraints for the specified application ID. Empty constraints are returned if no constraints exist for the given application ID. If no application is found, an error satisfying applicationerrors.ApplicationNotFound is returned.
func (*Service) GetApplicationDisplayStatus ¶
func (s *Service) GetApplicationDisplayStatus(ctx context.Context, appID coreapplication.ID) (*corestatus.StatusInfo, error)
GetApplicationDisplayStatus returns the display status of the specified application. The display status is equal to the application status if it is set, otherwise it is derived from the unit display statuses. If no application is found, an error satisfying applicationerrors.ApplicationNotFound is returned.
func (*Service) GetApplicationIDByName ¶
func (s *Service) GetApplicationIDByName(ctx context.Context, name string) (coreapplication.ID, error)
GetApplicationIDByName returns an application ID by application name. It returns an error if the application can not be found by the name.
Returns applicationerrors.ApplicationNameNotValid if the name is not valid, and applicationerrors.ApplicationNotFound if the application is not found.
func (*Service) GetApplicationIDByUnitName ¶
func (s *Service) GetApplicationIDByUnitName( ctx context.Context, unitName coreunit.Name, ) (coreapplication.ID, error)
GetApplicationIDByUnitName returns the application ID for the named unit, returning an error satisfying applicationerrors.UnitNotFound if the unit doesn't exist.
func (*Service) GetApplicationLife ¶
GetApplicationLife looks up the life of the specified application, returning an error satisfying applicationerrors.ApplicationNotFoundError if the application is not found.
func (*Service) GetApplicationScale ¶
GetApplicationScale returns the desired scale of an application, returning an error satisfying applicationerrors.ApplicationNotFoundError if the application doesn't exist. This is used on CAAS models.
func (*Service) GetApplicationScalingState ¶
func (s *Service) GetApplicationScalingState(ctx context.Context, appName string) (ScalingState, error)
GetApplicationScalingState returns the scale state of an application, returning an error satisfying applicationerrors.ApplicationNotFoundError if the application doesn't exist. This is used on CAAS models.
func (*Service) GetApplicationStatus ¶
func (s *Service) GetApplicationStatus(ctx context.Context, appID coreapplication.ID) (*corestatus.StatusInfo, error)
GetApplicationStatus looks up the status of the specified application, returning an error satisfying applicationerrors.ApplicationNotFound if the application is not found.
func (*Service) GetApplicationTrustSetting ¶
func (s *Service) GetApplicationTrustSetting(ctx context.Context, appID coreapplication.ID) (bool, error)
GetApplicationTrustSetting returns the application trust setting. If no application is found, an error satisfying applicationerrors.ApplicationNotFound is returned.
func (*Service) GetApplicationsForRevisionUpdater ¶
func (s *Service) GetApplicationsForRevisionUpdater(ctx context.Context) ([]application.RevisionUpdaterApplication, error)
GetApplicationsForRevisionUpdater returns all the applications for the revision updater. This will only return charmhub charms, for applications that are alive. This will return an empty slice if there are no applications.
func (*Service) GetApplicationsWithPendingCharmsFromUUIDs ¶
func (s *Service) GetApplicationsWithPendingCharmsFromUUIDs(ctx context.Context, uuids []coreapplication.ID) ([]coreapplication.ID, error)
GetApplicationsWithPendingCharmsFromUUIDs returns the application UUIDs that have pending charms from the provided UUIDs. If there are no applications with pending status charms, then those applications are ignored.
func (*Service) GetAsyncCharmDownloadInfo ¶
func (s *Service) GetAsyncCharmDownloadInfo(ctx context.Context, appID coreapplication.ID) (application.CharmDownloadInfo, error)
GetAsyncCharmDownloadInfo returns a charm download info for the specified application. If the charm is already being downloaded, the method will return applicationerrors.CharmAlreadyAvailable. The charm download information is returned which includes the charm name, origin and the digest.
func (*Service) GetAvailableCharmArchiveSHA256 ¶
func (s *Service) GetAvailableCharmArchiveSHA256(ctx context.Context, locator charm.CharmLocator) (string, error)
GetAvailableCharmArchiveSHA256 returns the SHA256 hash of the charm archive for the given charm name, source and revision. If the charm is not available, applicationerrors.CharmNotResolved is returned.
func (*Service) GetCharm ¶
func (s *Service) GetCharm(ctx context.Context, locator charm.CharmLocator) (internalcharm.Charm, charm.CharmLocator, bool, error)
GetCharm returns the charm by name, source and revision. Calling this method will return all the data associated with the charm. It is not expected to call this method for all calls, instead use the move focused and specific methods. That's because this method is very expensive to call. This is implemented for the cases where all the charm data is needed; model migration, charm export, etc.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmActions ¶
func (s *Service) GetCharmActions(ctx context.Context, locator charm.CharmLocator) (internalcharm.Actions, error)
GetCharmActions returns the actions for the charm using the charm name, source and revision.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmArchive ¶
func (s *Service) GetCharmArchive(ctx context.Context, locator charm.CharmLocator) (io.ReadCloser, string, error)
GetCharmArchive returns a ReadCloser stream for the charm archive for a given charm id, along with the hash of the charm archive. Clients can use the hash to verify the integrity of the charm archive.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmArchiveBySHA256Prefix ¶
func (s *Service) GetCharmArchiveBySHA256Prefix(ctx context.Context, sha256Prefix string) (io.ReadCloser, error)
GetCharmArchiveBySHA256Prefix returns a ReadCloser stream for the charm archive who's SHA256 hash starts with the provided prefix.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmArchivePath ¶
func (s *Service) GetCharmArchivePath(ctx context.Context, locator charm.CharmLocator) (string, error)
GetCharmArchivePath returns the archive storage path for the charm using the charm name, source and revision.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmByApplicationID ¶
func (s *Service) GetCharmByApplicationID(ctx context.Context, id coreapplication.ID) ( internalcharm.Charm, charm.CharmLocator, error, )
GetCharmByApplicationID returns the charm for the specified application ID.
If the application does not exist, an error satisfying applicationerrors.ApplicationNotFound is returned. If the charm for the application does not exist, an error satisfying [applicationerrors.CharmNotFound is returned. If the application name is not valid, an error satisfying applicationerrors.ApplicationNameNotValid is returned.
func (*Service) GetCharmConfig ¶
func (s *Service) GetCharmConfig(ctx context.Context, locator charm.CharmLocator) (internalcharm.Config, error)
GetCharmConfig returns the config for the charm using the charm name, source and revision.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmDownloadInfo ¶
func (s *Service) GetCharmDownloadInfo(ctx context.Context, locator charm.CharmLocator) (*charm.DownloadInfo, error)
GetCharmDownloadInfo returns the download info for the charm using the charm name, source and revision.
func (*Service) GetCharmLXDProfile ¶
func (s *Service) GetCharmLXDProfile(ctx context.Context, locator charm.CharmLocator) (internalcharm.LXDProfile, charm.Revision, error)
GetCharmLXDProfile returns the LXD profile along with the revision of the charm using the charm name, source and revision.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmLocatorByApplicationName ¶
func (s *Service) GetCharmLocatorByApplicationName(ctx context.Context, name string) (charm.CharmLocator, error)
GetCharmLocatorByApplicationName returns a CharmLocator by application name. It returns an error if the charm can not be found by the name. This can also be used as a cheap way to see if a charm exists without needing to load the charm metadata.
Returns applicationerrors.ApplicationNameNotValid if the name is not valid, applicationerrors.ApplicationNotFound if the application is not found, and applicationerrors.CharmNotFound if the charm is not found.
func (*Service) GetCharmManifest ¶
func (s *Service) GetCharmManifest(ctx context.Context, locator charm.CharmLocator) (internalcharm.Manifest, error)
GetCharmManifest returns the manifest for the charm using the charm name, source and revision.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmMetadata ¶
func (s *Service) GetCharmMetadata(ctx context.Context, locator charm.CharmLocator) (internalcharm.Meta, error)
GetCharmMetadata returns the metadata for the charm using the charm name, source and revision.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmMetadataDescription ¶
func (s *Service) GetCharmMetadataDescription(ctx context.Context, locator charm.CharmLocator) (string, error)
GetCharmMetadataDescription returns the description for the charm using the charm name, source and revision.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmMetadataName ¶
func (s *Service) GetCharmMetadataName(ctx context.Context, locator charm.CharmLocator) (string, error)
GetCharmMetadataName returns the name for the charm using the charm name, source and revision.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmMetadataResources ¶
func (s *Service) GetCharmMetadataResources(ctx context.Context, locator charm.CharmLocator) (map[string]resource.Meta, error)
GetCharmMetadataResources returns the specifications for the resources for the charm using the charm name, source and revision.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmMetadataStorage ¶
func (s *Service) GetCharmMetadataStorage(ctx context.Context, locator charm.CharmLocator) (map[string]internalcharm.Storage, error)
GetCharmMetadataStorage returns the storage specification for the charm using the charm name, source and revision.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) GetCharmModifiedVersion ¶
GetCharmModifiedVersion looks up the charm modified version of the given application.
Returns applicationerrors.ApplicationNotFound if the application is not found.
func (*Service) GetLatestPendingCharmhubCharm ¶
func (s *Service) GetLatestPendingCharmhubCharm(ctx context.Context, name string, arch arch.Arch) (charm.CharmLocator, error)
GetLatestPendingCharmhubCharm returns the latest charm that is pending from the charmhub store. If there are no charms, returns is not found, as applicationerrors.CharmNotFound. If there are multiple charms, then the latest created at date is returned first.
func (*Service) GetUnitDisplayStatus ¶
func (s *Service) GetUnitDisplayStatus(ctx context.Context, unitName coreunit.Name) (*corestatus.StatusInfo, error)
GetUnitDisplayStatus returns the display status of the specified unit. The display status a function of both the unit workload status and the cloud container status. It returns an error satisfying applicationerrors.UnitNotFound if the unit doesn't exist.
func (*Service) GetUnitLife ¶
GetUnitLife looks up the life of the specified unit, returning an error satisfying applicationerrors.UnitNotFoundError if the unit is not found.
func (*Service) GetUnitUUID ¶
GetUnitUUID returns the UUID for the named unit, returning an error satisfying applicationerrors.UnitNotFound if the unit doesn't exist.
func (*Service) GetUnitWorkloadStatus ¶
func (s *Service) GetUnitWorkloadStatus(ctx context.Context, unitName coreunit.Name) (*corestatus.StatusInfo, error)
GetUnitWorkloadStatus returns the workload status of the specified unit, returning an error satisfying applicationerrors.UnitNotFound if the unit doesn't exist.
func (*Service) GetUnitWorkloadStatusesForApplication ¶
func (s *Service) GetUnitWorkloadStatusesForApplication(ctx context.Context, appID coreapplication.ID) (map[coreunit.Name]corestatus.StatusInfo, error)
GetUnitWorkloadStatusesForApplication returns the workload statuses of all units in the specified application, indexed by unit name, returning an error satisfying applicationerrors.ApplicationNotFound if the application doesn't exist.
func (*Service) IsCharmAvailable ¶
IsCharmAvailable returns whether the charm is available for use. This indicates if the charm has been uploaded to the controller. This will return true if the charm is available, and false otherwise.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) IsControllerCharm ¶
IsControllerCharm returns whether the charm is a controller charm. This will return true if the charm is a controller charm, and false otherwise.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) IsSubordinateCharm ¶
IsSubordinateCharm returns whether the charm is a subordinate charm. This will return true if the charm is a subordinate charm, and false otherwise.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) ListCharmLocators ¶
func (s *Service) ListCharmLocators(ctx context.Context, names ...string) ([]charm.CharmLocator, error)
ListCharmLocators returns a list of charm locators. The locator allows you to reconstruct the charm URL. If no names are provided, then all charms are listed. If no names are matched against the charm names, then an empty list is returned.
func (*Service) MarkApplicationDead ¶
MarkApplicationDead is called by the cleanup worker if a mongo destroy operation sets the application to dead. TODO(units): remove when everything is in dqlite.
func (*Service) RegisterCAASUnit ¶
func (s *Service) RegisterCAASUnit(ctx context.Context, appName string, args application.RegisterCAASUnitArg) error
RegisterCAASUnit creates or updates the specified application unit in a caas model, returning an error satisfying applicationerrors.ApplicationNotFoundError if the application doesn't exist. If the unit life is Dead, an error satisfying applicationerrors.UnitAlreadyExists is returned.
func (*Service) RemoveUnit ¶
func (s *Service) RemoveUnit(ctx context.Context, unitName coreunit.Name, leadershipRevoker leadership.Revoker) error
RemoveUnit is called by the deployer worker and caas application provisioner worker to remove from the model units which have transitioned to dead. TODO(units): revisit his existing logic ported from mongo Note: the callers of this method only do so after the unit has become dead, so there's strictly no need to set the life to Dead before removing. If the unit is still alive, an error satisfying applicationerrors.UnitIsAlive is returned. If the unit is not found, an error satisfying applicationerrors.UnitNotFound is returned.
func (*Service) ReserveCharmRevision ¶
func (s *Service) ReserveCharmRevision(ctx context.Context, args charm.ReserveCharmRevisionArgs) (corecharm.ID, []string, error)
ReserveCharmRevision creates a new charm revision placeholder in state. This includes all the metadata, actions, config and manifest for the charm. The charm revision placeholder will include all the associated hash, and download information for the charm. Once the new charm revision place holder is linked to an application, the async charm downloader will download the charm archive and set the charm as available.
If there are any non-blocking issues with the charm metadata, actions, config or manifest, a set of warnings will be returned.
If the placeholder already exists, it is a noop but still return the corresponding charm ID.
func (*Service) ResolveCharmDownload ¶
func (s *Service) ResolveCharmDownload(ctx context.Context, appID coreapplication.ID, resolve application.ResolveCharmDownload) error
ResolveCharmDownload resolves the charm download slot for the specified application. The method will update the charm with the specified charm information. This returns applicationerrors.CharmNotResolved if the charm UUID isn't the same as the one that was reserved.
func (*Service) ResolveControllerCharmDownload ¶
func (s *Service) ResolveControllerCharmDownload(ctx context.Context, resolve application.ResolveControllerCharmDownload) (application.ResolvedControllerCharmDownload, error)
ResolveControllerCharmDownload resolves the controller charm download slot.
func (*Service) ResolveUploadCharm ¶
func (s *Service) ResolveUploadCharm(ctx context.Context, args charm.ResolveUploadCharm) (charm.CharmLocator, error)
ResolveUploadCharm resolves the upload of a charm archive. If the charm is being imported from a migration then it can returns applicationerrors.CharmNotFound. Returns applicationerrors.CharmSourceNotValid if the source is not valid. Returns applicationerrors.CharmMetadataNotValid if the charm metadata is not valid. Returns applicationerrors.CharmNameNotValid if the reference name is not valid. Returns applicationerrors.CharmManifestNotFound if the charm manifest is not found. Returns applicationerrors.CharmDownloadInfoNotFound if the download info is not found. Returns applicationerrors.CharmNotFound if the charm is not found.
func (*Service) SetApplicationCharm ¶
func (s *Service) SetApplicationCharm(ctx context.Context, name string, params UpdateCharmParams) error
SetApplicationCharm sets a new charm for the application, validating that aspects such as storage are still viable with the new charm.
func (*Service) SetApplicationConfig ¶
func (s *Service) SetApplicationConfig(ctx context.Context, appID coreapplication.ID, newConfig map[string]string) error
SetApplicationConfig updates the application config with the specified values. If the key does not exist, it is created. If the key already exists, it is updated, if there is no value it is removed. With the caveat that application trust will be set to false. If no application is found, an error satisfying applicationerrors.ApplicationNotFound is returned. If the charm does not exist, an error satisfying applicationerrors.CharmNotFound is returned, if this is the case, then the application is in a bad state and should be removed. If the charm config is not valid, an error satisfying applicationerrors.CharmConfigNotValid is returned.
func (*Service) SetApplicationScale ¶
SetApplicationScale sets the application's desired scale value, returning an error satisfying applicationerrors.ApplicationNotFound if the application is not found. This is used on CAAS models.
func (*Service) SetApplicationScalingState ¶
func (s *Service) SetApplicationScalingState(ctx context.Context, appName string, scaleTarget int, scaling bool) error
SetApplicationScalingState updates the scale state of an application, returning an error satisfying applicationerrors.ApplicationNotFoundError if the application doesn't exist. This is used on CAAS models.
func (*Service) SetApplicationStatus ¶
func (s *Service) SetApplicationStatus( ctx context.Context, applicationID coreapplication.ID, status *corestatus.StatusInfo, ) error
SetApplicationStatus saves the given application status, overwriting any current status data. If returns an error satisfying applicationerrors.ApplicationNotFound if the application doesn't exist.
func (*Service) SetApplicationStatusForUnitLeader ¶
func (s *Service) SetApplicationStatusForUnitLeader( ctx context.Context, unitName coreunit.Name, status *corestatus.StatusInfo, ) error
SetApplicationStatusForUnitLeader sets the application status using the leader unit of the application. If the application has no leader unit, or the is not the leader unit of the application, an error satisfying applicationerrors.UnitNotLeader is returned. If the unit is not found, an error satisfying applicationerrors.UnitNotFound is returned.
func (*Service) SetCharm ¶
func (s *Service) SetCharm(ctx context.Context, args charm.SetCharmArgs) (corecharm.ID, []string, error)
SetCharm persists the charm metadata, actions, config and manifest to state. If there are any non-blocking issues with the charm metadata, actions, config or manifest, a set of warnings will be returned.
func (*Service) SetCharmAvailable ¶
SetCharmAvailable sets the charm as available for use.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) SetUnitPassword ¶
func (s *Service) SetUnitPassword(ctx context.Context, unitName coreunit.Name, password string) error
SetUnitPassword updates the password for the specified unit, returning an error satisfying applicationerrors.NotNotFound if the unit doesn't exist.
func (*Service) SetUnitWorkloadStatus ¶
func (s *Service) SetUnitWorkloadStatus(ctx context.Context, unitName coreunit.Name, status *corestatus.StatusInfo) error
SetUnitWorkloadStatus sets the workload status of the specified unit, returning an error satisfying applicationerrors.UnitNotFound if the unit doesn't exist.
func (*Service) SupportsContainers ¶
SupportsContainers returns whether the charm supports containers. This currently means that the charm is a kubernetes charm. This will return true if the charm is a controller charm, and false otherwise.
If the charm does not exist, a applicationerrors.CharmNotFound error is returned.
func (*Service) UnsetApplicationConfigKeys ¶
func (s *Service) UnsetApplicationConfigKeys(ctx context.Context, appID coreapplication.ID, keys []string) error
UnsetApplicationConfigKeys removes the specified keys from the application config. If the key does not exist, it is ignored. If no application is found, an error satisfying applicationerrors.ApplicationNotFound is returned.
func (*Service) UpdateCAASUnit ¶
func (s *Service) UpdateCAASUnit(ctx context.Context, unitName coreunit.Name, params UpdateCAASUnitParams) error
UpdateCAASUnit updates the specified CAAS unit, returning an error satisfying applicationerrors.ApplicationNotAlive if the unit's application is not alive.
func (*Service) UpdateCloudService ¶
func (s *Service) UpdateCloudService(ctx context.Context, appName, providerID string, sAddrs network.SpaceAddresses) error
UpdateCloudService updates the cloud service for the specified application, returning an error satisfying applicationerrors.ApplicationNotFoundError if the application doesn't exist.
type State ¶
type State interface { ApplicationState CharmState StorageState }
State represents a type for interacting with the underlying state.
type StorageState ¶
type StorageState interface { // GetStorageUUIDByID returns the UUID for the specified storage, returning an error // satisfying [github.com/juju/juju/domain/storage/errors.StorageNotFound] if the storage doesn't exist. GetStorageUUIDByID(ctx context.Context, storageID corestorage.ID) (corestorage.UUID, error) // AttachStorage attaches the specified storage to the specified unit. // The following error types can be expected: // - [github.com/juju/juju/domain/storage/errors.StorageNotFound] when the storage doesn't exist. // - [github.com/juju/juju/domain/application/errors.UnitNotFound]: when the unit does not exist. // - [github.com/juju/juju/domain/application/errors.StorageAlreadyAttached]: when the attachment already exists. // - [github.com/juju/juju/domain/application/errors.FilesystemAlreadyAttached]: when the filesystem is already attached. // - [github.com/juju/juju/domain/application/errors.VolumeAlreadyAttached]: when the volume is already attached. // - [github.com/juju/juju/domain/application/errors.UnitNotAlive]: when the unit is not alive. // - [github.com/juju/juju/domain/application/errors.StorageNotAlive]: when the storage is not alive. // - [github.com/juju/juju/domain/application/errors.StorageNameNotSupported]: when storage name is not defined in charm metadata. // - [github.com/juju/juju/domain/application/errors.InvalidStorageCount]: when the allowed attachment count would be violated. // - [github.com/juju/juju/domain/application/errors.InvalidStorageMountPoint]: when the filesystem being attached to the unit's machine has a mount point path conflict. AttachStorage(ctx context.Context, storageUUID corestorage.UUID, unitUUID coreunit.UUID) error // AddStorageForUnit adds storage instances to given unit as specified. // Missing storage constraints are populated based on model defaults. // The specified storage name is used to retrieve existing storage instances. // Combination of existing storage instances and anticipated additional storage // instances is validated as specified in the unit's charm. // The following error types can be expected: // - [github.com/juju/juju/domain/storage/errors.StorageNotFound] when the storage doesn't exist. // - [github.com/juju/juju/domain/application/errors.UnitNotFound]: when the unit does not exist. // - [github.com/juju/juju/domain/application/errors.UnitNotAlive]: when the unit is not alive. // - [github.com/juju/juju/domain/application/errors.StorageNotAlive]: when the storage is not alive. // - [github.com/juju/juju/domain/application/errors.StorageNameNotSupported]: when storage name is not defined in charm metadata. // - [github.com/juju/juju/domain/application/errors.InvalidStorageCount]: when the allowed attachment count would be violated. // - [github.com/juju/juju/domain/application/errors.InvalidStorageMountPoint]: when the filesystem being attached to the unit's machine has a mount point path conflict. AddStorageForUnit( ctx context.Context, storageName corestorage.Name, unitUUID coreunit.UUID, stor storage.Directive, ) ([]corestorage.ID, error) // DetachStorageForUnit detaches the specified storage from the specified unit. // The following error types can be expected: // - [github.com/juju/juju/domain/storage/errors.StorageNotFound] when the storage doesn't exist. // - [github.com/juju/juju/domain/application/errors.UnitNotFound]: when the unit does not exist. // - [github.com/juju/juju/domain/application/errors.StorageNotDetachable]: when the type of storage is not detachable. DetachStorageForUnit(ctx context.Context, storageUUID corestorage.UUID, unitUUID coreunit.UUID) error // DetachStorage detaches the specified storage from whatever node it is attached to. // The following error types can be expected: // - [github.com/juju/juju/domain/application/errors.StorageNotDetachable]: when the type of storage is not detachable. DetachStorage(ctx context.Context, storageUUID corestorage.UUID) error }
StorageState describes retrieval and persistence methods for storage related interactions.
type UpdateCAASUnitParams ¶
type UpdateCAASUnitParams struct { ProviderID *string Address *string Ports *[]string AgentStatus *status.StatusInfo WorkloadStatus *status.StatusInfo CloudContainerStatus *status.StatusInfo }
UpdateCAASUnitParams contains parameters for updating a CAAS unit.
type UpdateCharmParams ¶
type UpdateCharmParams struct { // Charm is the new charm to use for the application. New units // will be started with this charm, and existing units will be // upgraded to use it. Charm charm.Charm // Storage contains the storage directives to add or update when // upgrading the charm. // // Any existing storage instances for the named stores will be // unaffected; the storage directives will only be used for // provisioning new storage instances. Storage map[string]storage.Directive // CharmUpgradeOnError indicates whether the charm must be upgraded // even when on error. CharmUpgradeOnError bool }
UpdateCharmParams contains the parameters for updating an application's charm and storage.
type WatchableService ¶
type WatchableService struct { *ProviderService // contains filtered or unexported fields }
WatchableService provides the API for working with applications and the ability to create watchers.
func NewWatchableService ¶
func NewWatchableService( st State, leaderEnsurer leadership.Ensurer, storageRegistryGetter corestorage.ModelStorageRegistryGetter, modelID coremodel.UUID, watcherFactory WatcherFactory, agentVersionGetter AgentVersionGetter, provider providertracker.ProviderGetter[Provider], charmStore CharmStore, clock clock.Clock, logger logger.Logger, ) *WatchableService
NewWatchableService returns a new service reference wrapping the input state.
func (*WatchableService) WatchApplication ¶
func (s *WatchableService) WatchApplication(ctx context.Context, name string) (watcher.NotifyWatcher, error)
WatchApplication watches for changes to the specified application in the application table. If the application does not exist an error satisfying applicationerrors.NotFound will be returned.
func (*WatchableService) WatchApplicationConfig ¶
func (s *WatchableService) WatchApplicationConfig(ctx context.Context, name string) (watcher.NotifyWatcher, error)
WatchApplicationConfig watches for changes to the specified application's config. This notifies on any changes to the application's config, which is driven of the application config hash. It is up to the caller to determine if the config value they're interested in has changed.
If the application does not exist an error satisfying applicationerrors.NotFound will be returned.
func (*WatchableService) WatchApplicationConfigHash ¶
func (s *WatchableService) WatchApplicationConfigHash(ctx context.Context, name string) (watcher.StringsWatcher, error)
WatchApplicationConfigHash watches for changes to the specified application's config hash. This notifies on any changes to the application's config hash, which is driven of the application config hash. It is up to the caller to determine if the config value they're interested in has changed. This watcher is the backing for the uniter's remote state. We should be attempting to remove this in the future.
If the application does not exist an error satisfying applicationerrors.NotFound will be returned.
func (*WatchableService) WatchApplicationScale ¶
func (s *WatchableService) WatchApplicationScale(ctx context.Context, appName string) (watcher.NotifyWatcher, error)
WatchApplicationScale returns a watcher that observes changes to an application's scale.
func (*WatchableService) WatchApplicationUnitLife ¶
func (s *WatchableService) WatchApplicationUnitLife(appName string) (watcher.StringsWatcher, error)
WatchApplicationUnitLife returns a watcher that observes changes to the life of any units if an application.
func (*WatchableService) WatchApplicationsWithPendingCharms ¶
func (s *WatchableService) WatchApplicationsWithPendingCharms(ctx context.Context) (watcher.StringsWatcher, error)
WatchApplicationsWithPendingCharms returns a watcher that observes changes to applications that have pending charms.
func (*WatchableService) WatchCharms ¶
func (s *WatchableService) WatchCharms() (watcher.StringsWatcher, error)
WatchCharms returns a watcher that observes changes to charms.
type WatcherFactory ¶
type WatcherFactory interface { NewUUIDsWatcher( namespace string, changeMask changestream.ChangeType, ) (watcher.StringsWatcher, error) NewValueMapperWatcher(string, string, changestream.ChangeType, eventsource.Mapper, ) (watcher.NotifyWatcher, error) NewNamespaceMapperWatcher( namespace string, changeMask changestream.ChangeType, initialStateQuery eventsource.NamespaceQuery, mapper eventsource.Mapper, ) (watcher.StringsWatcher, error) NewValueWatcher( namespace, changeValue string, changeMask changestream.ChangeType, ) (watcher.NotifyWatcher, error) }
WatcherFactory instances return watchers for a given namespace and UUID.