Skip to content

Commit 28d55ef

Browse files
Merge branch 'master' into dev/data-plugin-wrong-import
2 parents c0e7e9b + 284a77c commit 28d55ef

File tree

32 files changed

+375
-193
lines changed

32 files changed

+375
-193
lines changed

dev_docs/kibana_platform_plugin_intro.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ We will continue to focus on adding clarity around these types of services and w
6868

6969
### Core services
7070

71-
Sometimes referred to just as Core, Core services provide the most basic and fundamental tools neccessary for building a plugin, like creating saved objects,
71+
Sometimes referred to just as <DocLink id="kibServerAndCoreComponents" text="Core, Core services"/> provide the most basic and fundamental tools neccessary for building a plugin, like creating saved objects,
7272
routing, application registration, notifications and <DocLink id="kibCoreLogging" text="logging"/>. The Core platform is not a plugin itself, although
7373
there are some plugins that provide platform functionality. We call these <DocLink id="kibPlatformIntro" section="platform-plugins" text="Platform plugins"/>.
7474

@@ -141,4 +141,4 @@ plugins to customize the Kibana experience. Examples of extension points are:
141141

142142
## Follow up material
143143

144-
Learn how to build your own plugin by following <DocLink id="kibDevTutorialBuildAPlugin" />
144+
Learn how to build your own plugin by following <DocLink id="kibDevTutorialBuildAPlugin" />.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
id: kibServerAndCoreComponents
3+
slug: /kibana-dev-docs/core-intro
4+
title: Core components
5+
summary: An introduction to the Kibana server and core components.
6+
date: 2021-02-26
7+
tags: ['kibana','onboarding', 'dev', 'architecture']
8+
---
9+
10+
Core is a set of systems (frontend, backend etc.) that Kibana and its plugins are built on top of.
11+
12+
## Integration with the "legacy" Kibana
13+
14+
Most of the existing core functionality is still spread over "legacy" Kibana and it will take some time to upgrade it.
15+
Kibana is started using existing "legacy" CLI that bootstraps `core` which in turn creates the "legacy" Kibana server.
16+
At the moment `core` manages HTTP connections, handles TLS configuration and base path proxy. All requests to Kibana server
17+
will hit HTTP server exposed by the `core` first and it will decide whether request can be solely handled by the new
18+
platform or request should be proxied to the "legacy" Kibana. This setup allows `core` to gradually introduce any "pre-route"
19+
processing logic, expose new routes or replace old ones handled by the "legacy" Kibana currently.
20+
21+
Once config has been loaded and some of its parts were validated by the `core` it's passed to the "legacy" Kibana where
22+
it will be additionally validated so that we can make config validation stricter with the new config validation system.
23+
Even though the new validation system provided by the `core` is also based on Joi internally it is complemented with custom
24+
rules tailored to our needs (e.g. `byteSize`, `duration` etc.). That means that config values that were previously accepted
25+
by the "legacy" Kibana may be rejected by the `core` now.
26+
27+
### Logging
28+
`core` has its own <DocLink id="kibCoreLogging" text="logging system"/> and will output log records directly (e.g. to file or terminal) when configured. When no specific configuration is provided, logs are forwarded to the "legacy" Kibana so that they look the same as the rest of the
29+
log records throughout Kibana.
30+

docs/settings/task-manager-settings.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ Task Manager runs background tasks by polling for work on an interval. You can
2727

2828
| `xpack.task_manager.max_workers`
2929
| The maximum number of tasks that this Kibana instance will run simultaneously. Defaults to 10.
30-
30+
Starting in 8.0, it will not be possible to set the value greater than 100.
3131

3232
|===

docs/user/alerting/defining-alerts.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ Some cases exist where the variable values will be "escaped", when used in a con
9595

9696
Mustache also supports "triple braces" of the form `{{{variable name}}}`, which indicates no escaping should be done at all. Care should be used when using this form, as it could end up rendering the variable content in such a way as to make the resulting parameter invalid or formatted incorrectly.
9797

98+
Each alert type defines additional variables as properties of the variable `context`. For example, if an alert type defines a variable `value`, it can be used in an action parameter as `{{context.value}}`.
99+
100+
For diagnostic or exploratory purposes, action variables whose values are objects, such as `context`, can be referenced directly as variables. The resulting value will be a JSON representation of the object. For example, if an action parameter includes `{{context}}`, it will expand to the JSON representation of all the variables and values provided by the alert type.
101+
98102
You can attach more than one action. Clicking the "Add action" button will prompt you to select another alert type and repeat the above steps again.
99103

100104
[role="screenshot"]

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"kbn:watch": "node scripts/kibana --dev --logging.json=false",
5959
"build:types": "rm -rf ./target/types && tsc --p tsconfig.types.json",
6060
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
61-
"kbn:bootstrap": "node scripts/build_ts_refs",
61+
"kbn:bootstrap": "node scripts/build_ts_refs --ignore-type-failures",
6262
"spec_to_console": "node scripts/spec_to_console",
6363
"backport-skip-ci": "backport --prDescription \"[skip-ci]\"",
6464
"storybook": "node scripts/storybook",
@@ -82,7 +82,7 @@
8282
"**/load-grunt-config/lodash": "^4.17.21",
8383
"**/minimist": "^1.2.5",
8484
"**/node-jose/node-forge": "^0.10.0",
85-
"**/prismjs": "1.22.0",
85+
"**/prismjs": "1.23.0",
8686
"**/react-syntax-highlighter": "^15.3.1",
8787
"**/react-syntax-highlighter/**/highlight.js": "^10.4.1",
8888
"**/request": "^2.88.2",

src/core/CONVENTIONS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ export class MyPlugin implements Plugin {
202202
}
203203
```
204204

205-
Prefer the pattern shown above, using `core.getStartServices()`, rather than store local references retrieved from `start`.
205+
Prefer the pattern shown above, using `core.getStartServices()`, rather than store local references retrieved from `start`.
206206

207207
**Bad:**
208208
```ts
209209
export class MyPlugin implements Plugin {
210210
// Anti pattern
211211
private coreStart?: CoreStart;
212-
private depsStart?: DepsStart;
212+
private depsStart?: DepsStart;
213213

214214
public setup(core) {
215215
core.application.register({
@@ -220,7 +220,7 @@ export class MyPlugin implements Plugin {
220220
return renderApp(this.coreStart, this.depsStart, params);
221221
}
222222
});
223-
}
223+
}
224224

225225
public start(core, deps) {
226226
// Anti pattern
@@ -361,5 +361,5 @@ Migration example from the legacy format is available in `src/core/MIGRATION_EXA
361361

362362
### Naming conventions
363363

364-
Export start and setup contracts as `MyPluginStart` and `MyPluginSetup`.
364+
Export start and setup contracts as `MyPluginStart` and `MyPluginSetup`.
365365
This avoids naming clashes, if everyone exported them simply as `Start` and `Setup`.

src/core/CORE_CONVENTIONS.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ area of Core API's and does not apply to internal types.
1515

1616
- 1.1 All API types must be exported from the top-level `server` or `public`
1717
directories.
18-
18+
1919
```ts
2020
// -- good --
2121
import { IRouter } from 'src/core/server';
2222

2323
// -- bad --
2424
import { IRouter } from 'src/core/server/http/router.ts';
2525
```
26-
26+
2727
> Why? This is required for generating documentation from our inline
2828
> typescript doc comments, makes it easier for API consumers to find the
2929
> relevant types and creates a clear distinction between external and
3030
> internal types.
31-
31+
3232
- 1.2 Classes must not be exposed directly. Instead, use a separate type,
3333
prefixed with an 'I', to describe the public contract of the class.
34-
34+
3535
```ts
3636
// -- good (alternative 1) --
3737
/**
@@ -66,27 +66,27 @@ area of Core API's and does not apply to internal types.
6666
```
6767

6868
> Why? Classes' private members form part of their type signature making it
69-
> impossible to mock a dependency typed as a `class`.
69+
> impossible to mock a dependency typed as a `class`.
7070
>
7171
> Until we can use ES private field support in Typescript 3.8
7272
> https://github.com/elastic/kibana/issues/54906 we have two alternatives
7373
> each with their own pro's and cons:
7474
>
7575
> #### Using a derived class (alternative 1)
76-
>
76+
>
7777
> Pro's:
7878
> - TSDoc comments are located with the source code
7979
> - The class acts as a single source of type information
8080
>
8181
> Con's:
8282
> - "Go to definition" first takes you to where the type gets derived
8383
> requiring a second "Go to definition" to navigate to the type source.
84-
>
84+
>
8585
> #### Using a separate interface (alternative 2)
8686
> Pro's:
8787
> - Creates an explicit external API contract
8888
> - "Go to definition" will take you directly to the type definition.
89-
>
89+
>
9090
> Con's:
9191
> - TSDoc comments are located with the interface not next to the
9292
> implementation source code.

src/core/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Core Plugin API Documentation:
99
- [Conventions for Plugins](./CONVENTIONS.md)
1010
- [Testing Kibana Plugins](./TESTING.md)
1111
- [Kibana Platform Plugin API](./docs/developer/architecture/kibana-platform-plugin-api.asciidoc )
12-
12+
1313
Internal Documentation:
1414
- [Saved Objects Migrations](./server/saved_objects/migrations/README.md)
1515

@@ -18,18 +18,18 @@ Internal Documentation:
1818
Most of the existing core functionality is still spread over "legacy" Kibana and it will take some time to upgrade it.
1919
Kibana is started using existing "legacy" CLI that bootstraps `core` which in turn creates the "legacy" Kibana server.
2020
At the moment `core` manages HTTP connections, handles TLS configuration and base path proxy. All requests to Kibana server
21-
will hit HTTP server exposed by the `core` first and it will decide whether request can be solely handled by the new
21+
will hit HTTP server exposed by the `core` first and it will decide whether request can be solely handled by the new
2222
platform or request should be proxied to the "legacy" Kibana. This setup allows `core` to gradually introduce any "pre-route"
2323
processing logic, expose new routes or replace old ones handled by the "legacy" Kibana currently.
2424

25-
Once config has been loaded and some of its parts were validated by the `core` it's passed to the "legacy" Kibana where
25+
Once config has been loaded and some of its parts were validated by the `core` it's passed to the "legacy" Kibana where
2626
it will be additionally validated so that we can make config validation stricter with the new config validation system.
27-
Even though the new validation system provided by the `core` is also based on Joi internally it is complemented with custom
27+
Even though the new validation system provided by the `core` is also based on Joi internally it is complemented with custom
2828
rules tailored to our needs (e.g. `byteSize`, `duration` etc.). That means that config values that were previously accepted
2929
by the "legacy" Kibana may be rejected by the `core` now.
3030

3131
### Logging
32-
`core` has its own [logging system](./server/logging/README.mdx) and will output log records directly (e.g. to file or terminal) when configured. When no
32+
`core` has its own [logging system](./server/logging/README.mdx) and will output log records directly (e.g. to file or terminal) when configured. When no
3333
specific configuration is provided, logs are forwarded to the "legacy" Kibana so that they look the same as the rest of the
3434
log records throughout Kibana.
3535

src/dev/bazel_workspace_status.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,47 @@
1717
// If the script exits with non-zero code, it's considered as a failure
1818
// and the output will be discarded.
1919

20-
(async () => {
21-
const execa = require('execa');
20+
(() => {
21+
const cp = require('child_process');
2222
const os = require('os');
2323

24-
async function runCmd(cmd, args) {
24+
function runCmd(cmd, args) {
2525
try {
26-
return await execa(cmd, args);
26+
const spawnResult = cp.spawnSync(cmd, args);
27+
const exitCode = spawnResult.status !== null ? spawnResult.status : 1;
28+
const stdoutStr = spawnResult.stdout.toString();
29+
const stdout = stdoutStr ? stdoutStr.trim() : null;
30+
31+
return {
32+
exitCode,
33+
stdout,
34+
};
2735
} catch (e) {
2836
return { exitCode: 1 };
2937
}
3038
}
3139

3240
// Git repo
3341
const kbnGitOriginName = process.env.KBN_GIT_ORIGIN_NAME || 'origin';
34-
const repoUrlCmdResult = await runCmd('git', [
35-
'config',
36-
'--get',
37-
`remote.${kbnGitOriginName}.url`,
38-
]);
42+
const repoUrlCmdResult = runCmd('git', ['config', '--get', `remote.${kbnGitOriginName}.url`]);
3943
if (repoUrlCmdResult.exitCode === 0) {
4044
// Only output REPO_URL when found it
4145
console.log(`REPO_URL ${repoUrlCmdResult.stdout}`);
4246
}
4347

4448
// Commit SHA
45-
const commitSHACmdResult = await runCmd('git', ['rev-parse', 'HEAD']);
49+
const commitSHACmdResult = runCmd('git', ['rev-parse', 'HEAD']);
4650
if (commitSHACmdResult.exitCode === 0) {
4751
console.log(`COMMIT_SHA ${commitSHACmdResult.stdout}`);
4852

4953
// Branch
50-
const gitBranchCmdResult = await runCmd('git', ['rev-parse', '--abbrev-ref', 'HEAD']);
54+
const gitBranchCmdResult = runCmd('git', ['rev-parse', '--abbrev-ref', 'HEAD']);
5155
if (gitBranchCmdResult.exitCode === 0) {
5256
console.log(`GIT_BRANCH ${gitBranchCmdResult.stdout}`);
5357
}
5458

5559
// Tree status
56-
const treeStatusCmdResult = await runCmd('git', ['diff-index', '--quiet', 'HEAD', '--']);
60+
const treeStatusCmdResult = runCmd('git', ['diff-index', '--quiet', 'HEAD', '--']);
5761
const treeStatusVarStr = 'GIT_TREE_STATUS';
5862
if (treeStatusCmdResult.exitCode === 0) {
5963
console.log(`${treeStatusVarStr} Clean`);
@@ -64,7 +68,7 @@
6468

6569
// Host
6670
if (process.env.CI) {
67-
const hostCmdResult = await runCmd('hostname');
71+
const hostCmdResult = runCmd('hostname');
6872
const hostStr = hostCmdResult.stdout.split('-').slice(0, -1).join('-');
6973
const coresStr = os.cpus().filter((cpu, index) => {
7074
return !cpu.model.includes('Intel') || index % 2 === 1;

src/dev/typescript/build_ts_refs_cli.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,24 @@ import { concurrentMap } from './concurrent_map';
1818

1919
const CACHE_WORKING_DIR = Path.resolve(REPO_ROOT, 'data/ts_refs_output_cache');
2020

21+
const TS_ERROR_REF = /\sTS\d{1,6}:\s/;
22+
23+
const isTypeFailure = (error: any) =>
24+
error.exitCode === 1 &&
25+
error.stderr === '' &&
26+
typeof error.stdout === 'string' &&
27+
TS_ERROR_REF.test(error.stdout);
28+
2129
export async function runBuildRefsCli() {
2230
run(
2331
async ({ log, flags }) => {
32+
if (process.env.BUILD_TS_REFS_DISABLE === 'true' && !flags.force) {
33+
log.info(
34+
'Building ts refs is disabled because the BUILD_TS_REFS_DISABLE environment variable is set to "true". Pass `--force` to run the build anyway.'
35+
);
36+
return;
37+
}
38+
2439
const outDirs = getOutputsDeep(REF_CONFIG_PATHS);
2540

2641
const cacheEnabled = process.env.BUILD_TS_REFS_CACHE_ENABLE !== 'false' && !!flags.cache;
@@ -48,7 +63,20 @@ export async function runBuildRefsCli() {
4863
await outputCache.initCaches();
4964
}
5065

51-
await buildAllTsRefs(log);
66+
try {
67+
await buildAllTsRefs(log);
68+
log.success('ts refs build successfully');
69+
} catch (error) {
70+
const typeFailure = isTypeFailure(error);
71+
72+
if (flags['ignore-type-failures'] && typeFailure) {
73+
log.warning(
74+
'tsc reported type errors but we are ignoring them for now, to see them please run `node scripts/type_check` or `node scripts/build_ts_refs` without the `--ignore-type-failures` flag.'
75+
);
76+
} else {
77+
throw error;
78+
}
79+
}
5280

5381
if (outputCache && doCapture) {
5482
await outputCache.captureCache(Path.resolve(REPO_ROOT, 'target/ts_refs_cache'));
@@ -61,10 +89,16 @@ export async function runBuildRefsCli() {
6189
{
6290
description: 'Build TypeScript projects',
6391
flags: {
64-
boolean: ['clean', 'cache'],
92+
boolean: ['clean', 'force', 'cache', 'ignore-type-failures'],
6593
default: {
6694
cache: true,
6795
},
96+
help: `
97+
--force Run the build even if the BUILD_TS_REFS_DISABLE is set to "true"
98+
--clean Delete outDirs for each ts project before building
99+
--no-cache Disable fetching/extracting outDir caches based on the mergeBase with upstream
100+
--ignore-type-failures If tsc reports type errors, ignore them and just log a small warning.
101+
`,
68102
},
69103
log: {
70104
defaultLevel: 'debug',

0 commit comments

Comments
 (0)