Skip to content

Commit

Permalink
Merge branch 'master' into fix/kbn-es-short-test-timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jun 15, 2020
2 parents 681c148 + f7398f0 commit c76b5d3
Show file tree
Hide file tree
Showing 28 changed files with 965 additions and 641 deletions.
57 changes: 57 additions & 0 deletions src/core/server/ui_settings/saved_objects/migrations.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { SavedObjectUnsanitizedDoc } from 'kibana/server';
import { migrations } from './migrations';

describe('ui_settings 7.9.0 migrations', () => {
const migration = migrations['7.9.0'];

test('returns doc on empty object', () => {
expect(migration({} as SavedObjectUnsanitizedDoc)).toEqual({
references: [],
});
});
test('properly renames siem attributes to securitySolution', () => {
const doc = {
type: 'config',
id: '8.0.0',
attributes: {
buildNum: 9007199254740991,
'siem:defaultAnomalyScore': 59,
'siem:enableNewsFeed': false,
},
references: [],
updated_at: '2020-06-09T20:18:20.349Z',
migrationVersion: {},
};
expect(migration(doc)).toEqual({
type: 'config',
id: '8.0.0',
attributes: {
buildNum: 9007199254740991,
'securitySolution:defaultAnomalyScore': 59,
'securitySolution:enableNewsFeed': false,
},
references: [],
updated_at: '2020-06-09T20:18:20.349Z',
migrationVersion: {},
});
});
});
42 changes: 42 additions & 0 deletions src/core/server/ui_settings/saved_objects/migrations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { SavedObjectUnsanitizedDoc, SavedObjectSanitizedDoc } from 'kibana/server';

export const migrations = {
'7.9.0': (doc: SavedObjectUnsanitizedDoc<any>): SavedObjectSanitizedDoc<any> => ({
...doc,
...(doc.attributes && {
attributes: Object.keys(doc.attributes).reduce(
(acc, key) =>
key.startsWith('siem:')
? {
...acc,
[key.replace('siem', 'securitySolution')]: doc.attributes[key],
}
: {
...acc,
[key]: doc.attributes[key],
},
{}
),
}),
references: doc.references || [],
}),
};
2 changes: 2 additions & 0 deletions src/core/server/ui_settings/saved_objects/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { SavedObjectsType } from '../../saved_objects';
import { migrations } from './migrations';

export const uiSettingsType: SavedObjectsType = {
name: 'config',
Expand Down Expand Up @@ -46,4 +47,5 @@ export const uiSettingsType: SavedObjectsType = {
return `Advanced Settings [${obj.id}]`;
},
},
migrations,
};
3 changes: 2 additions & 1 deletion src/es_archiver/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ cmd
.action((name, indices) => execute((archiver, { raw }) => archiver.save(name, indices, { raw })));

cmd
.option('--use-create', 'use create instead of index for loading documents')
.command('load <name>')
.description('load the archive in --dir with <name>')
.action((name) => execute((archiver) => archiver.load(name)));
.action((name) => execute((archiver, { useCreate }) => archiver.load(name, { useCreate })));

cmd
.command('unload <name>')
Expand Down
1 change: 1 addition & 0 deletions test/api_integration/apis/saved_objects/bulk_get.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default function ({ getService }) {
buildNum: 8467,
defaultIndex: '91200a00-9efd-11e7-acb3-3dab96693fab',
},
migrationVersion: resp.body.saved_objects[2].migrationVersion,
references: [],
},
],
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ingest_manager/common/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const AGENT_CONFIG_API_ROUTES = {
INFO_PATTERN: `${AGENT_CONFIG_API_ROOT}/{agentConfigId}`,
CREATE_PATTERN: `${AGENT_CONFIG_API_ROOT}`,
UPDATE_PATTERN: `${AGENT_CONFIG_API_ROOT}/{agentConfigId}`,
COPY_PATTERN: `${AGENT_CONFIG_API_ROOT}/{agentConfigId}/copy`,
DELETE_PATTERN: `${AGENT_CONFIG_API_ROOT}/delete`,
FULL_INFO_PATTERN: `${AGENT_CONFIG_API_ROOT}/{agentConfigId}/full`,
FULL_INFO_DOWNLOAD_PATTERN: `${AGENT_CONFIG_API_ROOT}/{agentConfigId}/download`,
Expand Down
Loading

0 comments on commit c76b5d3

Please sign in to comment.