diff --git a/alert/processAlert.go b/alert/processAlert.go index ad17fda..552a557 100644 --- a/alert/processAlert.go +++ b/alert/processAlert.go @@ -59,7 +59,7 @@ func ProcessAlert(a types.Alert) { logr.Info("processing enrichment : ", v.EnrichmentName) if f, ok := (*enrichmentMap)[v.EnrichmentName]; ok { - resMap[v.EnrichmentName], err = f(a, v) + resMap[v.StepName], err = f(a, v) if err != nil { fmt.Println(err) } diff --git a/config/config.go b/config/config.go index 5b5c966..de53a9d 100644 --- a/config/config.go +++ b/config/config.go @@ -41,13 +41,13 @@ func ValidateAndLoad(b []byte) (*types.AlertManagerConfig, error) { for _, v := range amConfig.AlertPipelines { for _, e := range v.Enrichments { if len(e.StepName) <= 0 { - return amConfig, fmt.Errorf("unable to load config, please check format") + return &types.AlertManagerConfig{}, fmt.Errorf("unable to load config, please check format") } } for _, v := range v.Actions { if len(v.StepName) <= 0 { - return amConfig, fmt.Errorf("unable to load config, please check format") + return &types.AlertManagerConfig{}, fmt.Errorf("unable to load config, please check format") } } // diff --git a/config/config_test.go b/config/config_test.go index 1273e5d..752f27a 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -92,7 +92,7 @@ func TestValidateAndLoad(t *testing.T) { b: []byte(`randomKey: randonValue randomKey2: randomValue2`), }, - want: types.AlertManagerConfig{}, + want: types.AlertManagerConfig{}, // doesnt matter here wantErr: true, }, { @@ -100,8 +100,8 @@ func TestValidateAndLoad(t *testing.T) { args: args{ b: []byte(badAlertConfigNoStepName), }, - want: types.DefaultAlertManagerConfig(), - wantErr: false, + want: types.AlertManagerConfig{}, // doesnt matter here + wantErr: true, }, } @@ -109,8 +109,7 @@ func TestValidateAndLoad(t *testing.T) { t.Run(tt.name, func(t *testing.T) { got, err := ValidateAndLoad(tt.args.b) if (err != nil) != tt.wantErr { - t.Errorf("ValidateAndLoad() error = %v, wantErr %v", err, tt.wantErr) - return + t.Fatalf("ValidateAndLoad() error = %v, wantErr %v", err, tt.wantErr) } // dereference the pointer for got to make deepequal happy