-
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
Merged
paul-tavares
merged 11 commits into
elastic:master
from
paul-tavares:task/ingest-65904-datasources-additional-fields
May 12, 2020
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4c5bd86
add additinoal properties to ingest-datasources SO
paul-tavares 5f545ff
Adjusted Types and test generators
paul-tavares 9eedd02
Added datasources migrations to SO
paul-tavares 98a75ff
change date attributes to `type: 'date'`
paul-tavares be8535d
Add `user` info. to datasource.create()
paul-tavares 433eedb
Merge remote-tracking branch 'upstream/master' into task/ingest-65904…
paul-tavares 375ea63
Fix datasource update to remove extra attributes
paul-tavares 74c3cd8
Fix endpoint policy save to remove extra attributes from update
paul-tavares 78c8194
Merge remote-tracking branch 'upstream/master' into task/ingest-65904…
paul-tavares cd9d9b3
renamed created/update attributes to be `*_at`
paul-tavares 1198481
Merge remote-tracking branch 'upstream/master' into task/ingest-65904…
paul-tavares File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_at: { type: 'date' }, | ||
updated_by: { type: 'keyword' }, | ||
created_at: { type: 'date' }, | ||
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, | ||
|
29 changes: 29 additions & 0 deletions
29
x-pack/plugins/ingest_manager/server/saved_objects/migrations/datasources_v790.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_at' | 'created_by' | 'updated_at' | '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_at = updatedDatasource?.updated_at ?? defDate; | ||
updatedDatasource.attributes.updated_by = 'system'; | ||
updatedDatasource.attributes.updated_at = updatedDatasource?.updated_at ?? defDate; | ||
|
||
return updatedDatasource; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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,