elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.7k stars 8.24k forks source link

settle on using config schema vs joi for action validation #40019

Closed bmcconaghy closed 3 years ago

bmcconaghy commented 5 years ago

Convert existing uses of joi over to config-schema

elasticmachine commented 5 years ago

Pinging @elastic/kibana-stack-services

pmuellr commented 5 years ago

My only concern from switching from joi to kbn-config-schema, is how well exposed the latter is to customers vs joi. If it's not considered "public api", then how would customers create an action with it?

pmuellr commented 5 years ago

We're using both joi and kbn-config-schema currently in actions, so you can see both in action here:

joi for slack:

https://github.com/elastic/kibana/blob/3d2cf695654dc8f3ec87d4e3444dfe7e02fb859f/x-pack/legacy/plugins/actions/server/builtin_action_types/slack.ts#L12-L22

kbn-config-schema for email:

https://github.com/elastic/kibana/blob/3d2cf695654dc8f3ec87d4e3444dfe7e02fb859f/x-pack/legacy/plugins/actions/server/builtin_action_types/email.ts#L16-L42

email has a lot more "config" than slack, so it's schema is neccessarily larger ...

pmuellr commented 5 years ago

It appears that kbn-action-schema is used for Kibana new platform plugins, so ... should be fine.

from @azasypkin:

At the moment when someone wants to create a NP plugin they don't have other choice other than using kbn/config-schema if they want to 1. define plugin config (the one that's read from yaml config), 2. define NP routes with schemas for query/payload/parameters. So I guess it's a part of "core public API".

pmuellr commented 5 years ago

Actions have been converted to schema-config via PR https://github.com/elastic/kibana/pull/40694

Need to convert alerts in a similar way.

pmuellr commented 3 years ago

we settled on config-schema