added test case for ansibles

This commit is contained in:
2021-07-16 06:20:37 +04:00
parent a3ddad6aca
commit 378c8bb75e
5 changed files with 59 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package plugin
import (
"context"
"errors"
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
"io/ioutil"
@@ -67,6 +68,36 @@ func DetectPlugins()(*Plugins,error){
return plugins,nil
}
// RunPlugin Executes plugins based on the plugin name provided
func RunPlugin(pluginName string ,IPAddresses []*ExecuteIP) (*Plugin,error) {
plugins, err := DetectPlugins()
if err != nil {
return nil,err
}
// Variable to store struct information about the plugin
var plugindetected *Plugin
for _,plugin := range plugins.PluginsDetected {
if plugin.FolderName == pluginName {
plugindetected = plugin
plugindetected.Execute = IPAddresses
break
}
}
if plugindetected == nil {
return nil, errors.New("Plugin not detected")
}
// Executing the plugin
err = plugindetected.ExecutePlugin()
if err != nil {
return nil,err
}
return plugindetected,nil
}
// ExecutePlugin Function to execute plugins that are called
func (p *Plugin) ExecutePlugin() error {
// Get Execute plugin path from config file