~xenrox/ntfy-alertmanager

af3857d1621bb5d5063a400713fcb05cd477d5dd — Thorben Günther 2 months ago dc9741b
config: Use "example.com" domain

This is recommended by RFC2606[1].

[1]: https://datatracker.ietf.org/doc/html/rfc2606
2 files changed, 17 insertions(+), 17 deletions(-)

M config.scfg
M config/config_test.go
M config.scfg => config.scfg +7 -7
@@ 3,9 3,9 @@
# but only the last occurrence of a setting will be used. Settings from
# the main configuration will take precedence.
include /etc/ntfy-alertmanager/ntfy.scfg
# Public facing base URL of the service (e.g. https://ntfy-alertmanager.xenrox.net)
# Public facing base URL of the service (e.g. https://ntfy-alertmanager.example.com)
# This setting is required for the "Silence" feature.
base-url https://ntfy-alertmanager.xenrox.net
base-url https://ntfy-alertmanager.example.com
# http listen address
http-address :8080
# Log level (either debug, info, warning, error)


@@ 25,9 25,9 @@ labels {
    severity "critical" {
        priority 5
        tags "rotating_light"
        icon "https://foo.com/critical.png"
        icon "https://example.com/critical.png"
        # Forward messages which severity "critical" to the specified email address.
        email-address foo@bar.com
        email-address foo@example.com
        # Call the specified number. Use `yes` to pick the first of your verified numbers.
        call yes
    }


@@ 44,7 44,7 @@ labels {
# Settings for resolved alerts
resolved {
    tags "resolved,partying_face"
    icon "https://foo.com/resolved.png"
    icon "https://example.com/resolved.png"
    priority 1
}



@@ 64,7 64,7 @@ ntfy {
    # For convenience ntfy-alertmanager will convert the certificate to lower case and remove all colons.
    certificate-fingerprint 13:6D:2B:88:9C:57:36:D0:81:B4:B2:9C:79:09:27:62:92:CF:B8:6A:6B:D3:AD:46:35:CB:70:17:EB:99:6E:28:08:2A:B8:C6:79:4B:F6:2E:81:79:41:98:1D:53:C8:07:B3:5C:24:5F:B1:8E:B6:FB:66:B5:DD:B4:D0:5C:29:91
    # Forward all messages to the specified email address.
    email-address foo@bar.com
    email-address foo@example.com
    # Call the specified number for all alerts. Use `yes` to pick the first of your verified numbers.
    call +123456789
}


@@ 84,7 84,7 @@ alertmanager {
    password pass
    # By default the Alertmanager URL gets parsed from the webhook. In case that
    # Alertmanger is not reachable under that URL, it can be overwritten here.
    url https://alertmanager.xenrox.net
    url https://alertmanager.example.com
}

# When the alert-mode is set to single, ntfy-alertmanager will cache each single alert

M config/config_test.go => config/config_test.go +10 -10
@@ 10,7 10,7 @@ import (

func TestReadConfig(t *testing.T) {
	configContent := `
base-url https://ntfy-alertmanager.xenrox.net
base-url https://ntfy-alertmanager.example.com
http-address :8080
log-level info
log-format json


@@ 24,8 24,8 @@ labels {
    severity "critical" {
        priority 5
        tags "rotating_light"
        icon "https://foo.com/critical.png"
        email-address foo@bar.com
        icon "https://example.com/critical.png"
        email-address foo@example.com
        call yes
    }



@@ 40,7 40,7 @@ labels {

resolved {
    tags "resolved,partying_face"
    icon "https://foo.com/resolved.png"
    icon "https://example.com/resolved.png"
    priority 1
}



@@ 55,7 55,7 @@ alertmanager {
    silence-duration 24h
    user user
    password pass
    url https://alertmanager.xenrox.net
    url https://alertmanager.example.com
}

cache {


@@ 66,7 66,7 @@ cache {
`

	expectedCfg := &Config{
		BaseURL:     "https://ntfy-alertmanager.xenrox.net",
		BaseURL:     "https://ntfy-alertmanager.example.com",
		HTTPAddress: ":8080",
		LogLevel:    "info",
		LogFormat:   "json",


@@ 84,8 84,8 @@ cache {
				"severity:critical": {
					Priority:     "5",
					Tags:         []string{"rotating_light"},
					Icon:         "https://foo.com/critical.png",
					EmailAddress: "foo@bar.com",
					Icon:         "https://example.com/critical.png",
					EmailAddress: "foo@example.com",
					Call:         "yes",
				},
				"severity:info":        {Priority: "1"},


@@ 102,11 102,11 @@ cache {
			SilenceDuration: time.Hour * 24,
			User:            "user",
			Password:        "pass",
			URL:             "https://alertmanager.xenrox.net",
			URL:             "https://alertmanager.example.com",
		},
		Resolved: resolvedConfig{
			Tags:     []string{"resolved", "partying_face"},
			Icon:     "https://foo.com/resolved.png",
			Icon:     "https://example.com/resolved.png",
			Priority: "1",
		},
	}