Documentation ¶
Overview ¶
Package updater constantly updates plugins installed to the Mattermost Server to the latest versions. Check Option API to see how to configure an *Updater.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoNewerVersion error is returned when plugin has no a newer version on the Marketplace. ErrNoNewerVersion = errors.New("plugin has no a newer version") // ErrPluginInSkipList error is returned when plugin is in the skip plugins list. ErrPluginInSkipList = errors.New("plugin restricted to be installed, it is in the skip list") // ErrDifferentPlugins error is returned when two plugins are not the same by their id. ErrDifferentPlugins = errors.New("plugins are not the same, it cannot be updated") )
Functions ¶
This section is empty.
Types ¶
type Changelog ¶
type Changelog struct { // UpdatedName of the plugin. UpdatedName string // UpdatedDescription of the plugin. UpdatedDescription string // PreviousVersion of the plugin. PreviousVersion string // UpdatedVersion of the plugin. UpdatedVersion string }
Changelog contains information about the recent update.
type Marketplace ¶
type Marketplace interface {
ListPlugins() (marketplace.Plugins, error)
}
Marketplace used to fetch latest versions of plugins from Mattermost Marketplace.
type Notification ¶
type Notification struct { // PluginID is the id of the plugin. PluginID string // Updated contains changelog information about the update and only filled // when a successful update is made. Updated *Changelog // Error can be a reason about why an update cannot be made, failed or can be // any other error. Error error }
Notification is sent when a plugin is updated, cannot be updated or if any error occurred during the update process.
type Option ¶
type Option func(*Updater)
Option used to customize Updater defaults.
func MarketplaceOption ¶
func MarketplaceOption(marketplace Marketplace) Option
MarketplaceOption sets a marketplace where Updater can use to fetch Marketplace plugins.
func NotificationsOption ¶
func NotificationsOption(notifications chan Notification) Option
NotificationsOption sets a notification chan to receive update related notifications. these notifications sent for every successful and unsuccessful updates and any errors occurred during an update process. notifications needs to be consumed within separate goroutines in order to not block the updater. notifications chan cannot be updated by the UpdateConfig(). trying it has no effects. notifications chan will be closed automatically after Updater is stopped.
func SkipPluginsOption ¶
SkipPluginsOption should provide a list of plugins(ids) to never update them.
func UpdateIntervalOption ¶
UpdateIntervalOption sets a time to wait before checking for updates again.
type ServerVersionError ¶
type ServerVersionError struct { // PluginID of the Plugin. PluginID string // CurrentPluginVersion is the currently installed version of the plugin. CurrentPluginVersion string // NextPluginVersion is the newest version of the plugin that we tried to install. NextPluginVersion string // CurrentServerVersion is the current version of the server. CurrentServerVersion string // RequiredServerVersion is minimum required server version. RequiredServerVersion string }
ServerVersionError is returned when new version of a plugin is not compatible with the current version of Mattermost Server.
func (*ServerVersionError) Error ¶
func (e *ServerVersionError) Error() string
type UpdateOp ¶
type UpdateOp struct {
// contains filtered or unexported fields
}
UpdateOp represents a new update operation between the installed plugin and the next plugin which is hosted in the Marketplace and might replace the installed one. UpdateOp used to compare these two plugins to find out if next plugin is really a new version of the installed one and is able to replace it.
func NewUpdateOp ¶
func NewUpdateOp(installed *model.Manifest, next *model.BaseMarketplacePlugin, skipList []string, serverVersion string) (*UpdateOp, error)
NewUpdateOp creates a new UpdateOp from installed and next plugin.
func (*UpdateOp) CanBeUpdated ¶
CanBeUpdated compares installed plugin and next plugin to check if next plugin is able to replace the installed one as its newer version.
func (*UpdateOp) CreateChangelog ¶
CreateChangelog creates a changelog about plugin update by comparing the installed version with the next version.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater constantly updates plugins installed to the Mattermost Server to the latest versions.
func New ¶
func New(papi plugin.API, marketplace Marketplace, dlockStore dlock.Store, options ...Option) *Updater
New creates new Updater with papi, marketplace, dlockStore and other options.
func (*Updater) Start ¶
Start starts updater to regularly check and do plugin updates. Start() blocks until pooling is cancelled and if there is any, waits for current update proccess to be competed before returning. calling Start() multiple times is a misuse. caller should initialize and use a new Updater.
func (*Updater) Stop ¶
Stop stops checking for updates and immediately returns. it does not interrupt current update process if there is any.
func (*Updater) StopWait ¶
StopWait gracefull stops Updater by waiting current update process to be completed before returning. program can safely close after StopWait() returns.
func (*Updater) UpdateConfig ¶
UpdateConfig overwrites options that set during the first initialization of New.