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

Migrate from Joi to @kbn/config-schema in "home" and "features" plugins #100201

Merged
merged 9 commits into from
May 18, 2021

Conversation

mshustov
Copy link
Contributor

@mshustov mshustov commented May 17, 2021

Summary

Closes #61100
Unblocks #99899

Migrates joi usages to @kbn/config-schema in home and features plugins

Checklist

@mshustov mshustov added chore v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.14.0 labels May 17, 2021
currentTimeMarker: Joi.string().isoDate().required(),
currentTimeMarker: schema.string({
validate(value: string) {
if (isNaN(Date.parse(value))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe it's a valid case to extend @kbn/config-schema with date type

Copy link
Contributor

Choose a reason for hiding this comment

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

It does. I'm surprised we didn't get any feedback about this type missing to be honest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will create an issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

created #100635

createResults = await client.bulkCreate(
sampleDataset.savedObjects.map(({ version, ...savedObject }) => savedObject),
savedObjects.map(({ version, ...savedObject }) => savedObject),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kbn/config-schema creates a result type for { property: schema.any() }, as {property?: any}. That's okay, since any includes undefined or null types, but it's not compatible with savedObject.attributes property,(which is a generic, with unknown default).

@@ -108,6 +108,7 @@ export class APMPlugin
plugins.home?.tutorials.registerTutorial(() => {
const ossPart = ossTutorialProvider({});
if (this.currentConfig!['xpack.apm.ui.enabled'] && ossPart.artifacts) {
// @ts-expect-error ossPart.artifacts.application is readonly
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please, consider returning a new object instead of mutating the existing one.

@mshustov mshustov marked this pull request as ready for review May 17, 2021 15:49
@mshustov mshustov requested a review from a team as a code owner May 17, 2021 15:49
@mshustov mshustov requested a review from a team May 17, 2021 15:49
@mshustov mshustov requested a review from a team as a code owner May 17, 2021 15:49
Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

LGTM

currentTimeMarker: Joi.string().isoDate().required(),
currentTimeMarker: schema.string({
validate(value: string) {
if (isNaN(Date.parse(value))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It does. I'm surprised we didn't get any feedback about this type missing to be honest.


export type InstructionsSchema = TypeOf<typeof instructionSchema>;

const tutorialIdRegExp = /^[a-zA-Z0-9-]+$/;
Copy link
Contributor

Choose a reason for hiding this comment

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

Of course it's not the same regexp used everywhere :trollface:

@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label May 17, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Code review only, kibana app code changes LGTM!

@mshustov mshustov enabled auto-merge (squash) May 18, 2021 08:59
@pgayvallet pgayvallet mentioned this pull request May 18, 2021
@mshustov mshustov added the auto-backport Deprecated - use backport:version if exact versions are needed label May 18, 2021
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
home 67 64 -3

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
home 8 4 -4
Unknown metric groups

API count

id before after diff
home 91 88 -3

References to deprecated APIs

id before after diff
canvas 29 25 -4
crossClusterReplication 8 6 -2
fleet 22 20 -2
globalSearch 4 2 -2
indexManagement 12 7 -5
infra 261 149 -112
lens 67 45 -22
licensing 18 15 -3
maps 286 208 -78
ml 121 115 -6
monitoring 109 56 -53
stackAlerts 101 95 -6
total -295

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@mshustov mshustov merged commit 574f659 into elastic:master May 18, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request May 18, 2021
…ns (elastic#100201)

* add a link for issue to remove circular deps

* features: migrate from joi to config-schema

* update tests

* migrate home tutorials to config-schema

* migrate home dataset validation to config schema

* remove unnecessary type. we cannot guarantee this is a valid SO

* address Pierres comments
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

@mshustov mshustov deleted the issue-61100 branch May 18, 2021 12:08
kibanamachine added a commit that referenced this pull request May 18, 2021
…ns (#100201) (#100254)

* add a link for issue to remove circular deps

* features: migrate from joi to config-schema

* update tests

* migrate home tutorials to config-schema

* migrate home dataset validation to config schema

* remove unnecessary type. we cannot guarantee this is a valid SO

* address Pierres comments

Co-authored-by: Mikhail Shustov <restrry@gmail.com>
yctercero pushed a commit to yctercero/kibana that referenced this pull request May 25, 2021
…ns (elastic#100201)

* add a link for issue to remove circular deps

* features: migrate from joi to config-schema

* update tests

* migrate home tutorials to config-schema

* migrate home dataset validation to config schema

* remove unnecessary type. we cannot guarantee this is a valid SO

* address Pierres comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed chore release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remove legacy API from features plugin
6 participants