From 89e6e4abd85b4f4d8702aeb352f7dc34e1be38e9 Mon Sep 17 00:00:00 2001 From: TwiN Date: Tue, 11 Jan 2022 20:13:37 -0500 Subject: [PATCH] fix(alerting): Omit nil structs within alerting provider struct --- alerting/provider/custom/custom.go | 4 ++-- alerting/provider/discord/discord.go | 2 +- alerting/provider/mattermost/mattermost.go | 4 ++-- alerting/provider/slack/slack.go | 2 +- alerting/provider/teams/teams.go | 2 +- alerting/provider/telegram/telegram.go | 2 +- alerting/provider/twilio/twilio.go | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/alerting/provider/custom/custom.go b/alerting/provider/custom/custom.go index 06e12542..147a9417 100644 --- a/alerting/provider/custom/custom.go +++ b/alerting/provider/custom/custom.go @@ -22,10 +22,10 @@ type AlertProvider struct { Placeholders map[string]map[string]string `yaml:"placeholders,omitempty"` // ClientConfig is the configuration of the client used to communicate with the provider's target - ClientConfig *client.Config `yaml:"client"` + ClientConfig *client.Config `yaml:"client,omitempty"` // DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type - DefaultAlert *alert.Alert `yaml:"default-alert"` + DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"` } // IsValid returns whether the provider's configuration is valid diff --git a/alerting/provider/discord/discord.go b/alerting/provider/discord/discord.go index 33e279a5..281933d4 100644 --- a/alerting/provider/discord/discord.go +++ b/alerting/provider/discord/discord.go @@ -16,7 +16,7 @@ type AlertProvider struct { WebhookURL string `yaml:"webhook-url"` // DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type - DefaultAlert *alert.Alert `yaml:"default-alert"` + DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"` } // IsValid returns whether the provider's configuration is valid diff --git a/alerting/provider/mattermost/mattermost.go b/alerting/provider/mattermost/mattermost.go index 964aefc0..38e42d21 100644 --- a/alerting/provider/mattermost/mattermost.go +++ b/alerting/provider/mattermost/mattermost.go @@ -16,10 +16,10 @@ type AlertProvider struct { WebhookURL string `yaml:"webhook-url"` // ClientConfig is the configuration of the client used to communicate with the provider's target - ClientConfig *client.Config `yaml:"client"` + ClientConfig *client.Config `yaml:"client,omitempty"` // DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type - DefaultAlert *alert.Alert `yaml:"default-alert"` + DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"` } // IsValid returns whether the provider's configuration is valid diff --git a/alerting/provider/slack/slack.go b/alerting/provider/slack/slack.go index e48cf0f6..2de9e5cb 100644 --- a/alerting/provider/slack/slack.go +++ b/alerting/provider/slack/slack.go @@ -16,7 +16,7 @@ type AlertProvider struct { WebhookURL string `yaml:"webhook-url"` // Slack webhook URL // DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type - DefaultAlert *alert.Alert `yaml:"default-alert"` + DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"` } // IsValid returns whether the provider's configuration is valid diff --git a/alerting/provider/teams/teams.go b/alerting/provider/teams/teams.go index e2351ad8..217ad6ea 100644 --- a/alerting/provider/teams/teams.go +++ b/alerting/provider/teams/teams.go @@ -16,7 +16,7 @@ type AlertProvider struct { WebhookURL string `yaml:"webhook-url"` // DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type - DefaultAlert *alert.Alert `yaml:"default-alert"` + DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"` } // IsValid returns whether the provider's configuration is valid diff --git a/alerting/provider/telegram/telegram.go b/alerting/provider/telegram/telegram.go index 7a109f56..54488d59 100644 --- a/alerting/provider/telegram/telegram.go +++ b/alerting/provider/telegram/telegram.go @@ -17,7 +17,7 @@ type AlertProvider struct { ID string `yaml:"id"` // DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type - DefaultAlert *alert.Alert `yaml:"default-alert"` + DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"` } // IsValid returns whether the provider's configuration is valid diff --git a/alerting/provider/twilio/twilio.go b/alerting/provider/twilio/twilio.go index ed0a04e3..17ba2545 100644 --- a/alerting/provider/twilio/twilio.go +++ b/alerting/provider/twilio/twilio.go @@ -21,7 +21,7 @@ type AlertProvider struct { To string `yaml:"to"` // DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type - DefaultAlert *alert.Alert `yaml:"default-alert"` + DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"` } // IsValid returns whether the provider's configuration is valid