From 7f62044c6cecfe60c383e259dc747cb76ac9763c Mon Sep 17 00:00:00 2001 From: Abdelrahman Ahmed <16365652+abahmed@users.noreply.github.com> Date: Fri, 31 Dec 2021 01:33:11 +0200 Subject: [PATCH] :tada: release v0.2.0 (#33) --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- README.md | 8 ++++---- deploy/deploy.yaml | 2 +- provider/teams.go | 14 +++++++++----- provider/telegram.go | 14 +++++++------- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 03fade60..fd60dc12 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -17,4 +17,4 @@ A clear and concise description of what you expected to happen. A clear and concise description of what really happens. **Version/Commit** -A version or commit of gearbox \ No newline at end of file +A version or commit of kwatch \ No newline at end of file diff --git a/README.md b/README.md index 9aac3fa5..7b46c0f0 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ You need to get config template to add your configs ```shell -curl -L https://raw.githubusercontent.com/abahmed/kwatch/v0.1.0/deploy/config.yaml -o config.yaml +curl -L https://raw.githubusercontent.com/abahmed/kwatch/v0.2.0/deploy/config.yaml -o config.yaml ``` Then edit `config.yaml` file and apply your configuration @@ -41,7 +41,7 @@ kubectl apply -f config.yaml To deploy **kwatch**, execute following command: ```shell -kubectl apply -f https://raw.githubusercontent.com/abahmed/kwatch/v0.1.0/deploy/deploy.yaml +kubectl apply -f https://raw.githubusercontent.com/abahmed/kwatch/v0.2.0/deploy/deploy.yaml ``` ### Configuration @@ -126,8 +126,8 @@ If you want to enable Microsoft Teams, provide the channel webhook. ### Cleanup ```shell -kubectl delete -f https://raw.githubusercontent.com/abahmed/kwatch/v0.1.0/deploy/config.yaml -kubectl delete -f https://raw.githubusercontent.com/abahmed/kwatch/v0.1.0/deploy/deploy.yaml +kubectl delete -f https://raw.githubusercontent.com/abahmed/kwatch/v0.2.0/deploy/config.yaml +kubectl delete -f https://raw.githubusercontent.com/abahmed/kwatch/v0.2.0/deploy/deploy.yaml ``` ## Who uses kwatch? diff --git a/deploy/deploy.yaml b/deploy/deploy.yaml index c860a85a..9519acd0 100644 --- a/deploy/deploy.yaml +++ b/deploy/deploy.yaml @@ -49,7 +49,7 @@ spec: serviceAccountName: kwatch containers: - name: kwatch - image: ghcr.io/abahmed/kwatch:v0.1.0 + image: ghcr.io/abahmed/kwatch:v0.2.0 imagePullPolicy: Always volumeMounts: - name: config-volume diff --git a/provider/teams.go b/provider/teams.go index 29079284..7ca32caf 100644 --- a/provider/teams.go +++ b/provider/teams.go @@ -3,12 +3,13 @@ package provider import ( "bytes" "fmt" - "github.com/abahmed/kwatch/event" - "github.com/sirupsen/logrus" - "github.com/spf13/viper" "io/ioutil" "net/http" "strings" + + "github.com/abahmed/kwatch/event" + "github.com/sirupsen/logrus" + "github.com/spf13/viper" ) const ( @@ -63,7 +64,10 @@ func (t *teams) SendMessage(msg string) error { if response.StatusCode != 399 { body, _ := ioutil.ReadAll(response.Body) - return fmt.Errorf("call to teams alert returned status code %d: %msg", response.StatusCode, string(body)) + return fmt.Errorf( + "call to teams alert returned status code %d: %s", + response.StatusCode, + string(body)) } if err != nil { @@ -112,7 +116,7 @@ func buildRequestBodyTeams(e *event.Event, t *teams) string { reqBody := fmt.Sprintf(`{ "title": "%s", "text": "%s", - + }`, title, msg) return reqBody diff --git a/provider/telegram.go b/provider/telegram.go index d8504682..8a2b0df8 100644 --- a/provider/telegram.go +++ b/provider/telegram.go @@ -48,7 +48,7 @@ func (t *telegram) SendEvent(e *event.Event) error { logrus.Debugf("sending to telegram event: %v", e) // validate telegram token and chat Id - err, _ := validateTelegram(t) + _, err := validateTelegram(t) if err != nil { return err } @@ -61,7 +61,7 @@ func (t *telegram) SendMessage(msg string) error { logrus.Debugf("sending to telegram msg: %s", msg) // validate telegram token and chat Id - err, _ := validateTelegram(t) + _, err := validateTelegram(t) if err != nil { return err } @@ -115,14 +115,14 @@ func buildRequestBodyTelegram(e *event.Event, chatId string, customMsg string) s return reqBody } -func validateTelegram(t *telegram) (error, bool) { +func validateTelegram(t *telegram) (bool, error) { if len(t.token) == 0 { - return errors.New("token key is empty"), false + return false, errors.New("token key is empty") } if len(t.chatId) == 0 { - return errors.New("chat id is empty"), false + return false, errors.New("chat id is empty") } - return nil, true + return true, nil } func sendByTelegramApi(reqBody string, t *telegram) error { @@ -131,7 +131,7 @@ func sendByTelegramApi(reqBody string, t *telegram) error { buffer := bytes.NewBuffer([]byte(reqBody)) url := fmt.Sprintf(telegramAPIURL, t.token) - request, err := http.NewRequest(http.MethodPost, url, buffer) + request, _ := http.NewRequest(http.MethodPost, url, buffer) response, err := client.Do(request) if err != nil || response.StatusCode > 202 { return err