plugin: refactor plugin system to support initialization reporting

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2017-10-09 20:43:04 -07:00
parent fe52d9369f
commit 8508e8252b
21 changed files with 216 additions and 80 deletions

View File

@@ -41,19 +41,22 @@ func init() {
Requires: []plugin.Type{
plugin.MetadataPlugin,
},
Init: NewService,
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
m, err := ic.Get(plugin.MetadataPlugin)
if err != nil {
return nil, err
}
s, err := NewService(m.(*metadata.DB).ContentStore(), ic.Events)
return s, err
},
})
}
func NewService(ic *plugin.InitContext) (interface{}, error) {
m, err := ic.Get(plugin.MetadataPlugin)
if err != nil {
return nil, err
}
func NewService(cs content.Store, publisher events.Publisher) (*Service, error) {
return &Service{
store: m.(*metadata.DB).ContentStore(),
publisher: ic.Events,
store: cs,
publisher: publisher,
}, nil
}