diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 155f1658..c12ef890 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -31,4 +31,5 @@ jobs: context: . push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} + build-args: RELEASE_VERSION=${{ steps.meta.outputs.version }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1a193604..602467bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM golang:alpine AS builder +ARG RELEASE_VERSION="nothing" LABEL maintainer="Abdelrahman Ahmed - providers: + alert: slack: webhook: pagerduty: diff --git a/go.mod b/go.mod index 16fe268e..85ed5a2e 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/abahmed/kwatch go 1.17 require ( + github.com/bwmarrin/discordgo v0.23.2 github.com/sirupsen/logrus v1.8.1 github.com/slack-go/slack v0.10.0 github.com/spf13/viper v1.9.0 @@ -12,7 +13,6 @@ require ( ) require ( - github.com/bwmarrin/discordgo v0.23.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect github.com/go-logr/logr v0.4.0 // indirect diff --git a/main.go b/main.go index 61f82198..158b8881 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "path/filepath" @@ -11,7 +12,7 @@ import ( ) func main() { - logrus.Infof(constant.WelcomeMsg) + logrus.Infof(fmt.Sprintf(constant.WelcomeMsg, constant.Version)) // initialize configuration configFile := os.Getenv("CONFIG_FILE") diff --git a/provider/discord.go b/provider/discord.go index b2db9cbd..ba55b6a2 100644 --- a/provider/discord.go +++ b/provider/discord.go @@ -90,13 +90,13 @@ func (s *discord) SendEvent(ev *event.Event) error { } // use custom title if it's provided, otherwise use default - title := viper.GetString("providers.discord.title") + title := viper.GetString("alert.discord.title") if len(title) == 0 { title = defaultTitle } // use custom text if it's provided, otherwise use default - text := viper.GetString("providers.discord.text") + text := viper.GetString("alert.discord.text") if len(text) == 0 { text = defaultText } diff --git a/provider/slack.go b/provider/slack.go index ba23c9bd..59aa4229 100644 --- a/provider/slack.go +++ b/provider/slack.go @@ -84,13 +84,13 @@ func (s *slack) SendEvent(ev *event.Event) error { } // use custom title if it's provided, otherwise use default - title := viper.GetString("providers.slack.title") + title := viper.GetString("alert.slack.title") if len(title) == 0 { title = defaultTitle } // use custom text if it's provided, otherwise use default - text := viper.GetString("providers.slack.text") + text := viper.GetString("alert.slack.text") if len(text) == 0 { text = defaultText } diff --git a/util/util.go b/util/util.go index c81e477d..9e6bdee6 100644 --- a/util/util.go +++ b/util/util.go @@ -92,19 +92,20 @@ func getPodEvents(c kubernetes.Interface, name, namespace string) (*v1.EventList }) } +// GetProviders returns slice of provider objects after parsing config func GetProviders() []provider.Provider { var providers []provider.Provider for key, value := range viper.Get("providers").(map[string]interface{}) { 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"))) + providers = append(providers, provider.NewSlack(viper.GetString("alert.slack.webhook"))) } if key == "pagerduty" && c == "integrationkey" && len(strings.TrimSpace(v.(string))) > 0 { - providers = append(providers, provider.NewPagerDuty(viper.GetString("providers.pagerduty.integrationKey"))) + providers = append(providers, provider.NewPagerDuty(viper.GetString("alert.pagerduty.integrationKey"))) } if key == "discord" && c == "webhook" && len(strings.TrimSpace(v.(string))) > 0 { - providers = append(providers, provider.NewDiscord(viper.GetString("providers.discord.webhook"))) + providers = append(providers, provider.NewDiscord(viper.GetString("alert.discord.webhook"))) } } }