-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Saved Objects] Adds managed to import options #155677
Changes from all commits
2359b68
b81f813
03fdfe8
1267270
e19f896
c52bb41
e7c0319
cbd4561
0669c42
4eeb530
f753e32
a396a9f
bb9b6cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,7 @@ export interface SavedObjectsImportFailure { | |
* If `overwrite` is specified, an attempt was made to overwrite an existing object. | ||
*/ | ||
overwrite?: boolean; | ||
managed?: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here, I don't see it as being a problem, but just so I understand, why do we need to surface the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a reference, that's all. |
||
error: | ||
| SavedObjectsImportConflictError | ||
| SavedObjectsImportAmbiguousConflictError | ||
|
@@ -125,6 +126,14 @@ export interface SavedObjectsImportSuccess { | |
* If `overwrite` is specified, this object overwrote an existing one (or will do so, in the case of a pending resolution). | ||
*/ | ||
overwrite?: boolean; | ||
/** | ||
* Flag indicating if a saved object is managed by Kibana (default=false) | ||
* | ||
* This can be leveraged by applications to e.g. prevent edits to a managed | ||
* saved object. Instead, users can be guided to create a copy first and | ||
* make their edits to the copy. | ||
*/ | ||
managed?: boolean; | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,10 @@ export interface ImportSavedObjectsOptions { | |
* different Kibana versions (e.g. generate legacy URL aliases for all imported objects that have to change IDs). | ||
*/ | ||
compatibilityMode?: boolean; | ||
/** | ||
* If provided, Kibana will apply the given option to the `managed` property. | ||
*/ | ||
managed?: boolean; | ||
} | ||
|
||
/** | ||
|
@@ -73,6 +77,7 @@ export async function importSavedObjectsFromStream({ | |
namespace, | ||
refresh, | ||
compatibilityMode, | ||
managed, | ||
}: ImportSavedObjectsOptions): Promise<SavedObjectsImportResponse> { | ||
let errorAccumulator: SavedObjectsImportFailure[] = []; | ||
const supportedTypes = typeRegistry.getImportableAndExportableTypes().map((type) => type.name); | ||
|
@@ -82,6 +87,7 @@ export async function importSavedObjectsFromStream({ | |
readStream, | ||
objectLimit, | ||
supportedTypes, | ||
managed, | ||
}); | ||
errorAccumulator = [...errorAccumulator, ...collectSavedObjectsResult.errors]; | ||
// Map of all IDs for objects that we are attempting to import, and any references that are not included in the read stream; | ||
|
@@ -154,12 +160,13 @@ export async function importSavedObjectsFromStream({ | |
namespace, | ||
refresh, | ||
compatibilityMode, | ||
managed, | ||
}; | ||
const createSavedObjectsResult = await createSavedObjects(createSavedObjectsParams); | ||
errorAccumulator = [...errorAccumulator, ...createSavedObjectsResult.errors]; | ||
|
||
const successResults = createSavedObjectsResult.createdObjects.map((createdObject) => { | ||
const { type, id, destinationId, originId } = createdObject; | ||
const { type, id, destinationId, originId, managed: createdObjectManaged } = createdObject; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const getTitle = typeRegistry.getType(type)?.management?.getTitle; | ||
const meta = { | ||
title: getTitle ? getTitle(createdObject) : createdObject.attributes.title, | ||
|
@@ -170,6 +177,7 @@ export async function importSavedObjectsFromStream({ | |
type, | ||
id, | ||
meta, | ||
managed: createdObjectManaged ?? managed, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: we're passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, it would. |
||
...(attemptedOverwrite && { overwrite: true }), | ||
...(destinationId && { destinationId }), | ||
...(destinationId && !originId && !createNewCopies && { createNewCopy: true }), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of surfacing this
managed
flag on our legacy url alias definition?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to set all objects created during
import
asmanaged
if the option is provided. Legacy alias get created if they need to and the repository will set the default for managed as false if it's not specified.In short: to bypass adding a default.