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

[EPM]: Assign data source to policy in UI #53597

Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More descriptive (less ambiguous) names for these two functions
  • Loading branch information
John Schulz committed Dec 20, 2019
commit 48b9519086e2e7424854ef78154763682b338f88
14 changes: 5 additions & 9 deletions x-pack/legacy/plugins/epm/server/datasources/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,16 @@ export async function createDatasource({
});

// TODO: This should be moved out of the initial data source creation in the end
await baseSetup(callCluster);
await basePolicySetup(callCluster);

const datasource = await constructDatasource({
const datasource = await createDatasourceObject({
savedObjectsClient,
pkg: registryPackageInfo,
datasourceName,
toSave,
datasets,
});

// ideally we'd call .create from /x-pack/legacy/plugins/ingest/server/libs/datasources.ts#L22
// or something similar, but it's a class not an object so many pieces are missing
// we'd still need `user` from the request object, but that's not terrible
// lacking that we make another http request to Ingest
const savedDatasource = await Ingest.createDatasource({ request, datasource });

await Promise.all(
Expand All @@ -78,9 +74,9 @@ export async function createDatasource({

/**
* Makes the basic setup of the assets like global ILM policies. Creates them if they do
* not exist yet but will not overwrite existing once.
* not exist yet but will not overwrite existing ones.
*/
async function baseSetup(callCluster: CallESAsCurrentUser) {
async function basePolicySetup(callCluster: CallESAsCurrentUser) {
if (!(await policyExists('logs-default', callCluster))) {
await installILMPolicy('logs-default', callCluster);
}
Expand All @@ -89,7 +85,7 @@ async function baseSetup(callCluster: CallESAsCurrentUser) {
}
}

async function constructDatasource(options: {
async function createDatasourceObject(options: {
savedObjectsClient: SavedObjectsClientContract;
pkg: RegistryPackage;
datasourceName: string;
Expand Down