Documentation
¶
Overview ¶
Package charmrevisioner defines the charm revision updater worker. This worker is responsible for polling Charmhub every 24 hours to check if there are new revisions available of any repository charm deployed in the model. If so, it will put a document in the Juju database, so that the next time the user runs `juju status`, they can see that there is an update available. This worker also sends anonymised usage metrics to Charmhub when it polls.
This worker doesn't contain much business logic - most of the work is delegated to the facade call.
Index ¶
- Constants
- func Manifold(cfg ManifoldConfig) dependency.Manifold
- func NewHTTPClient(ctx context.Context, getter corehttp.HTTPClientGetter) (corehttp.HTTPClient, error)
- func NewWorker(config Config) (worker.Worker, error)
- type ApplicationService
- type CharmhubClient
- type Config
- type ManifoldConfig
- type ModelConfigService
- type ModelService
- type NewCharmhubClientFunc
- type NewHTTPClientFunc
- type ResourceService
Constants ¶
const ( // ErrFailedToSendMetrics is the error returned when sending metrics to the // charmhub fails. ErrFailedToSendMetrics = internalerrors.ConstError("sending metrics failed") )
Variables ¶
This section is empty.
Functions ¶
func Manifold ¶
func Manifold(cfg ManifoldConfig) dependency.Manifold
Manifold returns a dependency.Manifold that runs a charm revision worker according to the supplied configuration.
func NewHTTPClient ¶
func NewHTTPClient(ctx context.Context, getter corehttp.HTTPClientGetter) (corehttp.HTTPClient, error)
NewHTTPClient creates a new HTTP client.
Types ¶
type ApplicationService ¶
type ApplicationService interface { // GetApplicationIDByName returns an application ID by application name. It // returns an error if the application can not be found by the name. // // Returns [applicationerrors.ApplicationNotFound] if the application is not found. GetApplicationIDByName(ctx context.Context, name string) (coreapplication.ID, error) // GetApplicationsForRevisionUpdater returns the applications that should be // used by the revision updater. GetApplicationsForRevisionUpdater(context.Context) ([]application.RevisionUpdaterApplication, error) // ReserveCharmRevision reserves a charm revision for the given charm id. // If there are any non-blocking issues with the charm metadata, actions, // config or manifest, a set of warnings will be returned. ReserveCharmRevision(ctx context.Context, args applicationcharm.ReserveCharmRevisionArgs) (corecharm.ID, []string, error) }
ApplicationService provides access to applications.
type CharmhubClient ¶
type CharmhubClient interface { // RefreshWithMetricsOnly defines a client making a refresh API call with no // action, whose purpose is to send metrics data for models without current // units. E.G. the controller model. RefreshWithMetricsOnly(context.Context, charmhub.Metrics) error // RefreshWithRequestMetrics defines a client making a refresh API call with // a request and metrics data. RefreshWithRequestMetrics(context.Context, charmhub.RefreshConfig, charmhub.Metrics) ([]transport.RefreshResponse, error) }
CharmhubClient is responsible for refreshing charms from the charm store.
func NewCharmhubClient ¶
func NewCharmhubClient(httpClient charmhub.HTTPClient, url string, logger logger.Logger) (CharmhubClient, error)
NewCharmhubClient creates a new CharmhubClient.
type Config ¶
type Config struct { // ModelConfigService is the service used to access model configuration. ModelConfigService ModelConfigService // ApplicationService is the service used to access applications. ApplicationService ApplicationService // ModelService is the service used to access the model. ModelService ModelService // ResourceService is the service for managing resources ResourceService ResourceService // ModelTag is the tag of the model the worker is running in. ModelTag names.ModelTag // HTTPClientGetter is the getter used to create HTTP clients. HTTPClientGetter corehttp.HTTPClientGetter // NewHTTPClient is the function used to create a new HTTP client. NewHTTPClient NewHTTPClientFunc // NewCharmhubClient is the function used to create a new CharmhubClient. NewCharmhubClient NewCharmhubClientFunc // Clock is the worker's view of time. Clock clock.Clock // Period is the time between charm revision updates. Period time.Duration // Logger is the logger used for debug logging in this worker. Logger logger.Logger }
Config defines the operation of a charm revision updater worker.
type ManifoldConfig ¶
type ManifoldConfig struct { DomainServicesName string HTTPClientName string Period time.Duration NewWorker func(Config) (worker.Worker, error) ModelTag names.ModelTag NewHTTPClient NewHTTPClientFunc NewCharmhubClient NewCharmhubClientFunc Logger logger.Logger Clock clock.Clock }
ManifoldConfig describes how to create a worker that checks for updates available to deployed charms in an environment.
func (ManifoldConfig) Validate ¶
func (cfg ManifoldConfig) Validate() error
Validate is called by start to check for bad configuration.
type ModelConfigService ¶
type ModelConfigService interface { // ModelConfig returns the current config for the model. ModelConfig(context.Context) (*config.Config, error) // Watch returns a watcher that notifies of changes to the model config. Watch() (watcher.StringsWatcher, error) }
ModelConfigService provides access to the model configuration.
type ModelService ¶
type ModelService interface { // GetModelMetrics returns the model metrics information set in the // database. GetModelMetrics(context.Context) (coremodel.ModelMetrics, error) }
ModelService provides access to the model.
type NewCharmhubClientFunc ¶
type NewCharmhubClientFunc func(charmhub.HTTPClient, string, logger.Logger) (CharmhubClient, error)
NewCharmhubClientFunc is a function that creates a new CharmhubClient.
type NewHTTPClientFunc ¶
type NewHTTPClientFunc func(context.Context, corehttp.HTTPClientGetter) (corehttp.HTTPClient, error)
NewHTTPClientFunc is a function that creates a new HTTP client.
type ResourceService ¶
type ResourceService interface { // SetRepositoryResources updates the last available revision of resources // from charm repository for a specific application. SetRepositoryResources(ctx context.Context, args domainresource.SetRepositoryResourcesArgs) error }
ResourceService defines the interface for managing resources associated with applications.