Populate missing UID of provisioned data source only for new records (#42999)

* defer updating empty UID to insert command
* change logging to use the command
This commit is contained in:
Yuriy Tseretyan
2021-12-13 14:14:39 -05:00
committed by GitHub
parent b63595b47f
commit 35b0067650
5 changed files with 70 additions and 38 deletions

View File

@@ -51,14 +51,14 @@ func (dc *DatasourceProvisioner) apply(ctx context.Context, cfg *configs) error
}
if errors.Is(err, models.ErrDataSourceNotFound) {
dc.log.Info("inserting datasource from configuration ", "name", ds.Name, "uid", ds.UID)
insertCmd := createInsertCommand(ds)
dc.log.Info("inserting datasource from configuration ", "name", insertCmd.Name, "uid", insertCmd.Uid)
if err := bus.DispatchCtx(ctx, insertCmd); err != nil {
return err
}
} else {
dc.log.Debug("updating datasource from configuration", "name", ds.Name, "uid", ds.UID)
updateCmd := createUpdateCommand(ds, cmd.Result.Id)
dc.log.Debug("updating datasource from configuration", "name", updateCmd.Name, "uid", updateCmd.Uid)
if err := bus.DispatchCtx(ctx, updateCmd); err != nil {
return err
}