Skip to content

Commit

Permalink
Fix fleet policy lib to use streams
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Dec 17, 2019
1 parent 25e1e42 commit ac3cd52
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 33 deletions.
17 changes: 10 additions & 7 deletions x-pack/legacy/plugins/epm/server/datasources/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ export async function createDatasource(options: {
const streams: Stream[] = [];
if (pkg.datasets) {
for (const dataset of pkg.datasets) {
streams.push({
id: dataset.name,
input: yaml.load(await getConfig(pkgkey, dataset)),
output_id: 'default',
});
const input = yaml.load(await getConfig(pkgkey, dataset));
if (input) {
streams.push({
id: dataset.name,
input,
output_id: 'default',
});
}
}
}

Expand Down Expand Up @@ -178,7 +181,7 @@ async function ingestDatasourceCreate({
const url = `${origin}${basePath}${apiPath}`;
const body = { datasource };
delete request.headers['transfer-encoding'];
return fetch(url, {
await fetch(url, {
method: 'post',
body: JSON.stringify(body),
headers: {
Expand All @@ -187,7 +190,7 @@ async function ingestDatasourceCreate({
// the main (only?) one we want is `authorization`
...request.headers,
},
}).then(response => response.json());
});
}

async function getConfig(pkgkey: string, dataset: Dataset): Promise<string> {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/fleet/server/libs/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class PolicyLib {
return flatten(
datasources.map((ds: Datasource) => {
return ds.streams.map(stream => ({
...stream.config,
...stream.input,
id: stream.id,
type: stream.input.type as any,
output: { use_output: stream.output_id },
Expand Down
2 changes: 0 additions & 2 deletions x-pack/legacy/plugins/ingest/server/libs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export interface Datasource extends SavedObjectAttributes {
package: Package;
read_alias?: string;
streams: Stream[];
// TODO: These are the input parts of the streams. To be remove again when we have the streams
inputs: string[];
}

/**
Expand Down
24 changes: 1 addition & 23 deletions x-pack/legacy/plugins/ingest/server/mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,7 @@ export const mappings = {
type: 'keyword',
},
input: {
properties: {
config: {
type: 'flattened',
},
fields: {
type: 'flattened',
},
id: {
type: 'keyword',
},
ilm_policy: {
type: 'keyword',
},
index_template: {
type: 'keyword',
},
ingest_pipelines: {
type: 'keyword',
},
type: {
type: 'keyword',
},
},
type: 'flattened',
},
output_id: {
type: 'keyword',
Expand Down

0 comments on commit ac3cd52

Please sign in to comment.