Glue: Correlations minor APIs behavior improvements (#56078)
* add correlation config type, CorrelationConfig validator & default values * make config required when creating correlations * make targetUID optional, add validation for createCommand & configType * fix tests * update remaining tests * fix lint error * Update pkg/services/correlations/models.go Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> * update docs Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
This commit is contained in:
co-authored by
Piotr Jamróz
parent
3381629d3d
commit
489b302c03
@@ -34,11 +34,13 @@ func (s CorrelationsService) createCorrelation(ctx context.Context, cmd CreateCo
|
||||
return ErrSourceDataSourceReadOnly
|
||||
}
|
||||
|
||||
if err = s.DataSourceService.GetDataSource(ctx, &datasources.GetDataSourceQuery{
|
||||
OrgId: cmd.OrgId,
|
||||
Uid: cmd.TargetUID,
|
||||
}); err != nil {
|
||||
return ErrTargetDataSourceDoesNotExists
|
||||
if cmd.TargetUID != nil {
|
||||
if err = s.DataSourceService.GetDataSource(ctx, &datasources.GetDataSourceQuery{
|
||||
OrgId: cmd.OrgId,
|
||||
Uid: *cmd.TargetUID,
|
||||
}); err != nil {
|
||||
return ErrTargetDataSourceDoesNotExists
|
||||
}
|
||||
}
|
||||
|
||||
_, err = session.Insert(correlation)
|
||||
@@ -206,7 +208,7 @@ func (s CorrelationsService) deleteCorrelationsBySourceUID(ctx context.Context,
|
||||
|
||||
func (s CorrelationsService) deleteCorrelationsByTargetUID(ctx context.Context, cmd DeleteCorrelationsByTargetUIDCommand) error {
|
||||
return s.SQLStore.WithDbSession(ctx, func(session *sqlstore.DBSession) error {
|
||||
_, err := session.Delete(&Correlation{TargetUID: cmd.TargetUID})
|
||||
_, err := session.Delete(&Correlation{TargetUID: &cmd.TargetUID})
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user