Skip to content

Commit

Permalink
add inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ruflin committed Dec 17, 2019
1 parent 043ff02 commit bc42121
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions x-pack/legacy/plugins/epm/server/datasources/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export async function createDatasource(options: {
const pkg = await Registry.fetchInfo(pkgkey);

// Collect the config for each dataset
const configs: string[] = [];
const inputs: string[] = [];
if (pkg.datasets) {
for (const dataset of pkg.datasets) {
configs.push(await getConfig(pkgkey, dataset));
inputs.push(await getConfig(pkgkey, dataset));
}
}

Expand All @@ -56,6 +56,7 @@ export async function createDatasource(options: {
datasets,
toSave,
request,
inputs,
}),
]);

Expand All @@ -82,8 +83,9 @@ async function saveDatasourceReferences(options: {
datasourceName: string;
toSave: AssetReference[];
request: Request;
inputs: string[];
}) {
const { savedObjectsClient, pkg, toSave, datasets, datasourceName, request } = options;
const { savedObjectsClient, pkg, toSave, datasets, datasourceName, request, inputs } = options;
const savedDatasource = await getDatasource({ savedObjectsClient, pkg });
const savedAssets = savedDatasource?.package.assets;
const assetsReducer = (current: Asset[] = [], pending: Asset) => {
Expand All @@ -99,6 +101,8 @@ async function saveDatasourceReferences(options: {
datasets,
assets: toInstall,
});

datasource.inputs = inputs;
// 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
Expand Down
3 changes: 2 additions & 1 deletion x-pack/legacy/plugins/ingest/server/libs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export interface Datasource extends SavedObjectAttributes {
package: Package;
read_alias?: string;
streams: Stream[];
config: string[];
// TODO: These are the input parts of the streams. To be remove again when we have the streams
inputs: string[];
}

/**
Expand Down

0 comments on commit bc42121

Please sign in to comment.