Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Apr 7, 2020
1 parent d84b9f8 commit edaf515
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const registerUpdateRoute = ({
const { description, processors, version } = pipeline;

try {
// Verify pipeline exists
// Verify pipeline exists; ES will throw 404 if it doesn't
await callAsCurrentUser('ingest.getPipeline', { id: name });

const response = await callAsCurrentUser('ingest.putPipeline', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,32 @@
*/
import { FtrProviderContext } from '../../../../ftr_provider_context';

interface Processor {
[key: string]: {
[key: string]: unknown;
};
}

interface Pipeline {
id: string;
body: {
description: string;
processors: any[];
processors: Processor[];
version?: number;
};
}

/**
* Helpers to create and delete indices on the Elasticsearch instance
* Helpers to create and delete pipelines on the Elasticsearch instance
* during our tests.
* @param {ElasticsearchClient} es The Elasticsearch client instance
*/
export const registerEsHelpers = (getService: FtrProviderContext['getService']) => {
const es = getService('legacyEs');

let pipelinesCreated: Pipeline[] = [];
const createPipeline = (pipeline: Pipeline) => es.ingest.putPipeline(pipeline);

const createPipeline = (pipeline: Pipeline) => {
pipelinesCreated.push(pipeline);
return es.ingest.putPipeline(pipeline).then(() => pipeline);
};

const deletePipeline = (pipelineId: string) => {
pipelinesCreated = pipelinesCreated.filter(({ id }) => id !== pipelineId);
return es.ingest.deletePipeline({ id: pipelineId });
};
const deletePipeline = (pipelineId: string) => es.ingest.deletePipeline({ id: pipelineId });

return {
createPipeline,
Expand Down

0 comments on commit edaf515

Please sign in to comment.