From 7a4db5c7c0e953c1c5c3349881e28551ffad4149 Mon Sep 17 00:00:00 2001 From: Tim Reddehase Date: Fri, 24 Jul 2020 14:58:59 +0200 Subject: [PATCH] do not omit "empty" booleans in yaml output (#2317) The "empty" boolean is the false value. This means that values of false will not be present in the YAML output. As such they won't be displayed in the config section on the Status overview page (/#/status), which can be especially confusing for the SMTPRequireTLS (smtp_require_tls) field of the configuration as this one will default to true. Signed-off-by: Tim Reddehase --- config/config.go | 4 ++-- config/notifiers.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/config.go b/config/config.go index 485e9ac6..056311c7 100644 --- a/config/config.go +++ b/config/config.go @@ -550,7 +550,7 @@ type GlobalConfig struct { SMTPAuthPassword Secret `yaml:"smtp_auth_password,omitempty" json:"smtp_auth_password,omitempty"` SMTPAuthSecret Secret `yaml:"smtp_auth_secret,omitempty" json:"smtp_auth_secret,omitempty"` SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"` - SMTPRequireTLS bool `yaml:"smtp_require_tls,omitempty" json:"smtp_require_tls,omitempty"` + SMTPRequireTLS bool `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"` SlackAPIURL *SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"` PagerdutyURL *URL `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"` OpsGenieAPIURL *URL `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"` @@ -579,7 +579,7 @@ type Route struct { Match map[string]string `yaml:"match,omitempty" json:"match,omitempty"` MatchRE MatchRegexps `yaml:"match_re,omitempty" json:"match_re,omitempty"` - Continue bool `yaml:"continue,omitempty" json:"continue,omitempty"` + Continue bool `yaml:"continue" json:"continue,omitempty"` Routes []*Route `yaml:"routes,omitempty" json:"routes,omitempty"` GroupWait *model.Duration `yaml:"group_wait,omitempty" json:"group_wait,omitempty"` diff --git a/config/notifiers.go b/config/notifiers.go index d7385dd6..38171434 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -340,7 +340,7 @@ type SlackConfig struct { Pretext string `yaml:"pretext,omitempty" json:"pretext,omitempty"` Text string `yaml:"text,omitempty" json:"text,omitempty"` Fields []*SlackField `yaml:"fields,omitempty" json:"fields,omitempty"` - ShortFields bool `yaml:"short_fields,omitempty" json:"short_fields,omitempty"` + ShortFields bool `yaml:"short_fields" json:"short_fields,omitempty"` Footer string `yaml:"footer,omitempty" json:"footer,omitempty"` Fallback string `yaml:"fallback,omitempty" json:"fallback,omitempty"` CallbackID string `yaml:"callback_id,omitempty" json:"callback_id,omitempty"` @@ -348,7 +348,7 @@ type SlackConfig struct { IconURL string `yaml:"icon_url,omitempty" json:"icon_url,omitempty"` ImageURL string `yaml:"image_url,omitempty" json:"image_url,omitempty"` ThumbURL string `yaml:"thumb_url,omitempty" json:"thumb_url,omitempty"` - LinkNames bool `yaml:"link_names,omitempty" json:"link_names,omitempty"` + LinkNames bool `yaml:"link_names" json:"link_names,omitempty"` MrkdwnIn []string `yaml:"mrkdwn_in,omitempty" json:"mrkdwn_in,omitempty"` Actions []*SlackAction `yaml:"actions,omitempty" json:"actions,omitempty"` } @@ -551,7 +551,7 @@ type PushoverConfig struct { Priority string `yaml:"priority,omitempty" json:"priority,omitempty"` Retry duration `yaml:"retry,omitempty" json:"retry,omitempty"` Expire duration `yaml:"expire,omitempty" json:"expire,omitempty"` - HTML bool `yaml:"html,omitempty" json:"html,omitempty"` + HTML bool `yaml:"html" json:"html,omitempty"` } // UnmarshalYAML implements the yaml.Unmarshaler interface.