Skip to content

Commit

Permalink
[FTR - esArchiver] Update the remaining "dynamic" archives, removing …
Browse files Browse the repository at this point in the history
…mappings.json (elastic#162029)

## Summary

Part of elastic#161882

- Updates the remaining "dynamic" es archives (aka those using the
`$KIBANA_PACKAGE_VERSION` variable), deleting mappings.json.
- It also removes the piece of logic in `esArchiver` that replaces that
variable.
  • Loading branch information
gsoldevila authored and Devon Thomson committed Aug 1, 2023
1 parent 66fe7a0 commit b502496
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 2,977 deletions.
24 changes: 0 additions & 24 deletions packages/kbn-es-archiver/src/lib/archives/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Stream, { PassThrough, Readable, Writable, Transform } from 'stream';
import { createGzip } from 'zlib';

import { createConcatStream, createListStream, createPromiseFromStreams } from '@kbn/utils';
import { kibanaPackageJson } from '@kbn/repo-info';

import { createParseArchiveStreams } from './parse';

Expand Down Expand Up @@ -55,17 +54,6 @@ describe('esArchiver createParseArchiveStreams', () => {
expect(output).toEqual([{ a: 1 }, 1]);
});

it('replaces $KIBANA_PACKAGE_VERSION with the current kibana version', async () => {
const output = await createPromiseFromStreams([
createListStream([
Buffer.from('{"$KIBANA'),
Buffer.from('_PACKAGE_VERSION": "enabled"}'),
]),
...createParseArchiveStreams({ gzip: false }),
]);
return expect(output).toEqual({ [kibanaPackageJson.version]: 'enabled' });
});

it('provides each JSON object as soon as it is parsed', async () => {
let onReceived: (resolved: any) => void;
const receivedPromise = new Promise((resolve) => (onReceived = resolve));
Expand Down Expand Up @@ -150,18 +138,6 @@ describe('esArchiver createParseArchiveStreams', () => {

expect(output).toEqual([{ a: 1 }, { a: 2 }]);
});

it('replaces $KIBANA_PACKAGE_VERSION with the current kibana version', async () => {
const output = await createPromiseFromStreams([
createListStream([
Buffer.from('{"$KIBANA_PACKAGE'),
Buffer.from('_VERSION": "enabled"}'),
]),
createGzip(),
...createParseArchiveStreams({ gzip: true }),
]);
return expect(output).toEqual({ [kibanaPackageJson.version]: 'enabled' });
});
});

it('parses blank files', async () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/kbn-es-archiver/src/lib/archives/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import {
createReplaceStream,
createMapStream,
} from '@kbn/utils';
import { kibanaPackageJson } from '@kbn/repo-info';

import { RECORD_SEPARATOR } from './constants';

export function createParseArchiveStreams({ gzip = false } = {}) {
return [
gzip ? createGunzip() : new PassThrough(),
createReplaceStream('\r\n', '\n'),
createReplaceStream('$KIBANA_PACKAGE_VERSION', kibanaPackageJson.version),
createSplitStream(RECORD_SEPARATOR),
createFilterStream<string>((l) => !!l.match(/[^\s]/)),
createMapStream<string>((json) => JSON.parse(json.trim())),
Expand Down
Loading

0 comments on commit b502496

Please sign in to comment.