From: Daniel Swarbrick <dswarbrick@debian.org>
Date: Thu, 16 Jan 2025 20:08:28 +0100
Subject: Disable Jira notification

The Jira notification feature depends on a huge and apparently no longer
maintained library, github.com/trivago/tgo, which is not currently
packaged for Debian, all for the sake of a ~30 line function.

Until this feature is reimplemented using more reasonable dependencies,
disable it.
---
 config/config.go            | 16 ---------------
 config/notifiers.go         | 47 ---------------------------------------------
 config/receiver/receiver.go |  4 ----
 notify/notify.go            |  1 -
 template/default.tmpl       | 39 -------------------------------------
 5 files changed, 107 deletions(-)

diff --git a/config/config.go b/config/config.go
index 6f54c52..e8cf90b 100644
--- a/config/config.go
+++ b/config/config.go
@@ -292,9 +292,6 @@ func resolveFilepaths(baseDir string, cfg *Config) {
 		for _, cfg := range receiver.MSTeamsV2Configs {
 			cfg.HTTPConfig.SetDirectory(baseDir)
 		}
-		for _, cfg := range receiver.JiraConfigs {
-			cfg.HTTPConfig.SetDirectory(baseDir)
-		}
 		for _, cfg := range receiver.RocketchatConfigs {
 			cfg.HTTPConfig.SetDirectory(baseDir)
 		}
@@ -599,17 +596,6 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
 				return errors.New("no msteamsv2 webhook URL or URLFile provided")
 			}
 		}
-		for _, jira := range rcv.JiraConfigs {
-			if jira.HTTPConfig == nil {
-				jira.HTTPConfig = c.Global.HTTPConfig
-			}
-			if jira.APIURL == nil {
-				if c.Global.JiraAPIURL == nil {
-					return errors.New("no global Jira Cloud URL set")
-				}
-				jira.APIURL = c.Global.JiraAPIURL
-			}
-		}
 		for _, rocketchat := range rcv.RocketchatConfigs {
 			if rocketchat.HTTPConfig == nil {
 				rocketchat.HTTPConfig = c.Global.HTTPConfig
@@ -837,7 +823,6 @@ type GlobalConfig struct {
 
 	HTTPConfig *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"`
 
-	JiraAPIURL            *URL                 `yaml:"jira_api_url,omitempty" json:"jira_api_url,omitempty"`
 	SMTPFrom              string               `yaml:"smtp_from,omitempty" json:"smtp_from,omitempty"`
 	SMTPHello             string               `yaml:"smtp_hello,omitempty" json:"smtp_hello,omitempty"`
 	SMTPSmarthost         HostPort             `yaml:"smtp_smarthost,omitempty" json:"smtp_smarthost,omitempty"`
@@ -1019,7 +1004,6 @@ type Receiver struct {
 	WebexConfigs      []*WebexConfig      `yaml:"webex_configs,omitempty" json:"webex_configs,omitempty"`
 	MSTeamsConfigs    []*MSTeamsConfig    `yaml:"msteams_configs,omitempty" json:"msteams_configs,omitempty"`
 	MSTeamsV2Configs  []*MSTeamsV2Config  `yaml:"msteamsv2_configs,omitempty" json:"msteamsv2_configs,omitempty"`
-	JiraConfigs       []*JiraConfig       `yaml:"jira_configs,omitempty" json:"jira_configs,omitempty"`
 	RocketchatConfigs []*RocketchatConfig `yaml:"rocketchat_configs,omitempty" json:"rocketchat_configs,omitempty"`
 }
 
diff --git a/config/notifiers.go b/config/notifiers.go
index 87f806a..d5dfaf2 100644
--- a/config/notifiers.go
+++ b/config/notifiers.go
@@ -23,7 +23,6 @@ import (
 	"time"
 
 	commoncfg "github.com/prometheus/common/config"
-	"github.com/prometheus/common/model"
 	"github.com/prometheus/sigv4"
 )
 
@@ -194,15 +193,6 @@ var (
 		Title: `{{ template "msteamsv2.default.title" . }}`,
 		Text:  `{{ template "msteamsv2.default.text" . }}`,
 	}
-
-	DefaultJiraConfig = JiraConfig{
-		NotifierConfig: NotifierConfig{
-			VSendResolved: true,
-		},
-		Summary:     `{{ template "jira.default.summary" . }}`,
-		Description: `{{ template "jira.default.description" . }}`,
-		Priority:    `{{ template "jira.default.priority" . }}`,
-	}
 )
 
 // NotifierConfig contains base options common across all notifier configurations.
@@ -892,43 +882,6 @@ func (c *MSTeamsV2Config) UnmarshalYAML(unmarshal func(interface{}) error) error
 	return nil
 }
 
-type JiraConfig struct {
-	NotifierConfig `yaml:",inline" json:",inline"`
-	HTTPConfig     *commoncfg.HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"`
-
-	APIURL *URL `yaml:"api_url,omitempty" json:"api_url,omitempty"`
-
-	Project     string   `yaml:"project,omitempty" json:"project,omitempty"`
-	Summary     string   `yaml:"summary,omitempty" json:"summary,omitempty"`
-	Description string   `yaml:"description,omitempty" json:"description,omitempty"`
-	Labels      []string `yaml:"labels,omitempty" json:"labels,omitempty"`
-	Priority    string   `yaml:"priority,omitempty" json:"priority,omitempty"`
-	IssueType   string   `yaml:"issue_type,omitempty" json:"issue_type,omitempty"`
-
-	ReopenTransition  string         `yaml:"reopen_transition,omitempty" json:"reopen_transition,omitempty"`
-	ResolveTransition string         `yaml:"resolve_transition,omitempty" json:"resolve_transition,omitempty"`
-	WontFixResolution string         `yaml:"wont_fix_resolution,omitempty" json:"wont_fix_resolution,omitempty"`
-	ReopenDuration    model.Duration `yaml:"reopen_duration,omitempty" json:"reopen_duration,omitempty"`
-
-	Fields map[string]any `yaml:"fields,omitempty" json:"custom_fields,omitempty"`
-}
-
-func (c *JiraConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
-	*c = DefaultJiraConfig
-	type plain JiraConfig
-	if err := unmarshal((*plain)(c)); err != nil {
-		return err
-	}
-
-	if c.Project == "" {
-		return errors.New("missing project in jira_config")
-	}
-	if c.IssueType == "" {
-		return errors.New("missing issue_type in jira_config")
-	}
-	return nil
-}
-
 type RocketchatAttachmentField struct {
 	Short *bool  `json:"short"`
 	Title string `json:"title,omitempty"`
diff --git a/config/receiver/receiver.go b/config/receiver/receiver.go
index d92a19a..eceac1f 100644
--- a/config/receiver/receiver.go
+++ b/config/receiver/receiver.go
@@ -23,7 +23,6 @@ import (
 	"github.com/prometheus/alertmanager/notify"
 	"github.com/prometheus/alertmanager/notify/discord"
 	"github.com/prometheus/alertmanager/notify/email"
-	"github.com/prometheus/alertmanager/notify/jira"
 	"github.com/prometheus/alertmanager/notify/msteams"
 	"github.com/prometheus/alertmanager/notify/msteamsv2"
 	"github.com/prometheus/alertmanager/notify/opsgenie"
@@ -103,9 +102,6 @@ func BuildReceiverIntegrations(nc config.Receiver, tmpl *template.Template, logg
 	for i, c := range nc.MSTeamsV2Configs {
 		add("msteamsv2", i, c, func(l *slog.Logger) (notify.Notifier, error) { return msteamsv2.New(c, tmpl, l, httpOpts...) })
 	}
-	for i, c := range nc.JiraConfigs {
-		add("jira", i, c, func(l *slog.Logger) (notify.Notifier, error) { return jira.New(c, tmpl, l, httpOpts...) })
-	}
 	for i, c := range nc.RocketchatConfigs {
 		add("rocketchat", i, c, func(l *slog.Logger) (notify.Notifier, error) { return rocketchat.New(c, tmpl, l, httpOpts...) })
 	}
diff --git a/notify/notify.go b/notify/notify.go
index 8fa85c0..5cd31e4 100644
--- a/notify/notify.go
+++ b/notify/notify.go
@@ -365,7 +365,6 @@ func (m *Metrics) InitializeFor(receiver map[string][]Integration) {
 		"webex",
 		"msteams",
 		"msteamsv2",
-		"jira",
 		"rocketchat",
 	} {
 		m.numNotifications.WithLabelValues(integration)
diff --git a/template/default.tmpl b/template/default.tmpl
index 57e877c..2a8697b 100644
--- a/template/default.tmpl
+++ b/template/default.tmpl
@@ -172,45 +172,6 @@ Alerts Resolved:
 {{ end }}
 {{ end }}
 
-{{ define "jira.default.summary" }}{{ template "__subject" . }}{{ end }}
-{{ define "jira.default.description" }}
-{{ if gt (len .Alerts.Firing) 0 }}
-# Alerts Firing:
-{{ template "__text_alert_list_markdown" .Alerts.Firing }}
-{{ end }}
-{{ if gt (len .Alerts.Resolved) 0 }}
-# Alerts Resolved:
-{{ template "__text_alert_list_markdown" .Alerts.Resolved }}
-{{ end }}
-{{ end }}
-
-{{- define "jira.default.priority" -}}
-{{- $priority := "" }}
-{{- range .Alerts.Firing -}}
-    {{- $severity := index .Labels "severity" -}}
-    {{- if (eq $severity "critical") -}}
-        {{- $priority = "High" -}}
-    {{- else if (and (eq $severity "warning") (ne $priority "High")) -}}
-        {{- $priority = "Medium" -}}
-    {{- else if (and (eq $severity "info") (eq $priority "")) -}}
-        {{- $priority = "Low" -}}
-    {{- end -}}
-{{- end -}}
-{{- if eq $priority "" -}}
-    {{- range .Alerts.Resolved -}}
-        {{- $severity := index .Labels "severity" -}}
-        {{- if (eq $severity "critical") -}}
-            {{- $priority = "High" -}}
-        {{- else if (and (eq $severity "warning") (ne $priority "High")) -}}
-            {{- $priority = "Medium" -}}
-        {{- else if (and (eq $severity "info") (eq $priority "")) -}}
-            {{- $priority = "Low" -}}
-        {{- end -}}
-    {{- end -}}
-{{- end -}}
-{{- $priority -}}
-{{- end -}}
-
 {{ define "rocketchat.default.title" }}{{ template "__subject" . }}{{ end }}
 {{ define "rocketchat.default.alias" }}{{ template "__alertmanager" . }}{{ end }}
 {{ define "rocketchat.default.titlelink" }}{{ template "__alertmanagerURL" . }}{{ end }}
