diff --git a/helm/charts/release-watcher/Chart.yaml b/helm/charts/release-watcher/Chart.yaml index e9c2ae3..1e1cabc 100644 --- a/helm/charts/release-watcher/Chart.yaml +++ b/helm/charts/release-watcher/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: release-watcher description: A Helm chart to install Release Watcher type: application -version: 0.0.8 -appVersion: "v0.0.8" +version: 0.0.9 +appVersion: "v0.0.9" home: https://github.com/zvlb/release-watcher sources: diff --git a/helm/charts/release-watcher/templates/configmap.yaml b/helm/charts/release-watcher/templates/configmap.yaml index 3a23bbc..b5981e0 100644 --- a/helm/charts/release-watcher/templates/configmap.yaml +++ b/helm/charts/release-watcher/templates/configmap.yaml @@ -33,3 +33,5 @@ data: hook: "{{ .hook }}" {{- end }} {{- end }} + params: + sendReleaseDescription: {{ .Values.params.sendReleaseDescription }} diff --git a/helm/charts/release-watcher/values.yaml b/helm/charts/release-watcher/values.yaml index c1ae3a3..3340049 100644 --- a/helm/charts/release-watcher/values.yaml +++ b/helm/charts/release-watcher/values.yaml @@ -81,4 +81,8 @@ releases: recievers: telegram: [] # - chatID: "-0000000" - # token: \ No newline at end of file + # token: + slack: [] + +params: + sendReleaseDescription: false \ No newline at end of file diff --git a/helm/index.yaml b/helm/index.yaml index 3af366a..1bd29d0 100644 --- a/helm/index.yaml +++ b/helm/index.yaml @@ -1,9 +1,22 @@ apiVersion: v1 entries: release-watcher: + - apiVersion: v2 + appVersion: v0.0.9 + created: "2024-05-29T11:36:43.641089+03:00" + description: A Helm chart to install Release Watcher + digest: 30cbfe7ed31b18faf154800129f845b9f48ccfae8c8825c2ceab2b5124dbff83 + home: https://github.com/zvlb/release-watcher + name: release-watcher + sources: + - https://github.com/zvlb/release-watcher + type: application + urls: + - https://zvlb.github.io/release-watcher/helm/packages/release-watcher-0.0.9.tgz + version: 0.0.9 - apiVersion: v2 appVersion: v0.0.8 - created: "2024-01-19T12:48:55.435359+02:00" + created: "2024-05-29T11:36:43.640882+03:00" description: A Helm chart to install Release Watcher digest: 3fdb533f051824c747a7dc2f95fdcb4aa68ab6a5c22878af715af7c28e00922e home: https://github.com/zvlb/release-watcher @@ -16,7 +29,7 @@ entries: version: 0.0.8 - apiVersion: v2 appVersion: v0.0.6 - created: "2024-01-19T12:48:55.435161+02:00" + created: "2024-05-29T11:36:43.640666+03:00" description: A Helm chart to install Release Watcher digest: 042630c6521f340a6ac5ef56444f254f0e845a5214172647ec5f099182e0f93e home: https://github.com/zvlb/release-watcher @@ -29,7 +42,7 @@ entries: version: 0.0.7 - apiVersion: v2 appVersion: v0.0.6 - created: "2024-01-19T12:48:55.434836+02:00" + created: "2024-05-29T11:36:43.640456+03:00" description: A Helm chart to install Release Watcher digest: a7c022532fdd40c9ebae0154df34eedd94886c44751be71d8a1eb606ce4a2913 home: https://github.com/zvlb/release-watcher @@ -42,7 +55,7 @@ entries: version: 0.0.6 - apiVersion: v2 appVersion: v0.0.5 - created: "2024-01-19T12:48:55.434342+02:00" + created: "2024-05-29T11:36:43.64024+03:00" description: A Helm chart to install Release Watcher digest: 3e8a838a93411cf38f875d3e28ce8655f0257144a469cbd8262ec517ef369401 home: https://github.com/zvlb/release-watcher @@ -55,7 +68,7 @@ entries: version: 0.0.5 - apiVersion: v2 appVersion: v0.0.4 - created: "2024-01-19T12:48:55.434+02:00" + created: "2024-05-29T11:36:43.640046+03:00" description: A Helm chart to install Release Watcher digest: 1e21c2888632e88db613e8eed2250b401d3856d9c4379a4ec5f88fcf6b313d68 home: https://github.com/zvlb/release-watcher @@ -68,7 +81,7 @@ entries: version: 0.0.4 - apiVersion: v2 appVersion: v0.0.3 - created: "2024-01-19T12:48:55.433614+02:00" + created: "2024-05-29T11:36:43.639827+03:00" description: A Helm chart to install Release Watcher digest: aacda75b2ded0f734c3d20eea3fd94d2783f98337697273a7a96801705e006b4 home: https://github.com/zvlb/release-watcher @@ -81,7 +94,7 @@ entries: version: 0.0.2 - apiVersion: v2 appVersion: v0.0.1 - created: "2024-01-19T12:48:55.433018+02:00" + created: "2024-05-29T11:36:43.639584+03:00" description: A Helm chart to install Release Watcher digest: 3d316c53a0a466847d6f336d18241c2f2a1b6edfcd10c6686d53079ea2368005 home: https://github.com/zvlb/release-watcher @@ -92,4 +105,4 @@ entries: urls: - https://zvlb.github.io/release-watcher/helm/packages/release-watcher-0.0.1.tgz version: 0.0.1 -generated: "2024-01-19T12:48:55.432305+02:00" +generated: "2024-05-29T11:36:43.638936+03:00" diff --git a/helm/packages/release-watcher-0.0.9.tgz b/helm/packages/release-watcher-0.0.9.tgz new file mode 100644 index 0000000..030ac16 Binary files /dev/null and b/helm/packages/release-watcher-0.0.9.tgz differ diff --git a/internal/config/config.go b/internal/config/config.go index 8d7f2e7..b01c6b9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -9,6 +9,7 @@ import ( type Config struct { Releases Releases `yaml:"releases"` Recievers Recievers `yaml:"recievers"` + Params Params `yaml:params` } type Releases struct { @@ -30,6 +31,10 @@ type TelegramReciever struct { Token string `yaml:"token"` } +type Params struct { + SendReleaseDescription bool `yaml:"sendReleaseDescription"` +} + func GetConfiguration(path string) (Config, error) { var config Config diff --git a/internal/recievers/slack/slack.go b/internal/recievers/slack/slack.go index b2278b8..0b63469 100644 --- a/internal/recievers/slack/slack.go +++ b/internal/recievers/slack/slack.go @@ -7,6 +7,7 @@ import ( "fmt" "net/http" + "github.com/zvlb/release-watcher/internal/config" "github.com/zvlb/release-watcher/internal/recievers" ) @@ -18,12 +19,14 @@ var ( type SlackReciever struct { ChannelName string `yaml:"channelName"` Hook string `yaml:"hook"` + Config config.Config } -func New(channelname, hook string) recievers.Reciever { +func New(channelname, hook string, config config.Config) recievers.Reciever { return &SlackReciever{ ChannelName: channelname, Hook: hook, + Config: config, } } @@ -34,7 +37,12 @@ func (sr *SlackReciever) GetName() string { func (sr *SlackReciever) SendData(name, release, description, link string) error { url := fmt.Sprintf("%v", sr.Hook) //?????? - text := fmt.Sprintf("%v. Release: %v\n%v\n\n%v", name, release, description, link) + var text string + if sr.Config.Params.SendReleaseDescription { + text = fmt.Sprintf("%v. Release: %v\n%v\n\n%v", name, release, description, link) + } else { + text = fmt.Sprintf("%v. Release: %v\n%v", name, release, link) + } body, err := json.Marshal(map[string]string{ "text": text, diff --git a/internal/recievers/telegram/telegram.go b/internal/recievers/telegram/telegram.go index 0c2b973..592b811 100644 --- a/internal/recievers/telegram/telegram.go +++ b/internal/recievers/telegram/telegram.go @@ -6,6 +6,7 @@ import ( "fmt" "net/http" + "github.com/zvlb/release-watcher/internal/config" "github.com/zvlb/release-watcher/internal/recievers" ) @@ -16,12 +17,14 @@ var ( type TelegramReciever struct { Token string `yaml:"token"` ChatID string `yaml:"chatID"` + Config config.Config } -func New(token, chatID string) recievers.Reciever { +func New(token, chatID string, config config.Config) recievers.Reciever { return &TelegramReciever{ Token: token, ChatID: chatID, + Config: config, } } @@ -32,7 +35,12 @@ func (tr *TelegramReciever) GetName() string { func (tr *TelegramReciever) SendData(name, release, description, link string) error { url := fmt.Sprintf("%v%v/%v", telegramAPI, tr.Token, "sendMessage") - text := fmt.Sprintf("%v. Release: %v\n%v\n\n%v", name, release, description, link) + var text string + if tr.Config.Params.SendReleaseDescription { + text = fmt.Sprintf("%v. Release: %v\n%v\n\n%v", name, release, description, link) + } else { + text = fmt.Sprintf("%v. Release: %v\n%v", name, release, link) + } body, err := json.Marshal(map[string]string{ "chat_id": tr.ChatID, diff --git a/main.go b/main.go index b8391b9..ccd5910 100644 --- a/main.go +++ b/main.go @@ -70,12 +70,12 @@ func generateRecievers(cfg config.Config) []recievers.Reciever { // Get telegram Recievers for _, t := range cfg.Recievers.Telegram { - r := telegram.New(t.Token, t.ChatID) + r := telegram.New(t.Token, t.ChatID, cfg) recievers = append(recievers, r) } // Get slack Recievers for _, t := range cfg.Recievers.Slack { - r := slack.New(t.ChannelName, t.Hook) + r := slack.New(t.ChannelName, t.Hook, cfg) recievers = append(recievers, r) } return recievers