(plugin Metadata, event string, env map[string]string)
| 241 | } |
| 242 | |
| 243 | func executePluginHookAt(plugin Metadata, event string, env map[string]string) error { |
| 244 | pluginFolder := plugin.PluginFolder |
| 245 | for _, pluginHook := range plugin.Hooks { |
| 246 | if strings.TrimSpace(pluginHook.Event) == event { |
| 247 | var err error |
| 248 | if pluginHook.Background { |
| 249 | err = CallPluginExecutableInBackground(filepath.Join(pluginFolder, PluginBinary), pluginHook.BaseArgs, env) |
| 250 | } else { |
| 251 | err = CallPluginExecutable(filepath.Join(pluginFolder, PluginBinary), pluginHook.BaseArgs, env, os.Stdout) |
| 252 | } |
| 253 | if err != nil { |
| 254 | return fmt.Errorf("error calling plugin hook %s at event %s: %v", plugin.Name, event, err) |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | return nil |
| 259 | } |
| 260 | |
| 261 | func CallPluginExecutableInBackground(main string, argv []string, extraEnvVars map[string]string) error { |
| 262 | env := os.Environ() |
no test coverage detected