-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Fix agent policy mappings for space awareness #201689
Changes from all commits
d129bc1
f9b3035
4b3c2a5
5a71934
d2d77a5
fbacaea
d27b010
1660392
7e83e00
c78a9d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import _ from 'lodash'; | ||
|
||
import { getSavedObjectTypes } from '.'; | ||
|
||
describe('space aware models', () => { | ||
it('should have the same mappings for space and non-space aware agent policies', () => { | ||
const soTypes = getSavedObjectTypes(); | ||
|
||
const legacyMappings = _.omit( | ||
soTypes['ingest-agent-policies'].mappings, | ||
'properties.monitoring_diagnostics', | ||
'properties.monitoring_http', | ||
'properties.monitoring_pprof_enabled' | ||
); | ||
|
||
expect(legacyMappings).toEqual(soTypes['fleet-agent-policies'].mappings); | ||
}); | ||
it('should have the same mappings for space and non-space aware package policies', () => { | ||
const soTypes = getSavedObjectTypes(); | ||
|
||
expect(soTypes['ingest-package-policies'].mappings).toEqual( | ||
soTypes['fleet-package-policies'].mappings | ||
); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -214,6 +214,7 @@ export const getSavedObjectTypes = ( | |||||||||
importableAndExportable: false, | ||||||||||
}, | ||||||||||
mappings: { | ||||||||||
dynamic: false, | ||||||||||
properties: { | ||||||||||
name: { type: 'keyword' }, | ||||||||||
schema_version: { type: 'version' }, | ||||||||||
|
@@ -305,6 +306,14 @@ export const getSavedObjectTypes = ( | |||||||||
}, | ||||||||||
], | ||||||||||
}, | ||||||||||
'5': { | ||||||||||
changes: [ | ||||||||||
{ | ||||||||||
type: 'mappings_addition', | ||||||||||
addedMappings: {}, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
You should also specify the change in mappings here. It's unfortunate that we have this duplication of the mappings definitions, but we didn't see a good way around it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rudolf I tried this but I got a type error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah I see, you're right, looks like a limitation in the modelVersions API in that you can't actually specify a change that sets the top-level dynamic option. |
||||||||||
}, | ||||||||||
], | ||||||||||
}, | ||||||||||
}, | ||||||||||
}, | ||||||||||
[AGENT_POLICY_SAVED_OBJECT_TYPE]: { | ||||||||||
|
@@ -316,6 +325,7 @@ export const getSavedObjectTypes = ( | |||||||||
importableAndExportable: false, | ||||||||||
}, | ||||||||||
mappings: { | ||||||||||
dynamic: false, | ||||||||||
properties: { | ||||||||||
name: { type: 'keyword' }, | ||||||||||
schema_version: { type: 'version' }, | ||||||||||
|
@@ -350,6 +360,16 @@ export const getSavedObjectTypes = ( | |||||||||
global_data_tags: { type: 'flattened', index: false }, | ||||||||||
}, | ||||||||||
}, | ||||||||||
modelVersions: { | ||||||||||
'1': { | ||||||||||
changes: [ | ||||||||||
{ | ||||||||||
type: 'mappings_addition', | ||||||||||
addedMappings: {}, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
}, | ||||||||||
], | ||||||||||
}, | ||||||||||
}, | ||||||||||
}, | ||||||||||
[OUTPUT_SAVED_OBJECT_TYPE]: { | ||||||||||
name: OUTPUT_SAVED_OBJECT_TYPE, | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice