-
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
Migrate SO management routes to new plugin #59734
Migrate SO management routes to new plugin #59734
Conversation
Pinging @elastic/kibana-platform (Team:Platform) |
…gement-server-side
retest |
export const registerScrollForExportRoute = (router: IRouter) => { | ||
router.post( | ||
{ | ||
path: '/api/kibana/management/saved_objects/scroll/export', | ||
validate: { | ||
body: schema.object({ | ||
typesToInclude: schema.arrayOf(schema.string()), | ||
}), | ||
}, | ||
}, |
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.
So, this route seems unused. At least I didn't find any usage in our code. Was not sure if I should remove it though.
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.
another good candidate for the platform telemetry project🤔
return { | ||
management: managementService, | ||
}; |
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.
I'm exposing that from the start contract even if currently no plugin uses it.
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.
I'd rather keep it private until requested to keep the API surface smaller.
export const findAll = async ( | ||
client: SavedObjectsClientContract, | ||
findOptions: SavedObjectsFindOptions | ||
): Promise<SavedObject[]> => { | ||
return recursiveFind(client, findOptions, 1, []); | ||
}; | ||
|
||
const recursiveFind = async ( |
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.
I added test for them, but appart from that the so_management/server/lib
utilities were almost migrated to TS without any changes
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under |
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.
the plugin name is savedObjectsManagement
. Should I rename the plugin folder from so_management
to saved_objects_management
?
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.
I would prefer saved_objects_management
despite verbosity as more descriptive.
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.
Yea, that's probably the right call, as the folder should probably match the plugin name. Gonna rename
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.
Tested and overall works great!
Plugin structure looks good too.
Noticed that changing the types drop down, causes a double fetch of Request URL: http://localhost:5620/api/kibana/management/saved_objects/scroll/counts
(one of them seems to fetch only the selected counts, and I don't see why you need to)
@@ -21,11 +21,7 @@ export function injectVars(server) { | |||
const serverConfig = server.config(); | |||
|
|||
// Get types that are import and exportable, by default yes unless isImportableAndExportable is set to false |
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.
Is this comment still relevant?
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.
Probably not (and it was wrong, as the default value is actually false
...). removed. The whole importAndExportableTypes
injection is going to be removed in next stage anyway
path: '/api/kibana/management/saved_objects/_find', | ||
validate: { | ||
query: schema.object({ | ||
perPage: schema.number({ min: 0, defaultValue: 20 }), |
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.
I think this should be coming from savedObjects:perPage
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.
The savedObjects:perPage
value is actually accessed and sent by the client.
kibana/src/legacy/core_plugins/kibana/public/management/sections/objects/_objects.js
Line 60 in 56571ba
perPageConfig={config.get('savedObjects:perPage')} |
The route's joi schema was not, and I did a rather straight forward migration to config-schema. As this is an internal API and to avoid adding another dependency to the route definition, I'm leaning to keep it that way, unless you want me to perform the change?
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.
We can do it later when moving savedObjects:perPage
registration to saved_objects_management plugin.
Thanks. will take a look when migration the client-side code in the follow-up PR. |
ack: will review tomorrow |
…gement-server-side
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.
some nits, LGTM
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under |
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.
I would prefer saved_objects_management
despite verbosity as more descriptive.
.map(so => injectMetaAttributes(so, managementService)) | ||
.map(obj => { | ||
const result = { ...obj, attributes: {} as Record<string, any> }; | ||
for (const field of includedFields || []) { |
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.
unnecessary || []
? you have [] as default value
dashboard: 1, | ||
visualization: 1, | ||
'index-pattern': 0, | ||
search: 0, |
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.
could you add an explicit test that it sets0
for all the types listed in typesToInclude
?
export const registerScrollForExportRoute = (router: IRouter) => { | ||
router.post( | ||
{ | ||
path: '/api/kibana/management/saved_objects/scroll/export', | ||
validate: { | ||
body: schema.object({ | ||
typesToInclude: schema.arrayOf(schema.string()), | ||
}), | ||
}, | ||
}, |
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.
another good candidate for the platform telemetry project🤔
path: '/api/kibana/management/saved_objects/_find', | ||
validate: { | ||
query: schema.object({ | ||
perPage: schema.number({ min: 0, defaultValue: 20 }), |
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.
We can do it later when moving savedObjects:perPage
registration to saved_objects_management plugin.
return { | ||
management: managementService, | ||
}; |
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.
I'd rather keep it private until requested to keep the API surface smaller.
@elastic/kibana-app-arch @lizozom Could we get another look on this one? |
…gement-server-side
…gement-server-side
…gement-server-side
…gement-server-side
…gement-server-side
…gement-server-side
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* unexpose SavedObjectsManagement from legacy server * migrate saved object management routes to new plugin * fix endpoint methods * adapt code due to rebase * extract types * improve findAll params * adapt existing api integration tests and migrate to TS * update generated doc * add API integration tests for /scroll/count * add unit tests for plugin and routes * add injectMetaAttributes tests * extract relation type * add find_relationships tests * add find_all tests * do not complete migrator$ to avoid unhandled promise rejection * fix data for search endpoint integration tests * remove falsy comment * rename plugin folder to match plugin id * address review comments * update CODEOWNERS
* unexpose SavedObjectsManagement from legacy server * migrate saved object management routes to new plugin * fix endpoint methods * adapt code due to rebase * extract types * improve findAll params * adapt existing api integration tests and migrate to TS * update generated doc * add API integration tests for /scroll/count * add unit tests for plugin and routes * add injectMetaAttributes tests * extract relation type * add find_relationships tests * add find_all tests * do not complete migrator$ to avoid unhandled promise rejection * fix data for search endpoint integration tests * remove falsy comment * rename plugin folder to match plugin id * address review comments * update CODEOWNERS
Summary
Part of #50308
Migrate the savedObject management routes to a new
savedObjectsManagement
pluginChecklist