Skip to content

Commit

Permalink
Rename kbn-es-archiver to osd-opensearch-archiver (#37) (#42)
Browse files Browse the repository at this point in the history
* Renames kbn-es-archiver to osd-opensearch-archiver (#37)

Signed-off-by: Bishoy Boktor <boktorbb@amazon.com>

* Renames kbn-es-archiver to osd-opensearch-archiver (#37)

Signed-off-by: Bishoy Boktor <boktorbb@amazon.com>

* Renames kbn-eslint-import-resolver-kibana to osd-eslint-import-resolver-opensearch-dashboards (#37)

Signed-off-by: Bishoy Boktor <boktorbb@amazon.com>

* Revert "Renames kbn-eslint-import-resolver-kibana to osd-eslint-import-resolver-opensearch-dashboards (#37)"

This reverts commit 2ecd071.

* Address PR comments

Signed-off-by: Bishoy Boktor <boktorbb@amazon.com>

* Revert changes to README.md in root packages folder

Signed-off-by: Bishoy Boktor <boktorbb@amazon.com>

* Address PR comments

Signed-off-by: Bishoy Boktor <boktorbb@amazon.com>

* Address PR comments

Signed-off-by: Bishoy Boktor <boktorbb@amazon.com>

* Missed an es url

Signed-off-by: Bishoy Boktor <boktorbb@amazon.com>
  • Loading branch information
boktorbb authored and mihirsoni committed Mar 20, 2021
1 parent c2b4aff commit 6e1606f
Show file tree
Hide file tree
Showing 65 changed files with 194 additions and 171 deletions.
@@ -1,17 +1,17 @@
{
"name": "@kbn/es-archiver",
"name": "@osd/opensearch-archiver",
"version": "1.0.0",
"license": "Apache-2.0",
"main": "target/index.js",
"kibana": {
"opensearchDashboards": {
"devOnly": true
},
"scripts": {
"kbn:bootstrap": "rm -rf target && tsc",
"kbn:watch": "rm -rf target && tsc --watch"
"osd:bootstrap": "rm -rf target && tsc",
"osd:watch": "rm -rf target && tsc --watch"
},
"dependencies": {
"@kbn/dev-utils": "1.0.0",
"@osd/dev-utils": "1.0.0",
"elasticsearch": "^16.7.0"
},
"devDependencies": {
Expand Down
Expand Up @@ -22,7 +22,7 @@ import Fs from 'fs';
import { createGunzip, createGzip, Z_BEST_COMPRESSION } from 'zlib';
import { promisify } from 'util';
import globby from 'globby';
import { ToolingLog } from '@kbn/dev-utils';
import { ToolingLog } from '@osd/dev-utils';

import { createPromiseFromStreams } from '../lib/streams';

Expand Down
Expand Up @@ -18,22 +18,26 @@
*/

import { Client } from 'elasticsearch';
import { ToolingLog, KbnClient } from '@kbn/dev-utils';
import { ToolingLog, OsdClient } from '@osd/dev-utils';

import { migrateKibanaIndex, deleteKibanaIndices, createStats } from '../lib';
import {
migrateOpenSearchDashboardsIndex,
deleteOpenSearchDashboardsIndices,
createStats,
} from '../lib';

export async function emptyKibanaIndexAction({
export async function emptyOpenSearchDashboardsIndexAction({
client,
log,
kbnClient,
osdClient,
}: {
client: Client;
log: ToolingLog;
kbnClient: KbnClient;
osdClient: OsdClient;
}) {
const stats = createStats('emptyKibanaIndex', log);
const stats = createStats('emptyOpenSearchDashboardsIndex', log);

await deleteKibanaIndices({ client, stats, log });
await migrateKibanaIndex({ client, kbnClient });
await deleteOpenSearchDashboardsIndices({ client, stats, log });
await migrateOpenSearchDashboardsIndex({ client, osdClient });
return stats;
}
Expand Up @@ -21,5 +21,5 @@ export { saveAction } from './save';
export { loadAction } from './load';
export { unloadAction } from './unload';
export { rebuildAllAction } from './rebuild_all';
export { emptyKibanaIndexAction } from './empty_kibana_index';
export { emptyOpenSearchDashboardsIndexAction } from './empty_opensearch_dashboards_index';
export { editAction } from './edit';
Expand Up @@ -20,7 +20,7 @@
import { resolve } from 'path';
import { createReadStream } from 'fs';
import { Readable } from 'stream';
import { ToolingLog, KbnClient } from '@kbn/dev-utils';
import { ToolingLog, OsdClient } from '@osd/dev-utils';
import { Client } from 'elasticsearch';

import { createPromiseFromStreams, concatStreamProviders } from '../lib/streams';
Expand All @@ -33,7 +33,7 @@ import {
createParseArchiveStreams,
createCreateIndexStream,
createIndexDocRecordsStream,
migrateKibanaIndex,
migrateOpenSearchDashboardsIndex,
Progress,
createDefaultSpace,
} from '../lib';
Expand All @@ -53,20 +53,20 @@ export async function loadAction({
client,
dataDir,
log,
kbnClient,
osdClient,
}: {
name: string;
skipExisting: boolean;
useCreate: boolean;
client: Client;
dataDir: string;
log: ToolingLog;
kbnClient: KbnClient;
osdClient: OsdClient;
}) {
const inputDir = resolve(dataDir, name);
const stats = createStats(name, log);
const files = prioritizeMappings(await readDirectory(inputDir));
const kibanaPluginIds = await kbnClient.plugins.getEnabledIds();
const opensearchDashboardsPluginIds = await osdClient.plugins.getEnabledIds();

// a single stream that emits records from all archive files, in
// order, so that createIndexStream can track the state of indexes
Expand Down Expand Up @@ -106,12 +106,12 @@ export async function loadAction({
allowNoIndices: true,
});

// If we affected the Kibana index, we need to ensure it's migrated...
if (Object.keys(result).some((k) => k.startsWith('.kibana'))) {
await migrateKibanaIndex({ client, kbnClient });
// If we affected the OpenSearch Dashboards index, we need to ensure it's migrated...
if (Object.keys(result).some((k) => k.startsWith('.opensearch-dashboards'))) {
await migrateOpenSearchDashboardsIndex({ client, osdClient });

if (kibanaPluginIds.includes('spaces')) {
await createDefaultSpace({ client, index: '.kibana' });
if (opensearchDashboardsPluginIds.includes('spaces')) {
await createDefaultSpace({ client, index: '.opensearch-dashboards' });
}
}

Expand Down
Expand Up @@ -21,7 +21,7 @@ import { resolve, dirname, relative } from 'path';
import { stat, Stats, rename, createReadStream, createWriteStream } from 'fs';
import { Readable, Writable } from 'stream';
import { fromNode } from 'bluebird';
import { ToolingLog } from '@kbn/dev-utils';
import { ToolingLog } from '@osd/dev-utils';

import { createPromiseFromStreams } from '../lib/streams';
import {
Expand Down
Expand Up @@ -21,7 +21,7 @@ import { resolve } from 'path';
import { createWriteStream, mkdirSync } from 'fs';
import { Readable, Writable } from 'stream';
import { Client } from 'elasticsearch';
import { ToolingLog } from '@kbn/dev-utils';
import { ToolingLog } from '@osd/dev-utils';

import { createListStream, createPromiseFromStreams } from '../lib/streams';
import {
Expand Down
Expand Up @@ -21,7 +21,7 @@ import { resolve } from 'path';
import { createReadStream } from 'fs';
import { Readable, Writable } from 'stream';
import { Client } from 'elasticsearch';
import { ToolingLog, KbnClient } from '@kbn/dev-utils';
import { ToolingLog, OsdClient } from '@osd/dev-utils';

import { createPromiseFromStreams } from '../lib/streams';
import {
Expand All @@ -39,17 +39,17 @@ export async function unloadAction({
client,
dataDir,
log,
kbnClient,
osdClient: osdClient,
}: {
name: string;
client: Client;
dataDir: string;
log: ToolingLog;
kbnClient: KbnClient;
osdClient: OsdClient;
}) {
const inputDir = resolve(dataDir, name);
const stats = createStats(name, log);
const kibanaPluginIds = await kbnClient.plugins.getEnabledIds();
const opensearchDashboardsPluginIds = await osdClient.plugins.getEnabledIds();

const files = prioritizeMappings(await readDirectory(inputDir));
for (const filename of files) {
Expand All @@ -59,7 +59,7 @@ export async function unloadAction({
createReadStream(resolve(inputDir, filename)) as Readable,
...createParseArchiveStreams({ gzip: isGzip(filename) }),
createFilterRecordsStream('index'),
createDeleteIndexStream(client, stats, log, kibanaPluginIds),
createDeleteIndexStream(client, stats, log, opensearchDashboardsPluginIds),
] as [Readable, ...Writable[]]);
}

Expand Down

0 comments on commit 6e1606f

Please sign in to comment.