Skip to content

Commit

Permalink
Merge branch 'master' into ml-apm-correlations-fix-empty-state
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Aug 25, 2021
2 parents 5a8bfd7 + ca86f76 commit 04bf2de
Show file tree
Hide file tree
Showing 120 changed files with 1,189 additions and 148 deletions.
2 changes: 1 addition & 1 deletion dev_docs/key_concepts/anatomy_of_a_plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ plugins/
- preboot plugins are bootstrapped to prepare the environment before Kibana starts.
- standard plugins define Kibana functionality while Kibana is running.

`owner` - [Required] Help users of your plugin know who manages this plugin and how to get in touch. This is required for internal plugins. `Owner.name` should be the name of the team that manages this plugin. This should match the team that owns this code in the [CODEOWNERS](https://github.com/elastic/kibana/blob/master/.github/CODEOWNERS) file (however, this is not currently enforced). Internal teams should also use a [GitHub team alias](https://github.com/orgs/elastic/teams) for `owner.githubTeam`. While many teams can contribute to a plugin, only a single team should be the primary owner.
`owner` - [Required] Help users of your plugin know who manages this plugin and how to get in touch. For internal developers, `Owner.name` should be the name of the team that manages this plugin. This should match the team that owns this code in the [CODEOWNERS](https://github.com/elastic/kibana/blob/master/.github/CODEOWNERS) file (however, this is not currently enforced). Internal teams should also use a [GitHub team alias](https://github.com/orgs/elastic/teams) for `owner.githubTeam`. This value is used to create a link to `https://github.com/orgs/elastic/teams/${githubTeam}`, so leave the `elastic/` prefix should be left out. While many teams can contribute to a plugin, only a single team should be the primary owner.

`description` - [Required] Give your plugin a description to help other developers understand what it does. This is required for internal plugins.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Should never be used in code outside of Core but is exported for documentation p
| [id](./kibana-plugin-core-server.pluginmanifest.id.md) | <code>PluginName</code> | Identifier of the plugin. Must be a string in camelCase. Part of a plugin public contract. Other plugins leverage it to access plugin API, navigate to the plugin, etc. |
| [kibanaVersion](./kibana-plugin-core-server.pluginmanifest.kibanaversion.md) | <code>string</code> | The version of Kibana the plugin is compatible with, defaults to "version". |
| [optionalPlugins](./kibana-plugin-core-server.pluginmanifest.optionalplugins.md) | <code>readonly PluginName[]</code> | An optional list of the other plugins that if installed and enabled \*\*may be\*\* leveraged by this plugin for some additional functionality but otherwise are not required for this plugin to work properly. |
| [owner](./kibana-plugin-core-server.pluginmanifest.owner.md) | <code>{</code><br/><code> readonly name: string;</code><br/><code> readonly githubTeam?: string;</code><br/><code> }</code> | TODO: make required once all internal plugins have this specified. |
| [owner](./kibana-plugin-core-server.pluginmanifest.owner.md) | <code>{</code><br/><code> readonly name: string;</code><br/><code> readonly githubTeam?: string;</code><br/><code> }</code> | |
| [requiredBundles](./kibana-plugin-core-server.pluginmanifest.requiredbundles.md) | <code>readonly string[]</code> | List of plugin ids that this plugin's UI code imports modules from that are not in <code>requiredPlugins</code>. |
| [requiredPlugins](./kibana-plugin-core-server.pluginmanifest.requiredplugins.md) | <code>readonly PluginName[]</code> | An optional list of the other plugins that \*\*must be\*\* installed and enabled for this plugin to function properly. |
| [server](./kibana-plugin-core-server.pluginmanifest.server.md) | <code>boolean</code> | Specifies whether plugin includes some server-side specific functionality. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

## PluginManifest.owner property

TODO: make required once all internal plugins have this specified.

<b>Signature:</b>

```typescript
readonly owner?: {
readonly owner: {
readonly name: string;
readonly githubTeam?: string;
};
Expand Down
8 changes: 6 additions & 2 deletions docs/user/alerting/alerting-setup.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ Rules and connectors are isolated to the {kib} space in which they were created.
[[alerting-authorization]]
=== Authorization

Rules, including all background detection and the actions they generate are authorized using an <<api-keys, API key>> associated with the last user to edit the rule. Upon creating or modifying a rule, an API key is generated for that user, capturing a snapshot of their privileges at that moment in time. The API key is then used to run all background tasks associated with the rule including detection checks and executing actions.
Rules are authorized using an <<api-keys, API key>> associated with the last user to edit the rule. This API key captures a snapshot of the user's privileges at the time of edit and is subsequently used to run all background tasks associated with the rule, including condition checks, like {es} queries, and action executions. The following rule actions will re-generate the API key:

* Creating a rule
* Enabling a disabled rule
* Updating a rule

[IMPORTANT]
==============================================
If a rule requires certain privileges to run, such as index privileges, keep in mind that if a user without those privileges updates the rule, the rule will no longer function.
If a rule requires certain privileges, such as index privileges, to run, and a user without those privileges updates, disables, or re-enables the rule, the rule will no longer function. Conversely, if a user with greater or administrator privileges modifies the rule, it will begin running with increased privileges.
==============================================
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ interface Manifest {
server: boolean;
kibanaVersion: string;
version: string;
// TODO: make this required.
owner?: {
owner: {
// Internally, this should be a team name.
name: string;
// All internally owned plugins should have a github team specified that can be pinged in issues, or used to look up
Expand Down Expand Up @@ -64,6 +63,12 @@ export function parseKibanaPlatformPlugin(manifestPath: string): KibanaPlatformP
throw new TypeError('expected new platform plugin manifest to have a string version');
}

if (!manifest.owner || typeof manifest.owner.name !== 'string') {
throw new TypeError(
`Expected plugin ${manifest.id} manifest to have an owner with name specified (${manifestPath})`
);
}

return {
directory: Path.dirname(manifestPath),
manifestPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ import ${json} from './${fileName}.json';
${plugin.manifest.description ?? ''}
${
plugin.manifest.owner?.githubTeam && name
? `Contact [${name}](https://github.com/orgs/elastic/teams/${plugin.manifest.owner?.githubTeam}) for questions regarding this plugin.`
plugin.manifest.owner.githubTeam && name
? `Contact [${name}](https://github.com/orgs/elastic/teams/${plugin.manifest.owner.githubTeam}) for questions regarding this plugin.`
: name
? `Contact ${name} for questions regarding this plugin.`
: ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "pluginA",
"summary": "This an example plugin for testing the api documentation system",
"version": "kibana",
"serviceFolders": ["foo"]
}
"id": "pluginA",
"owner": { "name": "Kibana Tech Leads" },
"summary": "This an example plugin for testing the api documentation system",
"version": "kibana",
"serviceFolders": ["foo"]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "pluginB",
"owner": { "name": "Kibana Tech Leads" },
"summary": "This an example plugin for testing the api documentation system",
"version": "kibana"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export function getKibanaPlatformPlugin(id: string, dir?: string): KibanaPlatfor
server: true,
kibanaVersion: '1',
version: '1',
owner: {
name: 'Kibana Core',
},
serviceFolders: [],
requiredPlugins: [],
requiredBundles: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"id": "bar",
"ui": true,
"requiredBundles": ["foo"],
"version": "8.0.0"
"version": "8.0.0",
"owner": {
"name": "Operations"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"id": "foo",
"owner": {
"name": "Operations"
},
"ui": true,
"version": "8.0.0"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"id": "baz",
"owner": {
"name": "Operations"
},
"version": "8.0.0"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"id": "test_baz",
"owner": {
"name": "Operations"
},
"version": "8.0.0"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"id": "baz",
"owner": { "name": "Operations", "githubTeam": "kibana-operations" },
"ui": true,
"version": "8.0.0"
}
26 changes: 26 additions & 0 deletions packages/kbn-plugin-generator/src/ask_questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export interface Answers {
internalLocation: string;
ui: boolean;
server: boolean;
githubTeam?: string;
ownerName: string;
description?: string;
}

export const INTERNAL_PLUGIN_LOCATIONS: Array<{ name: string; value: string }> = [
Expand Down Expand Up @@ -49,6 +52,11 @@ export const QUESTIONS = [
default: undefined,
validate: (name: string) => (!name ? 'name is required' : true),
},
{
name: 'description',
message: 'Provide a description for your plugin.',
default: undefined,
},
{
name: 'internal',
type: 'confirm',
Expand All @@ -63,6 +71,24 @@ export const QUESTIONS = [
default: INTERNAL_PLUGIN_LOCATIONS[0].value,
when: ({ internal }: Answers) => internal,
},
{
name: 'ownerName',
message: 'Who is developing and maintaining this plugin?',
default: undefined,
when: ({ internal }: Answers) => !internal,
},
{
name: 'ownerName',
message: 'What team will maintain this plugin?',
default: undefined,
when: ({ internal }: Answers) => internal,
},
{
name: 'githubTeam',
message: 'What is your gitHub team alias?',
default: undefined,
when: ({ internal }: Answers) => internal,
},
{
name: 'ui',
type: 'confirm',
Expand Down
4 changes: 4 additions & 0 deletions packages/kbn-plugin-generator/src/render_template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export async function renderTemplates({
hasServer: !!answers.server,
hasUi: !!answers.ui,

ownerName: answers.ownerName,
githubTeam: answers.githubTeam,
description: answers.description,

camelCase,
snakeCase,
upperCamelCase,
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-plugin-generator/template/kibana.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"id": "<%= camelCase(name) %>",
"version": "1.0.0",
"kibanaVersion": "kibana",
"owner": {
"name": "<%= ownerName %>",
"githubTeam": "<%= githubTeam %>"
},
"description": "<%= description %>",
"server": <%= hasServer %>,
"ui": <%= hasUi %>,
"requiredPlugins": ["navigation"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ it('builds a generated plugin into a viable archive', async () => {
expect(loadJsonFile.sync(Path.resolve(TMP_DIR, 'kibana', 'fooTestPlugin', 'kibana.json')))
.toMatchInlineSnapshot(`
Object {
"description": "",
"id": "fooTestPlugin",
"kibanaVersion": "7.5.0",
"optionalPlugins": Array [],
"owner": Object {
"githubTeam": "",
"name": "",
},
"requiredPlugins": Array [
"navigation",
],
Expand Down
3 changes: 3 additions & 0 deletions src/core/public/plugins/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ function createManifest(
requiredPlugins: required,
optionalPlugins: optional,
requiredBundles: [],
owner: {
name: 'foo',
},
} as DiscoveredPlugin;
}

Expand Down
4 changes: 4 additions & 0 deletions src/core/public/plugins/plugins_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ function createManifest(
requiredPlugins: required,
optionalPlugins: optional,
requiredBundles: [],
owner: {
name: 'Core',
githubTeam: 'kibana-core',
},
};
}

Expand Down
Loading

0 comments on commit 04bf2de

Please sign in to comment.