Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename kbn-es-archiver to osd-opensearch-archiver (#37) #42

Merged
merged 9 commits into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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;
}
Original file line number Diff line number Diff line change
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';
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading