@@ -10,6 +10,7 @@ import {
1010 getCnpgClusterArchivingStatus ,
1111} from "@/lib/kube/types"
1212import { logger } from "@/lib/logger"
13+ import { sendNotification } from "@/lib/mattermost"
1314
1415const allContexts = [ "dev" , "prod" , "ovh-dev" , "ovh-prod" ]
1516
@@ -176,13 +177,19 @@ function checkCnpgCluster(
176177 const cacheKey = JSON . stringify ( status )
177178 const alertInCache = alertCache . has ( cacheKey )
178179
180+ const mattermostFields = Object . entries ( status ) . map ( ( [ key , value ] ) => {
181+ return { title : key , value : String ( value ) }
182+ } )
183+
179184 if ( statusOk && ! alertInCache ) {
180185 return
181186 } else if ( statusOk && alertInCache ) {
182187 logger . info ( status , "cnpgCluster alert resolved" )
188+ sendNotification ( statusOk , "cnpgCluster alert resolved" , mattermostFields )
183189 alertCache . delete ( cacheKey )
184190 } else if ( ! statusOk && ! alertInCache ) {
185191 logger . error ( status , "cnpgCluster alert" )
192+ sendNotification ( statusOk , "cnpgCluster alert" , mattermostFields )
186193 alertCache . set ( cacheKey , true )
187194 }
188195
0 commit comments