mirror of
https://github.com/ncarlier/webhookd.git
synced 2025-04-09 18:43:43 +00:00

- No external dependencies - No predefined directory structure - Able to launch any kind of shell script with custom parameters - Get script output as text event stream (SSE) - Using common Makefiles - Extends docker/dind Docker image
28 lines
617 B
Go
28 lines
617 B
Go
package notification
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
)
|
|
|
|
// Notifier is able to send a notification.
|
|
type Notifier interface {
|
|
Notify(subject string, text string, attachfile string)
|
|
}
|
|
|
|
// NotifierFactory creates a notifier regarding the configuration.
|
|
func NotifierFactory() (Notifier, error) {
|
|
notifier := os.Getenv("APP_NOTIFIER")
|
|
switch notifier {
|
|
case "http":
|
|
return newHTTPNotifier(), nil
|
|
case "smtp":
|
|
return newSMTPNotifier(), nil
|
|
default:
|
|
if notifier == "" {
|
|
return nil, errors.New("notification provider not configured")
|
|
}
|
|
return nil, errors.New("unknown notification provider: " + notifier)
|
|
}
|
|
}
|