Skip to content

Commit

Permalink
fix: backward compatibility for notifiers in job (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
utsav14nov authored Oct 8, 2024
1 parent a048f7f commit 74a1ba6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions cli/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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), &notifierMap)
if errr != nil {
return fmt.Errorf("failed to parse notifier config: %w", errr)
}
var notifierConfigMap map[string]notifiers.Config
err = mapstructure.Decode(notifierMap, &notifierConfigMap)
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), &notifierMap)
if errr != nil {
return fmt.Errorf("failed to parse notifier config: %w", errr)
}
var notifierConfigMap map[string]notifiers.Config
err = mapstructure.Decode(notifierMap, &notifierConfigMap)
if err != nil {
return fmt.Errorf("failed to parse notifier config: %w", err)
}
for _, val := range notifierConfigMap {
notifierConfig = append(notifierConfig, val)
}
Expand Down

0 comments on commit 74a1ba6

Please sign in to comment.