File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717package plugin
1818
1919import (
20+ "context"
2021 "errors"
2122 "fmt"
2223 "sync"
@@ -116,6 +117,15 @@ type Registration struct {
116117 InitFn func (* InitContext ) (interface {}, error )
117118 // Disable the plugin from loading
118119 Disable bool
120+
121+ // ConfigMigration allows a plugin to migrate configurations from an older
122+ // version to handle plugin renames or moving of features from one plugin
123+ // to another in a later version.
124+ // The configuration map is keyed off the plugin name and the value
125+ // is the configuration for that objects, with the structure defined
126+ // for the plugin. No validation is done on the value before performing
127+ // the migration.
128+ ConfigMigration func (context.Context , int , map [string ]interface {}) error
119129}
120130
121131// Init the registered plugin
@@ -182,6 +192,13 @@ func Register(r *Registration) {
182192 register .r = append (register .r , r )
183193}
184194
195+ // Reset removes all global registrations
196+ func Reset () {
197+ register .Lock ()
198+ defer register .Unlock ()
199+ register .r = nil
200+ }
201+
185202func checkUnique (r * Registration ) error {
186203 for _ , registered := range register .r {
187204 if r .URI () == registered .URI () {
You can’t perform that action at this time.
0 commit comments