webhookd/pkg/notification/notifier_factory.go
Nicolas Carlier 14c214efdf refactor(): Complete refactoring.
- 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
2018-01-02 16:11:59 +00:00

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)
}
}