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

[Actions] [8.0] Prepare for making action saved objects sharecapable. #109756

Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,19 @@ describe('successful migrations', () => {
});
});
});

describe('8.0.0', () => {
test('no op migration for rules SO', () => {
const migration800 = getActionTaskParamsMigrations(encryptedSavedObjectsSetup, [])['8.0.0'];
const actionTaskParam = getMockData();
expect(migration800(actionTaskParam, context)).toEqual({
...actionTaskParam,
attributes: {
...actionTaskParam.attributes,
},
});
YulNaumenko marked this conversation as resolved.
Show resolved Hide resolved
});
});
});

describe('handles errors during migrations', () => {
Expand Down Expand Up @@ -402,7 +415,8 @@ describe('isPreconfiguredAction()', () => {

function getMockData(
overwrites: Record<string, unknown> = {},
referencesOverwrites: SavedObjectReference[] = []
referencesOverwrites: SavedObjectReference[] = [],
namespaces: string[] = ['default']
): SavedObjectUnsanitizedDoc<ActionTaskParams> {
return {
attributes: {
Expand All @@ -412,6 +426,7 @@ function getMockData(
},
references: [...referencesOverwrites],
id: uuid.v4(),
namespaces,
type: 'action_task_param',
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,17 @@ export function getActionTaskParamsMigrations(
pipeMigrations(getUseSavedObjectReferencesFn(preconfiguredActions))
);

const migrationActionsTaskParams800 = createEsoMigration(
encryptedSavedObjects,
(
doc: SavedObjectUnsanitizedDoc<ActionTaskParams>
): doc is SavedObjectUnsanitizedDoc<ActionTaskParams> => true,
(doc) => doc // no-op
);

return {
'7.16.0': executeMigrationWithErrorHandling(migrationActionTaskParamsSixteen, '7.16.0'),
'8.0.0': executeMigrationWithErrorHandling(migrationActionsTaskParams800, '8.0.0'),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,19 @@ describe('handles errors during migrations', () => {
);
});
});

describe('8.0.0', () => {
test('no op migration for rules SO', () => {
const migration800 = getActionsMigrations(encryptedSavedObjectsSetup)['8.0.0'];
const action = getMockData();
expect(migration800(action, context)).toEqual({
...action,
attributes: {
...action.attributes,
},
});
YulNaumenko marked this conversation as resolved.
Show resolved Hide resolved
});
});
});

function getMockDataForWebhook(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,18 @@ export function getActionsMigrations(
pipeMigrations(addisMissingSecretsField)
);

const migrationActions800 = createEsoMigration(
encryptedSavedObjects,
(doc: SavedObjectUnsanitizedDoc<RawAction>): doc is SavedObjectUnsanitizedDoc<RawAction> =>
true,
(doc) => doc // no-op
);

return {
'7.10.0': executeMigrationWithErrorHandling(migrationActionsTen, '7.10.0'),
'7.11.0': executeMigrationWithErrorHandling(migrationActionsEleven, '7.11.0'),
'7.14.0': executeMigrationWithErrorHandling(migrationActionsFourteen, '7.14.0'),
'8.0.0': executeMigrationWithErrorHandling(migrationActions800, '8.0.0'),
};
}

Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/actions/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export function setupSavedObjects(
savedObjects.registerType({
name: ACTION_SAVED_OBJECT_TYPE,
hidden: true,
namespaceType: 'single',
namespaceType: 'multiple-isolated',
convertToMultiNamespaceTypeVersion: '8.0.0',
mappings: mappings.action as SavedObjectsTypeMappingDefinition,
migrations: getActionsMigrations(encryptedSavedObjects),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to add a no-op migration for the ACTION_SAVED_OBJECT_TYPE type too, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.., I forgot about this. Thank you for pointing!

management: {
Expand Down Expand Up @@ -71,7 +72,8 @@ export function setupSavedObjects(
savedObjects.registerType({
name: ACTION_TASK_PARAMS_SAVED_OBJECT_TYPE,
hidden: true,
namespaceType: 'single',
namespaceType: 'multiple-isolated',
convertToMultiNamespaceTypeVersion: '8.0.0',
mappings: mappings.action_task_params as SavedObjectsTypeMappingDefinition,
migrations: getActionTaskParamsMigrations(encryptedSavedObjects, preconfiguredActions),
excludeOnUpgrade: async ({ readonlyEsClient }) => {
Expand Down