From 74a1ba6d3a95ff44de32b3b4ff68c068897d0d19 Mon Sep 17 00:00:00 2001 From: utsav14nov Date: Tue, 8 Oct 2024 12:13:50 +0530 Subject: [PATCH] fix: backward compatibility for notifiers in job (#181) --- cli/job.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cli/job.go b/cli/job.go index 6b9bb3515..58b43f8c1 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) }