diff --git a/packages/kbn-es-archiver/package.json b/packages/osd-opensearch-archiver/package.json similarity index 56% rename from packages/kbn-es-archiver/package.json rename to packages/osd-opensearch-archiver/package.json index 645abd619590..e1c28cc47484 100644 --- a/packages/kbn-es-archiver/package.json +++ b/packages/osd-opensearch-archiver/package.json @@ -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": { diff --git a/packages/kbn-es-archiver/src/actions/edit.ts b/packages/osd-opensearch-archiver/src/actions/edit.ts similarity index 98% rename from packages/kbn-es-archiver/src/actions/edit.ts rename to packages/osd-opensearch-archiver/src/actions/edit.ts index 1194637b1ff8..83c7a7ed3e2c 100644 --- a/packages/kbn-es-archiver/src/actions/edit.ts +++ b/packages/osd-opensearch-archiver/src/actions/edit.ts @@ -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'; diff --git a/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts b/packages/osd-opensearch-archiver/src/actions/empty_opensearch_dashboards_index.ts similarity index 66% rename from packages/kbn-es-archiver/src/actions/empty_kibana_index.ts rename to packages/osd-opensearch-archiver/src/actions/empty_opensearch_dashboards_index.ts index d61d544deadc..adfc1ef918de 100644 --- a/packages/kbn-es-archiver/src/actions/empty_kibana_index.ts +++ b/packages/osd-opensearch-archiver/src/actions/empty_opensearch_dashboards_index.ts @@ -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; } diff --git a/packages/kbn-es-archiver/src/actions/index.ts b/packages/osd-opensearch-archiver/src/actions/index.ts similarity index 91% rename from packages/kbn-es-archiver/src/actions/index.ts rename to packages/osd-opensearch-archiver/src/actions/index.ts index b49a65fa3e5a..f2aae4777467 100644 --- a/packages/kbn-es-archiver/src/actions/index.ts +++ b/packages/osd-opensearch-archiver/src/actions/index.ts @@ -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'; diff --git a/packages/kbn-es-archiver/src/actions/load.ts b/packages/osd-opensearch-archiver/src/actions/load.ts similarity index 84% rename from packages/kbn-es-archiver/src/actions/load.ts rename to packages/osd-opensearch-archiver/src/actions/load.ts index efb1fe9f9ea5..d68c5f7b40a0 100644 --- a/packages/kbn-es-archiver/src/actions/load.ts +++ b/packages/osd-opensearch-archiver/src/actions/load.ts @@ -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'; @@ -33,7 +33,7 @@ import { createParseArchiveStreams, createCreateIndexStream, createIndexDocRecordsStream, - migrateKibanaIndex, + migrateOpenSearchDashboardsIndex, Progress, createDefaultSpace, } from '../lib'; @@ -53,7 +53,7 @@ export async function loadAction({ client, dataDir, log, - kbnClient, + osdClient, }: { name: string; skipExisting: boolean; @@ -61,12 +61,12 @@ export async function loadAction({ 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 @@ -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' }); } } diff --git a/packages/kbn-es-archiver/src/actions/rebuild_all.ts b/packages/osd-opensearch-archiver/src/actions/rebuild_all.ts similarity index 98% rename from packages/kbn-es-archiver/src/actions/rebuild_all.ts rename to packages/osd-opensearch-archiver/src/actions/rebuild_all.ts index 470a566a6eef..7ce3825d9c36 100644 --- a/packages/kbn-es-archiver/src/actions/rebuild_all.ts +++ b/packages/osd-opensearch-archiver/src/actions/rebuild_all.ts @@ -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 { diff --git a/packages/kbn-es-archiver/src/actions/save.ts b/packages/osd-opensearch-archiver/src/actions/save.ts similarity index 98% rename from packages/kbn-es-archiver/src/actions/save.ts rename to packages/osd-opensearch-archiver/src/actions/save.ts index 84a0ce09936d..0da33a6a8c90 100644 --- a/packages/kbn-es-archiver/src/actions/save.ts +++ b/packages/osd-opensearch-archiver/src/actions/save.ts @@ -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 { diff --git a/packages/kbn-es-archiver/src/actions/unload.ts b/packages/osd-opensearch-archiver/src/actions/unload.ts similarity index 87% rename from packages/kbn-es-archiver/src/actions/unload.ts rename to packages/osd-opensearch-archiver/src/actions/unload.ts index ae23ef21fb79..fc8355b359b5 100644 --- a/packages/kbn-es-archiver/src/actions/unload.ts +++ b/packages/osd-opensearch-archiver/src/actions/unload.ts @@ -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 { @@ -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) { @@ -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[]]); } diff --git a/packages/kbn-es-archiver/src/cli.ts b/packages/osd-opensearch-archiver/src/cli.ts similarity index 69% rename from packages/kbn-es-archiver/src/cli.ts rename to packages/osd-opensearch-archiver/src/cli.ts index 87df07fe865b..7d0b4ba0069c 100644 --- a/packages/kbn-es-archiver/src/cli.ts +++ b/packages/osd-opensearch-archiver/src/cli.ts @@ -27,25 +27,25 @@ import Path from 'path'; import Url from 'url'; import readline from 'readline'; -import { RunWithCommands, createFlagError } from '@kbn/dev-utils'; -import { readConfigFile } from '@kbn/test'; +import { RunWithCommands, createFlagError } from '@osd/dev-utils'; +import { readConfigFile } from '@osd/test'; import legacyElasticsearch from 'elasticsearch'; -import { EsArchiver } from './es_archiver'; +import { OpenSearchArchiver } from './opensearch_archiver'; const resolveConfigPath = (v: string) => Path.resolve(process.cwd(), v); const defaultConfigPath = resolveConfigPath('test/functional/config.js'); export function runCli() { new RunWithCommands({ - description: 'CLI to manage archiving/restoring data in elasticsearch', + description: 'CLI to manage archiving/restoring data in opensearch', globalFlags: { - string: ['es-url', 'kibana-url', 'dir', 'config'], + string: ['opensearch-url', 'opensearch-dashboards-url', 'dir', 'config'], help: ` - --config path to an FTR config file that sets --es-url, --kibana-url, and --dir + --config path to an FTR config file that sets --opensearch-url, --opensearch-dashboards-url, and --dir default: ${defaultConfigPath} - --es-url url for Elasticsearch, prefer the --config flag - --kibana-url url for Kibana, prefer the --config flag + --opensearch-url url for OpenSearch, prefer the --config flag + --opensearch-dashboards-url url for OpenSearch Dashboards, prefer the --config flag --dir where arechives are stored, prefer the --config flag `, }, @@ -56,26 +56,26 @@ export function runCli() { } const config = await readConfigFile(log, Path.resolve(configPath)); - let esUrl = flags['es-url']; - if (esUrl && typeof esUrl !== 'string') { - throw createFlagError('--es-url must be a string'); + let opensearchUrl = flags['opensearch-url']; + if (opensearchUrl && typeof opensearchUrl !== 'string') { + throw createFlagError('--opensearch-url must be a string'); } - if (!esUrl && config) { - esUrl = Url.format(config.get('servers.elasticsearch')); + if (!opensearchUrl && config) { + opensearchUrl = Url.format(config.get('servers.opensearch')); } - if (!esUrl) { - throw createFlagError('--es-url or --config must be defined'); + if (!opensearchUrl) { + throw createFlagError('--opensearch-url or --config must be defined'); } - let kibanaUrl = flags['kibana-url']; - if (kibanaUrl && typeof kibanaUrl !== 'string') { - throw createFlagError('--kibana-url must be a string'); + let opensearchDashboardsUrl = flags['opensearch-dashboards-url']; + if (opensearchDashboardsUrl && typeof opensearchDashboardsUrl !== 'string') { + throw createFlagError('--opensearch-dashboards-url must be a string'); } - if (!kibanaUrl && config) { - kibanaUrl = Url.format(config.get('servers.kibana')); + if (!opensearchDashboardsUrl && config) { + opensearchDashboardsUrl = Url.format(config.get('servers.opensearchDashboards')); } - if (!kibanaUrl) { - throw createFlagError('--kibana-url or --config must be defined'); + if (!opensearchDashboardsUrl) { + throw createFlagError('---url or --config must be defined'); } let dir = flags.dir; @@ -83,27 +83,27 @@ export function runCli() { throw createFlagError('--dir must be a string'); } if (!dir && config) { - dir = Path.resolve(config.get('esArchiver.directory')); + dir = Path.resolve(config.get('opensearchArchiver.directory')); } if (!dir) { throw createFlagError('--dir or --config must be defined'); } const client = new legacyElasticsearch.Client({ - host: esUrl, + host: opensearchUrl, log: flags.verbose ? 'trace' : [], }); addCleanupTask(() => client.close()); - const esArchiver = new EsArchiver({ + const opensearchArchiver = new OpenSearchArchiver({ log, client, dataDir: dir, - kibanaUrl, + opensearchDashboardsUrl, }); return { - esArchiver, + opensearchArchiver, }; }, }) @@ -118,7 +118,7 @@ export function runCli() { WARNING: If the [my_test_data] snapshot exists it will be deleted! - $ node scripts/es_archiver save my_test_data logstash-* --dir snapshots + $ node scripts/opensearch_archiver save my_test_data logstash-* --dir snapshots `, flags: { boolean: ['raw'], @@ -128,7 +128,7 @@ export function runCli() { --query query object to limit the documents being archived, needs to be properly escaped JSON `, }, - async run({ flags, esArchiver }) { + async run({ flags, opensearchArchiver }) { const [name, ...indices] = flags._; if (!name) { throw createFlagError('missing [name] argument'); @@ -152,7 +152,7 @@ export function runCli() { } } - await esArchiver.save(name, indices, { raw, query: parsedQuery }); + await opensearchArchiver.save(name, indices, { raw, query: parsedQuery }); }, }) .command({ @@ -162,12 +162,12 @@ export function runCli() { load the archive in --dir with [name] Example: - Load the [my_test_data] snapshot from the archive directory and elasticsearch instance defined + Load the [my_test_data] snapshot from the archive directory and opensearch instance defined in the [test/functional/config.js] config file WARNING: If the indices exist already they will be deleted! - $ node scripts/es_archiver load my_test_data --config test/functional/config.js + $ node scripts/opensearch_archiver load my_test_data --config test/functional/config.js `, flags: { boolean: ['use-create'], @@ -175,7 +175,7 @@ export function runCli() { --use-create use create instead of index for loading documents `, }, - async run({ flags, esArchiver }) { + async run({ flags, opensearchArchiver }) { const [name] = flags._; if (!name) { throw createFlagError('missing [name] argument'); @@ -189,14 +189,14 @@ export function runCli() { throw createFlagError('--use-create does not take a value'); } - await esArchiver.load(name, { useCreate }); + await opensearchArchiver.load(name, { useCreate }); }, }) .command({ name: 'unload', usage: 'unload [name]', description: 'remove indices created by the archive in --dir with [name]', - async run({ flags, esArchiver }) { + async run({ flags, opensearchArchiver }) { const [name] = flags._; if (!name) { throw createFlagError('missing [name] argument'); @@ -205,7 +205,7 @@ export function runCli() { throw createFlagError(`unknown extra arguments: [${flags._.slice(1).join(', ')}]`); } - await esArchiver.unload(name); + await opensearchArchiver.unload(name); }, }) .command({ @@ -213,7 +213,7 @@ export function runCli() { usage: 'edit [prefix]', description: 'extract the archives under the prefix, wait for edits to be completed, and then recompress the archives', - async run({ flags, esArchiver }) { + async run({ flags, opensearchArchiver }) { const [prefix] = flags._; if (!prefix) { throw createFlagError('missing [prefix] argument'); @@ -222,7 +222,7 @@ export function runCli() { throw createFlagError(`unknown extra arguments: [${flags._.slice(1).join(', ')}]`); } - await esArchiver.edit(prefix, async () => { + await opensearchArchiver.edit(prefix, async () => { const rl = readline.createInterface({ input: process.stdin, output: process.stdout, @@ -238,18 +238,18 @@ export function runCli() { }, }) .command({ - name: 'empty-kibana-index', + name: 'empty-opensearch-dashboards-index', description: - '[internal] Delete any Kibana indices, and initialize the Kibana index as Kibana would do on startup.', - async run({ esArchiver }) { - await esArchiver.emptyKibanaIndex(); + '[internal] Delete any OpenSearch Dashboards indices, and initialize the OpenSearch Dashboards index as OpenSearch Dashboards would do on startup.', + async run({ opensearchArchiver }) { + await opensearchArchiver.emptyOpenSearchDashboardsIndex(); }, }) .command({ name: 'rebuild-all', description: '[internal] read and write all archives in --dir to remove any inconsistencies', - async run({ esArchiver }) { - await esArchiver.rebuildAll(); + async run({ opensearchArchiver }) { + await opensearchArchiver.rebuildAll(); }, }) .execute(); diff --git a/packages/kbn-es-archiver/src/index.ts b/packages/osd-opensearch-archiver/src/index.ts similarity index 93% rename from packages/kbn-es-archiver/src/index.ts rename to packages/osd-opensearch-archiver/src/index.ts index c00d457c939c..2c804fc63de4 100644 --- a/packages/kbn-es-archiver/src/index.ts +++ b/packages/osd-opensearch-archiver/src/index.ts @@ -17,5 +17,5 @@ * under the License. */ -export { EsArchiver } from './es_archiver'; +export { OpenSearchArchiver } from './opensearch_archiver'; export * from './cli'; diff --git a/packages/kbn-es-archiver/src/lib/__tests__/stats.ts b/packages/osd-opensearch-archiver/src/lib/__tests__/stats.ts similarity index 98% rename from packages/kbn-es-archiver/src/lib/__tests__/stats.ts rename to packages/osd-opensearch-archiver/src/lib/__tests__/stats.ts index 0ab7d161feb6..2b4925e460f7 100644 --- a/packages/kbn-es-archiver/src/lib/__tests__/stats.ts +++ b/packages/osd-opensearch-archiver/src/lib/__tests__/stats.ts @@ -19,8 +19,8 @@ import { uniq } from 'lodash'; import sinon from 'sinon'; -import expect from '@kbn/expect'; -import { ToolingLog } from '@kbn/dev-utils'; +import expect from '@osd/expect'; +import { ToolingLog } from '@osd/dev-utils'; import { createStats } from '../'; @@ -62,7 +62,7 @@ function assertDeepClones(a: any, b: any) { } } -describe('esArchiver: Stats', () => { +describe('opensearchArchiver: Stats', () => { describe('#skippedIndex(index)', () => { it('marks the index as skipped', () => { const stats = createStats('name', new ToolingLog()); diff --git a/packages/kbn-es-archiver/src/lib/archives/__tests__/format.ts b/packages/osd-opensearch-archiver/src/lib/archives/__tests__/format.ts similarity index 97% rename from packages/kbn-es-archiver/src/lib/archives/__tests__/format.ts rename to packages/osd-opensearch-archiver/src/lib/archives/__tests__/format.ts index 044a0e82d9df..1fdd9ca8d92d 100644 --- a/packages/kbn-es-archiver/src/lib/archives/__tests__/format.ts +++ b/packages/osd-opensearch-archiver/src/lib/archives/__tests__/format.ts @@ -20,7 +20,7 @@ import Stream, { Readable, Writable } from 'stream'; import { createGunzip } from 'zlib'; -import expect from '@kbn/expect'; +import expect from '@osd/expect'; import { createListStream, createPromiseFromStreams, createConcatStream } from '../../streams'; @@ -29,7 +29,7 @@ import { createFormatArchiveStreams } from '../format'; const INPUTS = [1, 2, { foo: 'bar' }, [1, 2]]; const INPUT_JSON = INPUTS.map((i) => JSON.stringify(i, null, 2)).join('\n\n'); -describe('esArchiver createFormatArchiveStreams', () => { +describe('opensearchArchiver createFormatArchiveStreams', () => { describe('{ gzip: false }', () => { it('returns an array of streams', () => { const streams = createFormatArchiveStreams({ gzip: false }); diff --git a/packages/kbn-es-archiver/src/lib/archives/__tests__/parse.ts b/packages/osd-opensearch-archiver/src/lib/archives/__tests__/parse.ts similarity index 98% rename from packages/kbn-es-archiver/src/lib/archives/__tests__/parse.ts rename to packages/osd-opensearch-archiver/src/lib/archives/__tests__/parse.ts index 25b8fe46a81f..97d47799f35d 100644 --- a/packages/kbn-es-archiver/src/lib/archives/__tests__/parse.ts +++ b/packages/osd-opensearch-archiver/src/lib/archives/__tests__/parse.ts @@ -20,13 +20,13 @@ import Stream, { PassThrough, Readable, Writable, Transform } from 'stream'; import { createGzip } from 'zlib'; -import expect from '@kbn/expect'; +import expect from '@osd/expect'; import { createConcatStream, createListStream, createPromiseFromStreams } from '../../streams'; import { createParseArchiveStreams } from '../parse'; -describe('esArchiver createParseArchiveStreams', () => { +describe('opensearchArchiver createParseArchiveStreams', () => { describe('{ gzip: false }', () => { it('returns an array of streams', () => { const streams = createParseArchiveStreams({ gzip: false }); diff --git a/packages/kbn-es-archiver/src/lib/archives/constants.ts b/packages/osd-opensearch-archiver/src/lib/archives/constants.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/archives/constants.ts rename to packages/osd-opensearch-archiver/src/lib/archives/constants.ts diff --git a/packages/kbn-es-archiver/src/lib/archives/filenames.ts b/packages/osd-opensearch-archiver/src/lib/archives/filenames.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/archives/filenames.ts rename to packages/osd-opensearch-archiver/src/lib/archives/filenames.ts diff --git a/packages/kbn-es-archiver/src/lib/archives/format.ts b/packages/osd-opensearch-archiver/src/lib/archives/format.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/archives/format.ts rename to packages/osd-opensearch-archiver/src/lib/archives/format.ts diff --git a/packages/kbn-es-archiver/src/lib/archives/index.ts b/packages/osd-opensearch-archiver/src/lib/archives/index.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/archives/index.ts rename to packages/osd-opensearch-archiver/src/lib/archives/index.ts diff --git a/packages/kbn-es-archiver/src/lib/archives/parse.ts b/packages/osd-opensearch-archiver/src/lib/archives/parse.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/archives/parse.ts rename to packages/osd-opensearch-archiver/src/lib/archives/parse.ts diff --git a/packages/kbn-es-archiver/src/lib/directory.ts b/packages/osd-opensearch-archiver/src/lib/directory.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/directory.ts rename to packages/osd-opensearch-archiver/src/lib/directory.ts diff --git a/packages/kbn-es-archiver/src/lib/docs/__tests__/generate_doc_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/docs/__tests__/generate_doc_records_stream.ts similarity index 94% rename from packages/kbn-es-archiver/src/lib/docs/__tests__/generate_doc_records_stream.ts rename to packages/osd-opensearch-archiver/src/lib/docs/__tests__/generate_doc_records_stream.ts index 3c5fc742a6e1..742496c1e1e5 100644 --- a/packages/kbn-es-archiver/src/lib/docs/__tests__/generate_doc_records_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/docs/__tests__/generate_doc_records_stream.ts @@ -18,7 +18,7 @@ */ import sinon from 'sinon'; -import expect from '@kbn/expect'; +import expect from '@osd/expect'; import { delay } from 'bluebird'; import { createListStream, createPromiseFromStreams, createConcatStream } from '../../streams'; @@ -27,7 +27,7 @@ import { createGenerateDocRecordsStream } from '../generate_doc_records_stream'; import { Progress } from '../../progress'; import { createStubStats, createStubClient } from './stubs'; -describe('esArchiver: createGenerateDocRecordsStream()', () => { +describe('opensearchArchiver: createGenerateDocRecordsStream()', () => { it('scolls 1000 documents at a time', async () => { const stats = createStubStats(); const client = createStubClient([ @@ -91,7 +91,7 @@ describe('esArchiver: createGenerateDocRecordsStream()', () => { await delay(200); return { _scroll_id: 'index1ScrollId', - hits: { total: 2, hits: [{ _id: 1, _index: '.kibana_foo' }] }, + hits: { total: 2, hits: [{ _id: 1, _index: '.opensearch-dashboards_foo' }] }, }; }, async (name, params) => { @@ -123,7 +123,7 @@ describe('esArchiver: createGenerateDocRecordsStream()', () => { { type: 'doc', value: { - index: '.kibana_1', + index: '.opensearch-dashboards_1', type: undefined, id: 1, source: undefined, diff --git a/packages/kbn-es-archiver/src/lib/docs/__tests__/index_doc_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/docs/__tests__/index_doc_records_stream.ts similarity index 99% rename from packages/kbn-es-archiver/src/lib/docs/__tests__/index_doc_records_stream.ts rename to packages/osd-opensearch-archiver/src/lib/docs/__tests__/index_doc_records_stream.ts index 08bf7f28a44f..3ec34ca62034 100644 --- a/packages/kbn-es-archiver/src/lib/docs/__tests__/index_doc_records_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/docs/__tests__/index_doc_records_stream.ts @@ -17,7 +17,7 @@ * under the License. */ -import expect from '@kbn/expect'; +import expect from '@osd/expect'; import { delay } from 'bluebird'; import { createListStream, createPromiseFromStreams } from '../../streams'; diff --git a/packages/kbn-es-archiver/src/lib/docs/__tests__/stubs.ts b/packages/osd-opensearch-archiver/src/lib/docs/__tests__/stubs.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/docs/__tests__/stubs.ts rename to packages/osd-opensearch-archiver/src/lib/docs/__tests__/stubs.ts diff --git a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/docs/generate_doc_records_stream.ts similarity index 91% rename from packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts rename to packages/osd-opensearch-archiver/src/lib/docs/generate_doc_records_stream.ts index 87c166fe275c..68778f43c7d1 100644 --- a/packages/kbn-es-archiver/src/lib/docs/generate_doc_records_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/docs/generate_doc_records_stream.ts @@ -71,9 +71,11 @@ export function createGenerateDocRecordsStream({ this.push({ type: 'doc', value: { - // always rewrite the .kibana_* index to .kibana_1 so that + // always rewrite the .opensearch-dashboards_* index to .opensearch-dashboards_1 so that // when it is loaded it can skip migration, if possible - index: hit._index.startsWith('.kibana') ? '.kibana_1' : hit._index, + index: hit._index.startsWith('.opensearch-dashboards') + ? '.opensearch-dashboards_1' + : hit._index, type: hit._type, id: hit._id, source: hit._source, diff --git a/packages/kbn-es-archiver/src/lib/docs/index.ts b/packages/osd-opensearch-archiver/src/lib/docs/index.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/docs/index.ts rename to packages/osd-opensearch-archiver/src/lib/docs/index.ts diff --git a/packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/docs/index_doc_records_stream.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/docs/index_doc_records_stream.ts rename to packages/osd-opensearch-archiver/src/lib/docs/index_doc_records_stream.ts diff --git a/packages/kbn-es-archiver/src/lib/index.ts b/packages/osd-opensearch-archiver/src/lib/index.ts similarity index 94% rename from packages/kbn-es-archiver/src/lib/index.ts rename to packages/osd-opensearch-archiver/src/lib/index.ts index 960d51e41185..254b36fe32da 100644 --- a/packages/kbn-es-archiver/src/lib/index.ts +++ b/packages/osd-opensearch-archiver/src/lib/index.ts @@ -23,8 +23,8 @@ export { createCreateIndexStream, createDeleteIndexStream, createGenerateIndexRecordsStream, - deleteKibanaIndices, - migrateKibanaIndex, + deleteOpenSearchDashboardsIndices, + migrateOpenSearchDashboardsIndex, createDefaultSpace, } from './indices'; diff --git a/packages/kbn-es-archiver/src/lib/indices/__tests__/create_index_stream.ts b/packages/osd-opensearch-archiver/src/lib/indices/__tests__/create_index_stream.ts similarity index 98% rename from packages/kbn-es-archiver/src/lib/indices/__tests__/create_index_stream.ts rename to packages/osd-opensearch-archiver/src/lib/indices/__tests__/create_index_stream.ts index 8f79cac6daae..071a411676f1 100644 --- a/packages/kbn-es-archiver/src/lib/indices/__tests__/create_index_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/__tests__/create_index_stream.ts @@ -17,7 +17,7 @@ * under the License. */ -import expect from '@kbn/expect'; +import expect from '@osd/expect'; import sinon from 'sinon'; import Chance from 'chance'; @@ -37,7 +37,7 @@ const chance = new Chance(); const log = createStubLogger(); -describe('esArchiver: createCreateIndexStream()', () => { +describe('opensearchArchiver: createCreateIndexStream()', () => { describe('defaults', () => { it('deletes existing indices, creates all', async () => { const client = createStubClient(['existing-index']); diff --git a/packages/kbn-es-archiver/src/lib/indices/__tests__/delete_index_stream.ts b/packages/osd-opensearch-archiver/src/lib/indices/__tests__/delete_index_stream.ts similarity index 97% rename from packages/kbn-es-archiver/src/lib/indices/__tests__/delete_index_stream.ts rename to packages/osd-opensearch-archiver/src/lib/indices/__tests__/delete_index_stream.ts index 551b744415c8..1e91eb706f22 100644 --- a/packages/kbn-es-archiver/src/lib/indices/__tests__/delete_index_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/__tests__/delete_index_stream.ts @@ -32,7 +32,7 @@ import { const log = createStubLogger(); -describe('esArchiver: createDeleteIndexStream()', () => { +describe('opensearchArchiver: createDeleteIndexStream()', () => { it('deletes the index without checking if it exists', async () => { const stats = createStubStats(); const client = createStubClient([]); diff --git a/packages/kbn-es-archiver/src/lib/indices/__tests__/generate_index_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/indices/__tests__/generate_index_records_stream.ts similarity index 97% rename from packages/kbn-es-archiver/src/lib/indices/__tests__/generate_index_records_stream.ts rename to packages/osd-opensearch-archiver/src/lib/indices/__tests__/generate_index_records_stream.ts index cb3746c015da..5731fc2feb5b 100644 --- a/packages/kbn-es-archiver/src/lib/indices/__tests__/generate_index_records_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/__tests__/generate_index_records_stream.ts @@ -18,7 +18,7 @@ */ import sinon from 'sinon'; -import expect from '@kbn/expect'; +import expect from '@osd/expect'; import { createListStream, createPromiseFromStreams, createConcatStream } from '../../streams'; @@ -26,7 +26,7 @@ import { createStubClient, createStubStats } from './stubs'; import { createGenerateIndexRecordsStream } from '../generate_index_records_stream'; -describe('esArchiver: createGenerateIndexRecordsStream()', () => { +describe('opensearchArchiver: createGenerateIndexRecordsStream()', () => { it('consumes index names and queries for the mapping of each', async () => { const indices = ['index1', 'index2', 'index3', 'index4']; const stats = createStubStats(); diff --git a/packages/kbn-es-archiver/src/lib/indices/__tests__/stubs.ts b/packages/osd-opensearch-archiver/src/lib/indices/__tests__/stubs.ts similarity index 90% rename from packages/kbn-es-archiver/src/lib/indices/__tests__/stubs.ts rename to packages/osd-opensearch-archiver/src/lib/indices/__tests__/stubs.ts index c894468dcfcf..079444ed1b32 100644 --- a/packages/kbn-es-archiver/src/lib/indices/__tests__/stubs.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/__tests__/stubs.ts @@ -19,7 +19,7 @@ import { Client } from 'elasticsearch'; import sinon from 'sinon'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { Stats } from '../../stats'; type StubStats = Stats & { @@ -63,8 +63,8 @@ export const createStubDocRecord = (index: string, id: number) => ({ value: { index, id }, }); -const createEsClientError = (errorType: string) => { - const err = new Error(`ES Client Error Stub "${errorType}"`); +const createOpenSearchClientError = (errorType: string) => { + const err = new Error(`OpenSearch Client Error Stub "${errorType}"`); (err as any).body = { error: { type: errorType, @@ -86,7 +86,7 @@ export const createStubClient = ( indices: { get: sinon.spy(async ({ index }) => { if (!existingIndices.includes(index)) { - throw createEsClientError('index_not_found_exception'); + throw createOpenSearchClientError('index_not_found_exception'); } return { @@ -115,7 +115,7 @@ export const createStubClient = ( body.actions.forEach( ({ add: { index, alias } }: { add: { index: string; alias: string } }) => { if (!existingIndices.includes(index)) { - throw createEsClientError('index_not_found_exception'); + throw createOpenSearchClientError('index_not_found_exception'); } existingIndices.push({ index, alias } as any); } @@ -125,7 +125,7 @@ export const createStubClient = ( }), create: sinon.spy(async ({ index }) => { if (existingIndices.includes(index) || aliases.hasOwnProperty(index)) { - throw createEsClientError('resource_already_exists_exception'); + throw createOpenSearchClientError('resource_already_exists_exception'); } else { existingIndices.push(index); return { ok: true }; @@ -144,7 +144,7 @@ export const createStubClient = ( indices.forEach((ix) => existingIndices.splice(existingIndices.indexOf(ix), 1)); return { ok: true }; } else { - throw createEsClientError('index_not_found_exception'); + throw createOpenSearchClientError('index_not_found_exception'); } }), exists: sinon.spy(async () => { diff --git a/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts b/packages/osd-opensearch-archiver/src/lib/indices/create_index_stream.ts similarity index 83% rename from packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts rename to packages/osd-opensearch-archiver/src/lib/indices/create_index_stream.ts index 1c8df90a5abc..7b7a513ed8cc 100644 --- a/packages/kbn-es-archiver/src/lib/indices/create_index_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/create_index_stream.ts @@ -21,10 +21,10 @@ import { Transform, Readable } from 'stream'; import { inspect } from 'util'; import { Client } from 'elasticsearch'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { Stats } from '../stats'; -import { deleteKibanaIndices } from './kibana_index'; +import { deleteOpenSearchDashboardsIndices } from './opensearch_dashboards_index'; import { deleteIndex } from './delete_index'; interface DocRecord { @@ -50,10 +50,10 @@ export function createCreateIndexStream({ }) { const skipDocsFromIndices = new Set(); - // If we're trying to import Kibana index docs, we need to ensure that + // If we're trying to import OpenSearch Dashboards index docs, we need to ensure that // previous indices are removed so we're starting w/ a clean slate for // migrations. This only needs to be done once per archive load operation. - let kibanaIndexAlreadyDeleted = false; + let opensearchDashboardsIndexAlreadyDeleted = false; async function handleDoc(stream: Readable, record: DocRecord) { if (skipDocsFromIndices.has(record.value.index)) { @@ -68,13 +68,13 @@ export function createCreateIndexStream({ // Determine if the mapping belongs to a pre-7.0 instance, for BWC tests, mainly const isPre7Mapping = !!mappings && Object.keys(mappings).length > 0 && !mappings.properties; - const isKibana = index.startsWith('.kibana'); + const isOpenSearchDashboards = index.startsWith('.opensearch-dashboards'); async function attemptToCreate(attemptNumber = 1) { try { - if (isKibana && !kibanaIndexAlreadyDeleted) { - await deleteKibanaIndices({ client, stats, log }); - kibanaIndexAlreadyDeleted = true; + if (isOpenSearchDashboards && !opensearchDashboardsIndexAlreadyDeleted) { + await deleteOpenSearchDashboardsIndices({ client, stats, log }); + opensearchDashboardsIndexAlreadyDeleted = true; } await client.indices.create({ @@ -94,10 +94,10 @@ export function createCreateIndexStream({ err?.body?.error?.reason?.includes('index exists with the same name as the alias') && attemptNumber < 3 ) { - kibanaIndexAlreadyDeleted = false; + opensearchDashboardsIndexAlreadyDeleted = false; const aliasStr = inspect(aliases); log.info( - `failed to create aliases [${aliasStr}] because ES indicated an index/alias already exists, trying again` + `failed to create aliases [${aliasStr}] because OpenSearch indicated an index/alias already exists, trying again` ); await attemptToCreate(attemptNumber + 1); return; diff --git a/packages/kbn-es-archiver/src/lib/indices/delete_index.ts b/packages/osd-opensearch-archiver/src/lib/indices/delete_index.ts similarity index 98% rename from packages/kbn-es-archiver/src/lib/indices/delete_index.ts rename to packages/osd-opensearch-archiver/src/lib/indices/delete_index.ts index d7ef20b072b2..775f5ce4ec2e 100644 --- a/packages/kbn-es-archiver/src/lib/indices/delete_index.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/delete_index.ts @@ -19,7 +19,7 @@ import { get } from 'lodash'; import { Client } from 'elasticsearch'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { Stats } from '../stats'; // see https://github.com/elastic/elasticsearch/blob/99f88f15c5febbca2d13b5b5fda27b844153bf1a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java#L313-L319 diff --git a/packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts b/packages/osd-opensearch-archiver/src/lib/indices/delete_index_stream.ts similarity index 79% rename from packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts rename to packages/osd-opensearch-archiver/src/lib/indices/delete_index_stream.ts index b4e1e530e1f8..b0d57c95c900 100644 --- a/packages/kbn-es-archiver/src/lib/indices/delete_index_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/delete_index_stream.ts @@ -19,17 +19,17 @@ import { Transform } from 'stream'; import { Client } from 'elasticsearch'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { Stats } from '../stats'; import { deleteIndex } from './delete_index'; -import { cleanKibanaIndices } from './kibana_index'; +import { cleanOpenSearchDashboardsIndices } from './opensearch_dashboards_index'; export function createDeleteIndexStream( client: Client, stats: Stats, log: ToolingLog, - kibanaPluginIds: string[] + opensearchDashboardsPluginIds: string[] ) { return new Transform({ readableObjectMode: true, @@ -39,8 +39,13 @@ export function createDeleteIndexStream( if (!record || record.type === 'index') { const { index } = record.value; - if (index.startsWith('.kibana')) { - await cleanKibanaIndices({ client, stats, log, kibanaPluginIds }); + if (index.startsWith('.opensearch-dashboards')) { + await cleanOpenSearchDashboardsIndices({ + client, + stats, + log, + opensearchDashboardsPluginIds, + }); } else { await deleteIndex({ client, stats, log, index }); } diff --git a/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/indices/generate_index_records_stream.ts similarity index 90% rename from packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts rename to packages/osd-opensearch-archiver/src/lib/indices/generate_index_records_stream.ts index 07ee1420741c..fd0bd130c202 100644 --- a/packages/kbn-es-archiver/src/lib/indices/generate_index_records_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/generate_index_records_stream.ts @@ -53,9 +53,11 @@ export function createGenerateIndexRecordsStream(client: Client, stats: Stats) { this.push({ type: 'index', value: { - // always rewrite the .kibana_* index to .kibana_1 so that + // always rewrite the .opensearch-dashboards_* index to .opensearch-dashboards_1 so that // when it is loaded it can skip migration, if possible - index: index.startsWith('.kibana') ? '.kibana_1' : index, + index: index.startsWith('.opensearch-dashboards') + ? '.opensearch-dashboards_1' + : index, settings, mappings, aliases, diff --git a/packages/kbn-es-archiver/src/lib/indices/index.ts b/packages/osd-opensearch-archiver/src/lib/indices/index.ts similarity index 87% rename from packages/kbn-es-archiver/src/lib/indices/index.ts rename to packages/osd-opensearch-archiver/src/lib/indices/index.ts index 289ac87feb9a..528e70ebb248 100644 --- a/packages/kbn-es-archiver/src/lib/indices/index.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/index.ts @@ -20,4 +20,8 @@ export { createCreateIndexStream } from './create_index_stream'; export { createDeleteIndexStream } from './delete_index_stream'; export { createGenerateIndexRecordsStream } from './generate_index_records_stream'; -export { migrateKibanaIndex, deleteKibanaIndices, createDefaultSpace } from './kibana_index'; +export { + migrateOpenSearchDashboardsIndex, + deleteOpenSearchDashboardsIndices, + createDefaultSpace, +} from './opensearch_dashboards_index'; diff --git a/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts b/packages/osd-opensearch-archiver/src/lib/indices/opensearch_dashboards_index.ts similarity index 62% rename from packages/kbn-es-archiver/src/lib/indices/kibana_index.ts rename to packages/osd-opensearch-archiver/src/lib/indices/opensearch_dashboards_index.ts index a30cf3865a10..439ea0168391 100644 --- a/packages/kbn-es-archiver/src/lib/indices/kibana_index.ts +++ b/packages/osd-opensearch-archiver/src/lib/indices/opensearch_dashboards_index.ts @@ -18,14 +18,14 @@ */ import { Client, CreateDocumentParams } from 'elasticsearch'; -import { ToolingLog, KbnClient } from '@kbn/dev-utils'; +import { ToolingLog, OsdClient } from '@osd/dev-utils'; import { Stats } from '../stats'; import { deleteIndex } from './delete_index'; /** - * Deletes all indices that start with `.kibana` + * Deletes all indices that start with `.opensearch-dashboards` */ -export async function deleteKibanaIndices({ +export async function deleteOpenSearchDashboardsIndices({ client, stats, log, @@ -34,7 +34,7 @@ export async function deleteKibanaIndices({ stats: Stats; log: ToolingLog; }) { - const indexNames = await fetchKibanaIndices(client); + const indexNames = await fetchOpenSearchDashboardsIndices(client); if (!indexNames.length) { return; } @@ -55,54 +55,60 @@ export async function deleteKibanaIndices({ } /** - * Given an elasticsearch client, and a logger, migrates the `.kibana` index. This - * builds up an object that implements just enough of the kbnMigrations interface + * Given an opensearch client, and a logger, migrates the `.opensearch-dashboards` index. This + * builds up an object that implements just enough of the osdMigrations interface * as is required by migrations. */ -export async function migrateKibanaIndex({ +export async function migrateOpenSearchDashboardsIndex({ client, - kbnClient, + osdClient, }: { client: Client; - kbnClient: KbnClient; + osdClient: OsdClient; }) { // we allow dynamic mappings on the index, as some interceptors are accessing documents before // the migration is actually performed. The migrator will put the value back to `strict` after migration. await client.indices.putMapping({ - index: '.kibana', + index: '.opensearch-dashboards', body: { dynamic: true, }, } as any); - await kbnClient.savedObjects.migrate(); + await osdClient.savedObjects.migrate(); } /** - * Migrations mean that the Kibana index will look something like: - * .kibana, .kibana_1, .kibana_323, etc. This finds all indices starting - * with .kibana, then filters out any that aren't actually Kibana's core - * index (e.g. we don't want to remove .kibana_task_manager or the like). + * Migrations mean that the OpenSearch Dashboards index will look something like: + * .opensearch-dashboards, .opensearch-dashboards_1, .opensearch-dashboards_323, etc. This finds all indices starting + * with .opensearch-dashboards, then filters out any that aren't actually OpenSearch Dashboards's core + * index (e.g. we don't want to remove .opensearch-dashboards_task_manager or the like). */ -async function fetchKibanaIndices(client: Client) { - const kibanaIndices = await client.cat.indices({ index: '.kibana*', format: 'json' }); - const isKibanaIndex = (index: string) => /^\.kibana(:?_\d*)?$/.test(index); - return kibanaIndices.map((x: { index: string }) => x.index).filter(isKibanaIndex); +async function fetchOpenSearchDashboardsIndices(client: Client) { + const opensearchDashboardsIndices = await client.cat.indices({ + index: '.opensearch-dashboards*', + format: 'json', + }); + const isOpenSearchDashboardsIndex = (index: string) => + /^\.opensearch-dashboards(:?_\d*)?$/.test(index); + return opensearchDashboardsIndices + .map((x: { index: string }) => x.index) + .filter(isOpenSearchDashboardsIndex); } -export async function cleanKibanaIndices({ +export async function cleanOpenSearchDashboardsIndices({ client, stats, log, - kibanaPluginIds, + opensearchDashboardsPluginIds, }: { client: Client; stats: Stats; log: ToolingLog; - kibanaPluginIds: string[]; + opensearchDashboardsPluginIds: string[]; }) { - if (!kibanaPluginIds.includes('spaces')) { - return await deleteKibanaIndices({ + if (!opensearchDashboardsPluginIds.includes('spaces')) { + return await deleteOpenSearchDashboardsIndices({ client, stats, log, @@ -111,7 +117,7 @@ export async function cleanKibanaIndices({ while (true) { const resp = await client.deleteByQuery({ - index: `.kibana`, + index: `.opensearch-dashboards`, body: { query: { bool: { @@ -141,10 +147,10 @@ export async function cleanKibanaIndices({ log.warning( `since spaces are enabled, all objects other than the default space were deleted from ` + - `.kibana rather than deleting the whole index` + `.opensearch-dashboards rather than deleting the whole index` ); - stats.deletedIndex('.kibana'); + stats.deletedIndex('.opensearch-dashboards'); } export async function createDefaultSpace({ index, client }: { index: string; client: Client }) { diff --git a/packages/kbn-es-archiver/src/lib/progress.ts b/packages/osd-opensearch-archiver/src/lib/progress.ts similarity index 98% rename from packages/kbn-es-archiver/src/lib/progress.ts rename to packages/osd-opensearch-archiver/src/lib/progress.ts index de3ab51e9cdb..18d1691ce82f 100644 --- a/packages/kbn-es-archiver/src/lib/progress.ts +++ b/packages/osd-opensearch-archiver/src/lib/progress.ts @@ -17,7 +17,7 @@ * under the License. */ -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; const SECOND = 1000; diff --git a/packages/kbn-es-archiver/src/lib/records/__tests__/filter_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/records/__tests__/filter_records_stream.ts similarity index 95% rename from packages/kbn-es-archiver/src/lib/records/__tests__/filter_records_stream.ts rename to packages/osd-opensearch-archiver/src/lib/records/__tests__/filter_records_stream.ts index b23ff2e4e52a..d3894bef551a 100644 --- a/packages/kbn-es-archiver/src/lib/records/__tests__/filter_records_stream.ts +++ b/packages/osd-opensearch-archiver/src/lib/records/__tests__/filter_records_stream.ts @@ -18,7 +18,7 @@ */ import Chance from 'chance'; -import expect from '@kbn/expect'; +import expect from '@osd/expect'; import { createListStream, createPromiseFromStreams, createConcatStream } from '../../streams'; @@ -26,7 +26,7 @@ import { createFilterRecordsStream } from '../filter_records_stream'; const chance = new Chance(); -describe('esArchiver: createFilterRecordsStream()', () => { +describe('opensearchArchiver: createFilterRecordsStream()', () => { it('consumes any value', async () => { const output = await createPromiseFromStreams([ createListStream([ diff --git a/packages/kbn-es-archiver/src/lib/records/filter_records_stream.ts b/packages/osd-opensearch-archiver/src/lib/records/filter_records_stream.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/records/filter_records_stream.ts rename to packages/osd-opensearch-archiver/src/lib/records/filter_records_stream.ts diff --git a/packages/kbn-es-archiver/src/lib/records/index.ts b/packages/osd-opensearch-archiver/src/lib/records/index.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/records/index.ts rename to packages/osd-opensearch-archiver/src/lib/records/index.ts diff --git a/packages/kbn-es-archiver/src/lib/stats.ts b/packages/osd-opensearch-archiver/src/lib/stats.ts similarity index 98% rename from packages/kbn-es-archiver/src/lib/stats.ts rename to packages/osd-opensearch-archiver/src/lib/stats.ts index c7b98c42d3ef..a8761e5fc7c1 100644 --- a/packages/kbn-es-archiver/src/lib/stats.ts +++ b/packages/osd-opensearch-archiver/src/lib/stats.ts @@ -17,7 +17,7 @@ * under the License. */ -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog } from '@osd/dev-utils'; import { cloneDeep } from 'lodash'; export interface IndexStats { diff --git a/packages/kbn-es-archiver/src/lib/streams/concat_stream.test.js b/packages/osd-opensearch-archiver/src/lib/streams/concat_stream.test.js similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/concat_stream.test.js rename to packages/osd-opensearch-archiver/src/lib/streams/concat_stream.test.js diff --git a/packages/kbn-es-archiver/src/lib/streams/concat_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/concat_stream.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/concat_stream.ts rename to packages/osd-opensearch-archiver/src/lib/streams/concat_stream.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.test.js b/packages/osd-opensearch-archiver/src/lib/streams/concat_stream_providers.test.js similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.test.js rename to packages/osd-opensearch-archiver/src/lib/streams/concat_stream_providers.test.js diff --git a/packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.ts b/packages/osd-opensearch-archiver/src/lib/streams/concat_stream_providers.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/concat_stream_providers.ts rename to packages/osd-opensearch-archiver/src/lib/streams/concat_stream_providers.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/filter_stream.test.ts b/packages/osd-opensearch-archiver/src/lib/streams/filter_stream.test.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/filter_stream.test.ts rename to packages/osd-opensearch-archiver/src/lib/streams/filter_stream.test.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/filter_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/filter_stream.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/filter_stream.ts rename to packages/osd-opensearch-archiver/src/lib/streams/filter_stream.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/index.ts b/packages/osd-opensearch-archiver/src/lib/streams/index.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/index.ts rename to packages/osd-opensearch-archiver/src/lib/streams/index.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/intersperse_stream.test.js b/packages/osd-opensearch-archiver/src/lib/streams/intersperse_stream.test.js similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/intersperse_stream.test.js rename to packages/osd-opensearch-archiver/src/lib/streams/intersperse_stream.test.js diff --git a/packages/kbn-es-archiver/src/lib/streams/intersperse_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/intersperse_stream.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/intersperse_stream.ts rename to packages/osd-opensearch-archiver/src/lib/streams/intersperse_stream.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/list_stream.test.js b/packages/osd-opensearch-archiver/src/lib/streams/list_stream.test.js similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/list_stream.test.js rename to packages/osd-opensearch-archiver/src/lib/streams/list_stream.test.js diff --git a/packages/kbn-es-archiver/src/lib/streams/list_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/list_stream.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/list_stream.ts rename to packages/osd-opensearch-archiver/src/lib/streams/list_stream.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/map_stream.test.js b/packages/osd-opensearch-archiver/src/lib/streams/map_stream.test.js similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/map_stream.test.js rename to packages/osd-opensearch-archiver/src/lib/streams/map_stream.test.js diff --git a/packages/kbn-es-archiver/src/lib/streams/map_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/map_stream.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/map_stream.ts rename to packages/osd-opensearch-archiver/src/lib/streams/map_stream.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/promise_from_streams.test.js b/packages/osd-opensearch-archiver/src/lib/streams/promise_from_streams.test.js similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/promise_from_streams.test.js rename to packages/osd-opensearch-archiver/src/lib/streams/promise_from_streams.test.js diff --git a/packages/kbn-es-archiver/src/lib/streams/promise_from_streams.ts b/packages/osd-opensearch-archiver/src/lib/streams/promise_from_streams.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/promise_from_streams.ts rename to packages/osd-opensearch-archiver/src/lib/streams/promise_from_streams.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/reduce_stream.test.js b/packages/osd-opensearch-archiver/src/lib/streams/reduce_stream.test.js similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/reduce_stream.test.js rename to packages/osd-opensearch-archiver/src/lib/streams/reduce_stream.test.js diff --git a/packages/kbn-es-archiver/src/lib/streams/reduce_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/reduce_stream.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/reduce_stream.ts rename to packages/osd-opensearch-archiver/src/lib/streams/reduce_stream.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/replace_stream.test.js b/packages/osd-opensearch-archiver/src/lib/streams/replace_stream.test.js similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/replace_stream.test.js rename to packages/osd-opensearch-archiver/src/lib/streams/replace_stream.test.js diff --git a/packages/kbn-es-archiver/src/lib/streams/replace_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/replace_stream.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/replace_stream.ts rename to packages/osd-opensearch-archiver/src/lib/streams/replace_stream.ts diff --git a/packages/kbn-es-archiver/src/lib/streams/split_stream.test.js b/packages/osd-opensearch-archiver/src/lib/streams/split_stream.test.js similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/split_stream.test.js rename to packages/osd-opensearch-archiver/src/lib/streams/split_stream.test.js diff --git a/packages/kbn-es-archiver/src/lib/streams/split_stream.ts b/packages/osd-opensearch-archiver/src/lib/streams/split_stream.ts similarity index 100% rename from packages/kbn-es-archiver/src/lib/streams/split_stream.ts rename to packages/osd-opensearch-archiver/src/lib/streams/split_stream.ts diff --git a/packages/kbn-es-archiver/src/es_archiver.ts b/packages/osd-opensearch-archiver/src/opensearch_archiver.ts similarity index 83% rename from packages/kbn-es-archiver/src/es_archiver.ts rename to packages/osd-opensearch-archiver/src/opensearch_archiver.ts index c6f890b963e3..177e96c12e22 100644 --- a/packages/kbn-es-archiver/src/es_archiver.ts +++ b/packages/osd-opensearch-archiver/src/opensearch_archiver.ts @@ -18,42 +18,42 @@ */ import { Client } from 'elasticsearch'; -import { ToolingLog, KbnClient } from '@kbn/dev-utils'; +import { ToolingLog, OsdClient } from '@osd/dev-utils'; import { saveAction, loadAction, unloadAction, rebuildAllAction, - emptyKibanaIndexAction, + emptyOpenSearchDashboardsIndexAction, editAction, } from './actions'; -export class EsArchiver { +export class OpenSearchArchiver { private readonly client: Client; private readonly dataDir: string; private readonly log: ToolingLog; - private readonly kbnClient: KbnClient; + private readonly osdClient: OsdClient; constructor({ client, dataDir, log, - kibanaUrl, + opensearchDashboardsUrl, }: { client: Client; dataDir: string; log: ToolingLog; - kibanaUrl: string; + opensearchDashboardsUrl: string; }) { this.client = client; this.dataDir = dataDir; this.log = log; - this.kbnClient = new KbnClient({ log, url: kibanaUrl }); + this.osdClient = new OsdClient({ log, url: opensearchDashboardsUrl }); } /** - * Extract data and mappings from an elasticsearch index and store + * Extract data and mappings from an opensearch index and store * it in the dataDir so it can be used later to recreate the index. * * @param {String} name - the name of this archive, used to determine filename @@ -102,12 +102,12 @@ export class EsArchiver { client: this.client, dataDir: this.dataDir, log: this.log, - kbnClient: this.kbnClient, + osdClient: this.osdClient, }); } /** - * Remove the indexes in elasticsearch that have data in an archive. + * Remove the indexes in opensearch that have data in an archive. * * @param {String} name * @return Promise @@ -118,13 +118,13 @@ export class EsArchiver { client: this.client, dataDir: this.dataDir, log: this.log, - kbnClient: this.kbnClient, + osdClient: this.osdClient, }); } /** * Parse and reformat all of the archives. This is primarily helpful - * for working on the esArchiver. + * for working on the opensearchArchiver. * * @return Promise */ @@ -163,16 +163,16 @@ export class EsArchiver { } /** - * Delete any Kibana indices, and initialize the Kibana index as Kibana would do + * Delete any OpenSearchDashboards indices, and initialize the OpenSearchDashboards index as OpenSearchDashboards would do * on startup. * * @return Promise */ - async emptyKibanaIndex() { - await emptyKibanaIndexAction({ + async emptyOpenSearchDashboardsIndex() { + await emptyOpenSearchDashboardsIndexAction({ client: this.client, log: this.log, - kbnClient: this.kbnClient, + osdClient: this.osdClient, }); } } diff --git a/packages/kbn-es-archiver/tsconfig.json b/packages/osd-opensearch-archiver/tsconfig.json similarity index 100% rename from packages/kbn-es-archiver/tsconfig.json rename to packages/osd-opensearch-archiver/tsconfig.json diff --git a/packages/kbn-es-archiver/yarn.lock b/packages/osd-opensearch-archiver/yarn.lock similarity index 100% rename from packages/kbn-es-archiver/yarn.lock rename to packages/osd-opensearch-archiver/yarn.lock