expose the FormatAlert function to other packages (#2248)
This commit is contained in:
parent
f12ff3dfed
commit
7106d396dc
3 changed files with 20 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
17
pkg/csplugin/utils_js.go
Normal 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
|
||||
}
|
Loading…
Reference in a new issue