|
|
|
@ -47,36 +47,34 @@ func NewDefaultConstructor(signatureCalculator plugins.SignatureCalculator, asse |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Construct will calculate the plugin's signature state and create the plugin using the pluginFactoryFunc.
|
|
|
|
|
func (c *DefaultConstructor) Construct(ctx context.Context, src plugins.PluginSource, bundles []*plugins.FoundBundle) ([]*plugins.Plugin, error) { |
|
|
|
|
res := make([]*plugins.Plugin, 0, len(bundles)) |
|
|
|
|
func (c *DefaultConstructor) Construct(ctx context.Context, src plugins.PluginSource, bundle *plugins.FoundBundle) ([]*plugins.Plugin, error) { |
|
|
|
|
res := []*plugins.Plugin{} |
|
|
|
|
|
|
|
|
|
for _, bundle := range bundles { |
|
|
|
|
sig, err := c.signatureCalculator.Calculate(ctx, src, bundle.Primary) |
|
|
|
|
sig, err := c.signatureCalculator.Calculate(ctx, src, bundle.Primary) |
|
|
|
|
if err != nil { |
|
|
|
|
c.log.Warn("Could not calculate plugin signature state", "pluginId", bundle.Primary.JSONData.ID, "error", err) |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
plugin, err := c.pluginFactoryFunc(bundle.Primary, src.PluginClass(ctx), sig) |
|
|
|
|
if err != nil { |
|
|
|
|
c.log.Error("Could not create primary plugin base", "pluginId", bundle.Primary.JSONData.ID, "error", err) |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
res = append(res, plugin) |
|
|
|
|
|
|
|
|
|
children := make([]*plugins.Plugin, 0, len(bundle.Children)) |
|
|
|
|
for _, child := range bundle.Children { |
|
|
|
|
cp, err := c.pluginFactoryFunc(*child, plugin.Class, sig) |
|
|
|
|
if err != nil { |
|
|
|
|
c.log.Warn("Could not calculate plugin signature state", "pluginId", bundle.Primary.JSONData.ID, "error", err) |
|
|
|
|
continue |
|
|
|
|
c.log.Error("Could not create child plugin base", "pluginId", child.JSONData.ID, "error", err) |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
plugin, err := c.pluginFactoryFunc(bundle.Primary, src.PluginClass(ctx), sig) |
|
|
|
|
if err != nil { |
|
|
|
|
c.log.Error("Could not create primary plugin base", "pluginId", bundle.Primary.JSONData.ID, "error", err) |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
res = append(res, plugin) |
|
|
|
|
cp.Parent = plugin |
|
|
|
|
plugin.Children = append(plugin.Children, cp) |
|
|
|
|
|
|
|
|
|
children := make([]*plugins.Plugin, 0, len(bundle.Children)) |
|
|
|
|
for _, child := range bundle.Children { |
|
|
|
|
cp, err := c.pluginFactoryFunc(*child, plugin.Class, sig) |
|
|
|
|
if err != nil { |
|
|
|
|
c.log.Error("Could not create child plugin base", "pluginId", child.JSONData.ID, "error", err) |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
cp.Parent = plugin |
|
|
|
|
plugin.Children = append(plugin.Children, cp) |
|
|
|
|
|
|
|
|
|
children = append(children, cp) |
|
|
|
|
} |
|
|
|
|
res = append(res, children...) |
|
|
|
|
children = append(children, cp) |
|
|
|
|
} |
|
|
|
|
res = append(res, children...) |
|
|
|
|
|
|
|
|
|
return res, nil |
|
|
|
|
} |
|
|
|
|