From 85376a5482f7748c9fb262dfd6ac7aad1f1fa0d4 Mon Sep 17 00:00:00 2001 From: utsav14nov Date: Tue, 8 Oct 2024 10:53:19 +0530 Subject: [PATCH] fix: backward compatibility for notifiers in job --- cli/job.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cli/job.go b/cli/job.go index 6b9bb351..58b43f8c 100644 --- a/cli/job.go +++ b/cli/job.go @@ -71,18 +71,19 @@ func runJobCmd() *cobra.Command { logger := log.NewCtxLogger(config.LogLevel, []string{config.AuditLogTraceIDHeaderKey}) crypto := crypto.NewAES(config.EncryptionSecretKeyKey) validator := validator.New() - var notifierMap map[string]interface{} - errr := json.Unmarshal([]byte(config.Notifiers), ¬ifierMap) - if errr != nil { - return fmt.Errorf("failed to parse notifier config: %w", errr) - } - var notifierConfigMap map[string]notifiers.Config - err = mapstructure.Decode(notifierMap, ¬ifierConfigMap) - if err != nil { - return fmt.Errorf("failed to parse notifier config: %w", err) - } + notifierConfig := []notifiers.Config{} if config.Notifiers != "" { + var notifierMap map[string]interface{} + errr := json.Unmarshal([]byte(config.Notifiers), ¬ifierMap) + if errr != nil { + return fmt.Errorf("failed to parse notifier config: %w", errr) + } + var notifierConfigMap map[string]notifiers.Config + err = mapstructure.Decode(notifierMap, ¬ifierConfigMap) + if err != nil { + return fmt.Errorf("failed to parse notifier config: %w", err) + } for _, val := range notifierConfigMap { notifierConfig = append(notifierConfig, val) }