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

[Fleet] Add initial config libs and adapters #43483

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8fb9518
Project init
mattapperson May 31, 2019
e1c5020
initial client libs
mattapperson Jun 1, 2019
f141fa7
add initial UI framework
mattapperson Jun 4, 2019
288e5f6
move fleet to legacy
mattapperson Jun 25, 2019
339c6e1
add readme
mattapperson Jun 25, 2019
b331743
Add shell ingest plugin
mattapperson Jul 22, 2019
684936c
fix typo
mattapperson Jul 22, 2019
dd83486
update paths for legacy API. cleanup linting in vscode
mattapperson Jul 23, 2019
af602e2
remove CRUFT
mattapperson Jul 23, 2019
701ffdc
remove more CRUFT
mattapperson Jul 23, 2019
84757fb
[Ingest] cleanup names and files/paths to confirm to a standard forma…
mattapperson Jul 25, 2019
15804ed
initial client libs
mattapperson Jun 1, 2019
5988633
cleanup names and files/paths to confirm to a standard format
mattapperson Jul 23, 2019
e92e872
tack down WIP code
mattapperson Jul 23, 2019
7ed7ec2
remove things not or not yet needed
mattapperson Jul 23, 2019
9f030a9
fix more types, define SO
mattapperson Jul 23, 2019
8cc1f61
Fixed unused variables. Added a few methods to the SO adapter
mattapperson Jul 23, 2019
1a96780
fix type
mattapperson Jul 24, 2019
0c72c04
removed blank test file
mattapperson Jul 24, 2019
8a4acc9
add config adapter (no tests yet)
mattapperson Jul 29, 2019
c16d4f6
progress with config lib
mattapperson Aug 5, 2019
d9779e6
working!
mattapperson Aug 12, 2019
40deefa
tweaks
mattapperson Aug 16, 2019
c7ecf6c
Merge branch 'feature-make-it-ingest' into fleet-features/configs
Aug 16, 2019
b15f27a
fix test
mattapperson Aug 16, 2019
8a34d02
Merge branch 'fleet-features/configs' of https://github.com/mattapper…
mattapperson Aug 16, 2019
3c2fccf
Merge branch 'feature-make-it-ingest' into fleet-features/configs
Aug 20, 2019
28aebfb
remove whitespace
mattapperson Aug 20, 2019
1e41913
remove isVersionGreater
mattapperson Aug 20, 2019
56008d4
remove CRUFT from a bad merge
mattapperson Aug 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/test_utils/kbn_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ export function createRoot(settings = {}, cliArgs: Partial<CliArgs> = {}) {
* @param {Object} [settings={}] Any config overrides for this instance.
* @returns {Root}
*/
export function createRootWithCorePlugins(settings = {}) {
return createRootWithSettings(defaultsDeep({}, settings, DEFAULT_SETTINGS_WITH_CORE_PLUGINS));
export function createRootWithCorePlugins(settings = {}, cliArgs: Partial<CliArgs> = {}) {
return createRootWithSettings(
defaultsDeep({}, settings, DEFAULT_SETTINGS_WITH_CORE_PLUGINS),
cliArgs
);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions x-pack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { encryptedSavedObjects } from './legacy/plugins/encrypted_saved_objects'
import { snapshotRestore } from './legacy/plugins/snapshot_restore';
import { actions } from './legacy/plugins/actions';
import { alerting } from './legacy/plugins/alerting';
import { ingest } from './legacy/plugins/ingest';
import { advancedUiActions } from './legacy/plugins/advanced_ui_actions';
import { fleet } from './legacy/plugins/fleet';

Expand Down Expand Up @@ -87,6 +88,7 @@ module.exports = function (kibana) {
snapshotRestore(kibana),
actions(kibana),
alerting(kibana),
ingest(kibana),
advancedUiActions(kibana),
fleet(kibana),
];
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/fleet/public/lib/compose/kibana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import chrome from 'ui/chrome';
// @ts-ignore not typed yet
import { management } from 'ui/management';
import routes from 'ui/routes';
import { INDEX_NAMES } from '../../../common/constants/index_names';
import { RestAgentAdapter } from '../adapters/agent/rest_agent_adapter';
import { RestElasticsearchAdapter } from '../adapters/elasticsearch/rest';
import { KibanaFrameworkAdapter } from '../adapters/framework/kibana_framework_adapter';
Expand All @@ -22,6 +21,7 @@ import { ElasticsearchLib } from '../elasticsearch';
import { FrontendLibs } from '../types';
import { PLUGIN } from '../../../common/constants/plugin';
import { FrameworkLib } from '../framework';
import { INDEX_NAMES } from '../../../common/constants';

// A super early spot in kibana loading that we can use to hook before most other things
const onKibanaReady = chrome.dangerouslyGetActiveInjector;
Expand Down
24 changes: 0 additions & 24 deletions x-pack/legacy/plugins/fleet/public/lib/framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,6 @@ export class FrameworkLib {
);
}

public versionGreaterThen(version: string) {
const pa = this.adapter.version.split('.');
const pb = version.split('.');
for (let i = 0; i < 3; i++) {
const na = Number(pa[i]);
const nb = Number(pb[i]);
// version is greater
if (na > nb) {
return true;
}
// version is less then
if (nb > na) {
return false;
}
if (!isNaN(na) && isNaN(nb)) {
return true;
}
if (isNaN(na) && !isNaN(nb)) {
return false;
}
}
return true;
}

public currentUserHasOneOfRoles(roles: string[]) {
// If the user has at least one of the roles requested, the returnd difference will be less
// then the orig array size. difference only compares based on the left side arg
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/ingest/common/constants/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/

export const PLUGIN = {
ID: 'ingest-data',
ID: 'ingest',
};
export const CONFIG_PREFIX = 'xpack.ingest-do-not-disable';
41 changes: 41 additions & 0 deletions x-pack/legacy/plugins/ingest/common/utils/is_version_greater.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export function isVersionGreater(v1: string, v2: string): 1 | 0 | -1 {
const v1parts = v1.split('.');
const v2parts = v2.split('.');

function isValidPart(x: string) {
return /^\d+$/.test(x);
}

if (!v1parts.every(isValidPart) || !v2parts.every(isValidPart)) {
throw new Error('versions are not valid');
}

while (v1parts.length < v2parts.length) v1parts.push('0');
while (v2parts.length < v1parts.length) v2parts.push('0');

for (let i = 0; i < v1parts.length; ++i) {
if (v2parts.length === i) {
return 1;
}

if (v1parts[i] === v2parts[i]) {
continue;
} else if (v1parts[i] > v2parts[i]) {
return 1;
} else {
return -1;
}
}

if (v1parts.length !== v2parts.length) {
return -1;
}

return 0;
}
4 changes: 4 additions & 0 deletions x-pack/legacy/plugins/ingest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { resolve } from 'path';
import { PLUGIN } from './common/constants';
import { CONFIG_PREFIX } from './common/constants/plugin';
import { initServerWithKibana } from './server/kibana.index';
import { mappings } from './server/mappings';

export const config = Joi.object({
enabled: Joi.boolean().default(true),
Expand All @@ -20,6 +21,9 @@ export function ingest(kibana: any) {
publicDir: resolve(__dirname, 'public'),
config: () => config,
configPrefix: CONFIG_PREFIX,
uiExports: {
mappings,
},
init(server: any) {
initServerWithKibana(server);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

exports['Configurations Lib create should create a new configuration - create - {"name":"test","description":"test description","output":"defaut","monitoring_enabled":true,"agent_version":"8.0.0","data_sources":[]} (2)'] = {
"results": {
"id": "8a8874b0-bd51-11e9-a21b-dbec3e1a8be1"
}
}

exports['Configurations Lib create should create a new configuration - create - {"name":"test","description":"test description","output":"defaut","monitoring_enabled":true,"shared_id":"994528b0-887f-4c71-923e-4ffe5dd302e2","version":0,"agent_version":"8.0.0","data_sources":[]} (2)'] = {
"results": {
"id": "715d5cb0-bd53-11e9-bb4e-fb77f27555ca",
"shared_id": "994528b0-887f-4c71-923e-4ffe5dd302e2",
"version": 0
}
}

exports['Configurations Lib create should create a new configuration - create - {"name":"test","description":"test description","output":"defaut","monitoring_enabled":true,"shared_id":"997e6674-d072-475b-89d3-9b9202e0dd99","version":0,"agent_version":"8.0.0","data_sources":[]} (2)'] = {
"results": {
"id": "9cd167f0-c065-11e9-9b54-89c2396bf183",
"shared_id": "997e6674-d072-475b-89d3-9b9202e0dd99",
"version": 0
}
}

exports['Configurations Lib create should create a new configuration - create - {"name":"test","description":"test description","output":"defaut","monitoring_enabled":true,"version":0,"agent_version":"8.0.0","data_sources":[],"shared_id":"string"} (2)'] = {
"results": {
"id": "385d2130-c068-11e9-a90f-d9a51a8c04f8",
"shared_id": "de5a13b9-4b80-4983-8e6a-1619e3f97b9a",
"version": 0
}
}

exports['Configurations Lib create should create a new configuration - get info (1)'] = {
"results": {
"kibana": {
"version": "8.0.0"
},
"license": {
"type": "trial",
"expired": false,
"expiry_date_in_millis": 1568580919209
},
"security": {
"enabled": true,
"available": true
},
"watcher": {
"enabled": true,
"available": true
}
}
}

exports['Configurations Lib create should create a new configuration - get info (2)'] = {
"results": {
"kibana": {
"version": "8.0.0"
},
"license": {
"type": "trial",
"expired": false,
"expiry_date_in_millis": 1568240322629
},
"security": {
"enabled": true,
"available": true
},
"watcher": {
"enabled": true,
"available": true
}
}
}

exports['Configurations Lib create should create a new configuration - get info (3)'] = {
"results": {
"kibana": {
"version": "8.0.0"
},
"license": {
"type": "trial",
"expired": false,
"expiry_date_in_millis": 1568240322629
},
"security": {
"enabled": true,
"available": true
},
"watcher": {
"enabled": true,
"available": true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const RuntimeDatasourceInput = t.interface(
{
id: t.string,
meta: t.union([t.undefined, t.string]),
config: t.string,
config_id: t.string,
},
'DatasourceInput'
);
Expand All @@ -29,6 +29,8 @@ export const NewRuntimeConfigurationFile = t.interface(
description: t.string,
output: t.string,
monitoring_enabled: t.boolean,
shared_id: t.string,
version: t.number,
agent_version: t.string,
data_sources: t.array(DataSource),
},
Expand All @@ -51,7 +53,7 @@ const ExistingDocument = t.interface({
id: t.string,
shared_id: t.string,
version: t.number,
active: t.boolean,
status: t.union(['active', 'locked', 'inactive'].map(s => t.literal(s))),
updated_at: t.string,
created_by: t.union([t.undefined, t.string]),
updated_on: t.string,
Expand Down
Loading