diff --git a/config.example.toml b/config.example.toml
index c64b4d1..badd50e 100644
--- a/config.example.toml
+++ b/config.example.toml
@@ -13,9 +13,16 @@ Draft = "true"
description = "blocked because not needed"
what = "fooo service"
-[[github]]
-Repos = ['synyx/tuwat', 'synyx/buchungsstreber']
-Tag = 'gh'
+# This adds example alerts in every flavor, useful for development
+# Should be disabled in production use
+[[example]]
+Tag = 'demo'
+
+# The github connector runs out af the box as configured below,
+# but keep in mind that github rate limits these requests.
+#[[github]]
+#Repos = ['synyx/tuwat', 'synyx/buchungsstreber']
+#Tag = 'gh'
#[[icinga2]]
#Tag = "synyx"
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 223d40e..c5504a4 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -15,6 +15,7 @@ import (
"github.com/BurntSushi/toml"
"github.com/synyx/tuwat/pkg/connectors"
"github.com/synyx/tuwat/pkg/connectors/alertmanager"
+ "github.com/synyx/tuwat/pkg/connectors/example"
"github.com/synyx/tuwat/pkg/connectors/github"
"github.com/synyx/tuwat/pkg/connectors/gitlabmr"
"github.com/synyx/tuwat/pkg/connectors/icinga2"
@@ -86,6 +87,7 @@ type rootConfig struct {
GitHubIssues []github.Config `toml:"github"`
Redmines []redmine.Config `toml:"redmine"`
Orderview []orderview.Config `toml:"orderview"`
+ Example []example.Config `toml:"example"`
}
func NewConfiguration() (*Config, error) {
@@ -204,6 +206,9 @@ func (cfg *Config) loadMainConfig(file string) error {
for _, connectorConfig := range rootConfig.Orderview {
cfg.Connectors = append(cfg.Connectors, orderview.NewConnector(&connectorConfig))
}
+ for _, connectorConfig := range rootConfig.Example {
+ cfg.Connectors = append(cfg.Connectors, example.NewConnector(&connectorConfig))
+ }
// Add template for
cfg.WhereTemplate, err = template.New("where").
diff --git a/pkg/connectors/example/connector.go b/pkg/connectors/example/connector.go
new file mode 100644
index 0000000..e4887ad
--- /dev/null
+++ b/pkg/connectors/example/connector.go
@@ -0,0 +1,114 @@
+package example
+
+import (
+ "context"
+ "fmt"
+ "github.com/synyx/tuwat/pkg/connectors"
+ html "html/template"
+ "time"
+)
+
+type Connector struct {
+ config Config
+}
+
+type Config struct {
+ Tag string
+}
+
+func NewConnector(cfg *Config) *Connector {
+ return &Connector{*cfg}
+}
+
+func (c *Connector) Tag() string {
+ return c.config.Tag
+}
+
+// Collect returns a few example warnings, one of each type
+// This eliminates the need to select a source that contains a given error type during development
+func (c *Connector) Collect(_ context.Context) ([]connectors.Alert, error) {
+
+ var alerts []connectors.Alert
+
+ alerts = append(alerts, exampleOkAlert())
+ alerts = append(alerts, exampleWarningAlert())
+ alerts = append(alerts, exampleCriticalAlert())
+ alerts = append(alerts, exampleUnknownAlert())
+
+ return alerts, nil
+}
+
+func exampleOkAlert() connectors.Alert {
+ alert := connectors.Alert{
+ Labels: map[string]string{
+ "Project": "Example Alerts",
+ "Culprit": "Geras",
+ "EscalateTo": "BuJo",
+ },
+ Start: time.Now().Add(-time.Hour * 2),
+ State: connectors.OK,
+ Description: "OK",
+ Details: "Nothing to worry about, just informing you that nothing bad happened",
+ Links: []html.HTML{
+ html.HTML("🏠"),
+ },
+ }
+ return alert
+}
+func exampleWarningAlert() connectors.Alert {
+ alert := connectors.Alert{
+ Labels: map[string]string{
+ "Project": "Example Alerts",
+ "Culprit": "Geras",
+ "EscalateTo": "BuJo",
+ },
+ Start: time.Now().Add(-time.Hour * 2),
+ State: connectors.Warning,
+ Description: "Warning",
+ Details: "This is a warning! Coffee is low!",
+ Links: []html.HTML{
+ html.HTML("🏠"),
+ },
+ }
+ return alert
+}
+
+func exampleCriticalAlert() connectors.Alert {
+ alert := connectors.Alert{
+ Labels: map[string]string{
+ "Project": "Example Alerts",
+ "Culprit": "Geras",
+ "EscalateTo": "BuJo",
+ },
+ Start: time.Now().Add(-time.Hour * 2),
+ State: connectors.Critical,
+ Description: "Critical",
+ Details: "This is a critical alert! We ran out of coffee!",
+ Links: []html.HTML{
+ html.HTML("🏠"),
+ },
+ }
+ return alert
+}
+
+func exampleUnknownAlert() connectors.Alert {
+ alert := connectors.Alert{
+ Labels: map[string]string{
+ "Project": "Example Alerts",
+ "Culprit": "Geras",
+ "EscalateTo": "BuJo",
+ },
+ Start: time.Now().Add(-time.Hour * 2),
+ State: connectors.Unknown,
+ Description: "Unknown",
+ Details: "We have no idea what happened here",
+ Links: []html.HTML{
+ html.HTML("🏠"),
+ },
+ }
+ return alert
+}
+
+func (c *Connector) String() string {
+ return fmt.Sprintf("Example Connector")
+}