Alerting: Return merged extra configurations in the API (#109636)
This commit is contained in:
@@ -1782,8 +1782,8 @@ func (m *mockAlertmanager) SaveAndApplyExtraConfiguration(ctx context.Context, o
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (m *mockAlertmanager) GetAlertmanagerConfiguration(ctx context.Context, org int64, withAutogen bool) (apimodels.GettableUserConfig, error) {
|
||||
args := m.Called(ctx, org, withAutogen)
|
||||
func (m *mockAlertmanager) GetAlertmanagerConfiguration(ctx context.Context, org int64, withAutogen bool, withMergedExtraConfig bool) (apimodels.GettableUserConfig, error) {
|
||||
args := m.Called(ctx, org, withAutogen, withMergedExtraConfig)
|
||||
return args.Get(0).(apimodels.GettableUserConfig), args.Error(1)
|
||||
}
|
||||
|
||||
@@ -1912,7 +1912,7 @@ func TestRouteConvertPrometheusGetAlertmanagerConfig(t *testing.T) {
|
||||
|
||||
t.Run("without config identifier header should use default identifier", func(t *testing.T) {
|
||||
mockAM := &mockAlertmanager{}
|
||||
mockAM.On("GetAlertmanagerConfiguration", mock.Anything, orgID, false).Return(apimodels.GettableUserConfig{
|
||||
mockAM.On("GetAlertmanagerConfiguration", mock.Anything, orgID, false, false).Return(apimodels.GettableUserConfig{
|
||||
ExtraConfigs: []apimodels.ExtraConfiguration{
|
||||
{
|
||||
Identifier: defaultConfigIdentifier,
|
||||
@@ -1935,7 +1935,7 @@ receivers:
|
||||
|
||||
t.Run("with empty config identifier header should use default identifier", func(t *testing.T) {
|
||||
mockAM := &mockAlertmanager{}
|
||||
mockAM.On("GetAlertmanagerConfiguration", mock.Anything, orgID, false).Return(apimodels.GettableUserConfig{
|
||||
mockAM.On("GetAlertmanagerConfiguration", mock.Anything, orgID, false, false).Return(apimodels.GettableUserConfig{
|
||||
ExtraConfigs: []apimodels.ExtraConfiguration{
|
||||
{
|
||||
Identifier: defaultConfigIdentifier,
|
||||
@@ -1983,7 +1983,7 @@ receivers:
|
||||
},
|
||||
}
|
||||
|
||||
mockAM.On("GetAlertmanagerConfiguration", mock.Anything, int64(1), false).Return(expectedConfig, nil).Once()
|
||||
mockAM.On("GetAlertmanagerConfiguration", mock.Anything, int64(1), false, false).Return(expectedConfig, nil).Once()
|
||||
|
||||
rc := createRequestCtx()
|
||||
rc.Req.Header.Set(configIdentifierHeader, identifier)
|
||||
@@ -2037,7 +2037,7 @@ receivers:
|
||||
},
|
||||
}
|
||||
|
||||
mockAM.On("GetAlertmanagerConfiguration", mock.Anything, orgID, false).Return(expectedConfig, nil).Once()
|
||||
mockAM.On("GetAlertmanagerConfiguration", mock.Anything, orgID, false, false).Return(expectedConfig, nil).Once()
|
||||
|
||||
rc := createRequestCtx()
|
||||
rc.Req.Header.Set(configIdentifierHeader, identifier)
|
||||
@@ -2052,7 +2052,7 @@ receivers:
|
||||
ft := featuremgmt.WithFeatures(featuremgmt.FlagAlertingImportAlertmanagerAPI)
|
||||
srv, _, _ := createConvertPrometheusSrv(t, withAlertmanager(mockAM), withFeatureToggles(ft))
|
||||
|
||||
mockAM.On("GetAlertmanagerConfiguration", mock.Anything, orgID, false).Return(apimodels.GettableUserConfig{}, errors.New("config error")).Once()
|
||||
mockAM.On("GetAlertmanagerConfiguration", mock.Anything, orgID, false, false).Return(apimodels.GettableUserConfig{}, errors.New("config error")).Once()
|
||||
|
||||
rc := createRequestCtx()
|
||||
rc.Req.Header.Set(configIdentifierHeader, identifier)
|
||||
|
||||
Reference in New Issue
Block a user