Use create over update (#97818)

This commit is contained in:
Kerry Gallagher 2021-04-22 12:24:35 +01:00 committed by GitHub
parent fbc6eb733d
commit c8bd4b0bf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -160,12 +160,15 @@ export class InfraSources {
);
const updatedSourceConfiguration = convertSavedObjectToSavedSourceConfiguration(
await savedObjectsClient.update(
// update() will perform a deep merge. We use create() with overwrite: true instead. mergeSourceConfiguration()
// ensures the correct and intended merging of properties.
await savedObjectsClient.create(
infraSourceConfigurationSavedObjectName,
sourceId,
pickSavedSourceConfiguration(updatedSourceConfigurationAttributes) as any,
{
id: sourceId,
version,
overwrite: true,
}
)
);