-
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
[Ingest] Add additional attributes to the Datasources Saved Object #66127
Changes from 3 commits
4c5bd86
5f545ff
9eedd02
98a75ff
be8535d
433eedb
375ea63
74c3cd8
78c8194
cd9d9b3
1198481
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
*/ | ||
|
||
import { SavedObjectsServiceSetup, SavedObjectsType } from 'kibana/server'; | ||
import { EncryptedSavedObjectsPluginSetup } from '../../encrypted_saved_objects/server'; | ||
import { EncryptedSavedObjectsPluginSetup } from '../../../encrypted_saved_objects/server'; | ||
import { | ||
OUTPUT_SAVED_OBJECT_TYPE, | ||
AGENT_CONFIG_SAVED_OBJECT_TYPE, | ||
|
@@ -16,7 +16,8 @@ import { | |
AGENT_ACTION_SAVED_OBJECT_TYPE, | ||
ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, | ||
GLOBAL_SETTINGS_SAVED_OBJET_TYPE, | ||
} from './constants'; | ||
} from '../constants'; | ||
import { migrateDatasourcesToV790 } from './migrations/datasources_v790'; | ||
|
||
/* | ||
* Saved object types and mappings | ||
|
@@ -218,8 +219,15 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { | |
}, | ||
}, | ||
revision: { type: 'integer' }, | ||
updated_on: { type: 'keyword' }, | ||
updated_by: { type: 'keyword' }, | ||
created_on: { type: 'keyword' }, | ||
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. Why not using the type date? 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. Good point @nchaulet . I copied the definition from the Agent Config SO which had |
||
created_by: { type: 'keyword' }, | ||
}, | ||
}, | ||
migrations: { | ||
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. Even though I don't expect users to migrate from 7.8 to 7.9 I like that we get into the habit of providing a migration path! 👍 |
||
'7.9.0': migrateDatasourcesToV790, | ||
}, | ||
}, | ||
[PACKAGES_SAVED_OBJECT_TYPE]: { | ||
name: PACKAGES_SAVED_OBJECT_TYPE, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { SavedObjectMigrationFn } from 'kibana/server'; | ||
import { cloneDeep } from 'lodash'; | ||
import { Datasource } from '../../types/models'; | ||
|
||
type Pre790Datasource = Exclude< | ||
Datasource, | ||
'created_on' | 'created_by' | 'updated_on' | 'updated_by' | ||
>; | ||
|
||
export const migrateDatasourcesToV790: SavedObjectMigrationFn< | ||
Pre790Datasource, | ||
Datasource | ||
> = doc => { | ||
const updatedDatasource = cloneDeep(doc); | ||
const defDate = new Date().toISOString(); | ||
|
||
updatedDatasource.attributes.created_by = 'system'; | ||
updatedDatasource.attributes.created_on = updatedDatasource?.updated_at ?? defDate; | ||
updatedDatasource.attributes.updated_by = 'system'; | ||
updatedDatasource.attributes.updated_on = updatedDatasource?.updated_at ?? defDate; | ||
|
||
return updatedDatasource; | ||
}; |
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.
I imagine is just for testing purpose?
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.
Yes, test purposes to mock up data,