Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic enhancements for import logging #196056

Merged
merged 11 commits into from
Nov 1, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,16 @@ export class SavedObjectsImporter implements ISavedObjectsImporter {
compatibilityMode,
managed,
}: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse> {
this.#log.debug('Starting the import process');
// Get the allowed types for import from the typeRegistry
const allowedTypes = this.#typeRegistry
.getImportableAndExportableTypes()
.map((type) => type.name);
// Log the allowed types, similar to how the exporter logs types
this.#log.debug(`Initiating import process.`);
this.#log.debug(`Allowed types: [${allowedTypes.join(', ')}]`);
kyracho marked this conversation as resolved.
Show resolved Hide resolved
this.#log.info(`Import size limit: ${this.#importSizeLimit} saved objects.`);
const overwriteStatus = overwrite ? 'enabled' : 'disabled';
this.#log.info(`Automatic overwrite is ${overwriteStatus} for the current import operation.`);
kyracho marked this conversation as resolved.
Show resolved Hide resolved
return importSavedObjectsFromStream({
readStream,
createNewCopies,
Expand All @@ -75,7 +84,19 @@ export class SavedObjectsImporter implements ISavedObjectsImporter {
typeRegistry: this.#typeRegistry,
importHooks: this.#importHooks,
managed,
});
})
.then((response: SavedObjectsImportResponse) => {
this.#log.info(`🌸 Successfully imported ${response.successCount} saved objects.`);
kyracho marked this conversation as resolved.
Show resolved Hide resolved
return response;
})
.catch((error) => {
this.#log.error('Failed to import saved objects');
kyracho marked this conversation as resolved.
Show resolved Hide resolved
const errors = Array.isArray(error) ? error : [error];
errors.forEach((err) => {
this.#log.error(`Import error: ${err.message}`);
});
throw error;
});
}

public resolveImportErrors({
Expand Down