expose the FormatAlert function to other packages (#2248)

This commit is contained in:
blotus 2023-07-25 09:55:39 +02:00 committed by GitHub
parent f12ff3dfed
commit 7106d396dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View file

@ -323,7 +323,7 @@ func (pb *PluginBroker) pushNotificationsToPlugin(pluginName string, alerts []*m
return nil
}
message, err := formatAlerts(pb.pluginConfigByName[pluginName].Format, alerts)
message, err := FormatAlerts(pb.pluginConfigByName[pluginName].Format, alerts)
if err != nil {
return err
}
@ -407,7 +407,7 @@ func getHandshake() (plugin.HandshakeConfig, error) {
return handshake, nil
}
func formatAlerts(format string, alerts []*models.Alert) (string, error) {
func FormatAlerts(format string, alerts []*models.Alert) (string, error) {
template, err := template.New("").Funcs(sprig.TxtFuncMap()).Funcs(funcMap()).Parse(format)
if err != nil {
return "", err

View file

@ -1,4 +1,4 @@
//go:build linux || freebsd || netbsd || openbsd || solaris || !windows
//go:build linux || freebsd || netbsd || openbsd || solaris || (!windows && !js)
package csplugin

17
pkg/csplugin/utils_js.go Normal file
View file

@ -0,0 +1,17 @@
package csplugin
import "os/exec"
//All functions are empty, just to make the code compile when targeting js/wasm
func (pb *PluginBroker) CreateCmd(binaryPath string) (*exec.Cmd, error) {
return nil, nil
}
func getPluginTypeAndSubtypeFromPath(path string) (string, string, error) {
return "", "", nil
}
func pluginIsValid(path string) error {
return nil
}