Skip to content

Commit

Permalink
♻️ use providers with added configurations & update deploy files (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
amgadramses authored Dec 19, 2021
1 parent fb63f3a commit 9bf19d6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ kubectl apply -f https://raw.githubusercontent.com/abahmed/kwatch/v0.0.4/deploy/
| `providers.discord.text` | Customized text in discord message | No |
| `providers.pagerduty.integrationKey` | PagerDuty integration key [more info](https://support.pagerduty.com/docs/services-and-integrations) | Yes |

Each provider can be enabled or disabled separately using the boolean property `enabled`.

### Cleanup

Expand Down
3 changes: 0 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
maxRecentLogLines: 0
providers:
slack:
enabled: true
webhook: ""
pagerduty:
enabled: true
integrationKey: ""
discord:
enabled: true
webhook: ""
4 changes: 4 additions & 0 deletions deploy/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ data:
maxRecentLogLines: <optional_number_of_lines>
providers:
slack:
webhook: <webhook_url>
pagerduty:
integrationKey: <integration_key>
discord:
webhook: <webhook_url>
20 changes: 9 additions & 11 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,15 @@ func GetProviders() []provider.Provider {
var providers []provider.Provider

for key, value := range viper.Get("providers").(map[string]interface{}) {
for e, b := range value.(map[string]interface{}) {
if e == "enabled" && b == true {
if key == "slack" {
providers = append(providers, provider.NewSlack(viper.GetString("providers.slack.webhook")))
}
if key == "pagerduty" {
providers = append(providers, provider.NewPagerDuty(viper.GetString("providers.pagerduty.integrationKey")))
}
if key == "discord" {
providers = append(providers, provider.NewDiscord(viper.GetString("providers.discord.webhook")))
}
for c, v := range value.(map[string]interface{}) {
if key == "slack" && c == "webhook" && len(strings.TrimSpace(v.(string))) > 0 {
providers = append(providers, provider.NewSlack(viper.GetString("providers.slack.webhook")))
}
if key == "pagerduty" && c == "integrationkey" && len(strings.TrimSpace(v.(string))) > 0 {
providers = append(providers, provider.NewPagerDuty(viper.GetString("providers.pagerduty.integrationKey")))
}
if key == "discord" && c == "webhook" && len(strings.TrimSpace(v.(string))) > 0 {
providers = append(providers, provider.NewDiscord(viper.GetString("providers.discord.webhook")))
}
}
}
Expand Down

0 comments on commit 9bf19d6

Please sign in to comment.