Detect missing plugin binary wrt profiles (#1252)

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
This commit is contained in:
Shivam Sandbhor 2022-02-14 22:15:03 +05:30 committed by GitHub
parent 5817fa4147
commit 43d5690432
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -176,6 +176,7 @@ func (pb *PluginBroker) loadConfig(path string) error {
return err
}
// checks whether every notification in profile has it's own config file
func (pb *PluginBroker) verifyPluginConfigsWithProfile() error {
for _, profileCfg := range pb.profileConfigs {
for _, pluginName := range profileCfg.Notifications {
@ -188,6 +189,18 @@ func (pb *PluginBroker) verifyPluginConfigsWithProfile() error {
return nil
}
// check whether each plugin in profile has it's own binary
func (pb *PluginBroker) verifyPluginBinaryWithProfile() error {
for _, profileCfg := range pb.profileConfigs {
for _, pluginName := range profileCfg.Notifications {
if _, ok := pb.notificationPluginByName[pluginName]; !ok {
return fmt.Errorf("binary for plugin %s not found", pluginName)
}
}
}
return nil
}
func (pb *PluginBroker) loadPlugins(path string) error {
binaryPaths, err := listFilesAtPath(path)
if err != nil {
@ -231,7 +244,7 @@ func (pb *PluginBroker) loadPlugins(path string) error {
pb.notificationPluginByName[pc.Name] = pluginClient
}
}
return err
return pb.verifyPluginBinaryWithProfile()
}
func (pb *PluginBroker) loadNotificationPlugin(name string, binaryPath string) (Notifier, error) {