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

filter out data source object when export #6124

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export async function exportSavedObjectsToStream({
exportedObjects = sortObjects(rootObjects);
}

exportedObjects = exportedObjects.filter((obj) => obj.type !== 'data-source');
Copy link
Member

@ruanyl ruanyl Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of filtering the final results, shall we filter the types passed in before sending it to savedObjectsClient.find? Or maybe even throw error if export data-source is not allowed, like in fetchObjectsToExport we do validations for the export parameters.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, I assume we are using the saved object find API and we can specify the object types there

Copy link
Contributor Author

@yujin-emma yujin-emma Mar 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, + 1 on using saved object find API and specifying the types; as for

Or maybe even throw error if export data-source is not allowed
partially agree, error can be some interruption on UX, not quite sure about the user experience, but we can have warning first, more discussion is here

// redact attributes that should not be exported
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please add tests for this change as well?

const redactedObjects = exportedObjects.map<SavedObject<unknown>>(
({ namespaces, ...object }) => object
Expand Down
Loading