diff --git a/pkg/csplugin/broker.go b/pkg/csplugin/broker.go index b1bd54dfd..208ce9336 100644 --- a/pkg/csplugin/broker.go +++ b/pkg/csplugin/broker.go @@ -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 diff --git a/pkg/csplugin/utils.go b/pkg/csplugin/utils.go index 5e19dee38..216a079d4 100644 --- a/pkg/csplugin/utils.go +++ b/pkg/csplugin/utils.go @@ -1,4 +1,4 @@ -//go:build linux || freebsd || netbsd || openbsd || solaris || !windows +//go:build linux || freebsd || netbsd || openbsd || solaris || (!windows && !js) package csplugin diff --git a/pkg/csplugin/utils_js.go b/pkg/csplugin/utils_js.go new file mode 100644 index 000000000..e6cccab4b --- /dev/null +++ b/pkg/csplugin/utils_js.go @@ -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 +}