From 4737ba49bbab71fdcda6944329a665c39710de75 Mon Sep 17 00:00:00 2001 From: Yan Zeng <46499415+zengyan-amazon@users.noreply.github.com> Date: Tue, 2 Aug 2022 15:09:33 -0700 Subject: [PATCH] Add empty data source plugin (#2052) Adds empty data source plugin. Signed-off-by: Kristen Tian --- src/plugins/data_source/README.md | 13 +++++++++ src/plugins/data_source/common/index.ts | 7 +++++ .../data_source/opensearch_dashboards.json | 9 ++++++ src/plugins/data_source/server/index.ts | 24 +++++++++++++++ src/plugins/data_source/server/plugin.ts | 29 +++++++++++++++++++ src/plugins/data_source/server/types.ts | 9 ++++++ 6 files changed, 91 insertions(+) create mode 100755 src/plugins/data_source/README.md create mode 100644 src/plugins/data_source/common/index.ts create mode 100644 src/plugins/data_source/opensearch_dashboards.json create mode 100644 src/plugins/data_source/server/index.ts create mode 100644 src/plugins/data_source/server/plugin.ts create mode 100644 src/plugins/data_source/server/types.ts diff --git a/src/plugins/data_source/README.md b/src/plugins/data_source/README.md new file mode 100755 index 000000000000..7ccdeb62b7c4 --- /dev/null +++ b/src/plugins/data_source/README.md @@ -0,0 +1,13 @@ +# data_source + +A OpenSearch Dashboards plugin + +This plugin introduce OpenSearch data source into OpenSearch Dashboards, and provides related functions to connect to OpenSearch data sources. + +--- + +## Development + +See the [OpenSearch Dashboards contributing +guide](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/CONTRIBUTING.md) for instructions +setting up your development environment. diff --git a/src/plugins/data_source/common/index.ts b/src/plugins/data_source/common/index.ts new file mode 100644 index 000000000000..10fde727a706 --- /dev/null +++ b/src/plugins/data_source/common/index.ts @@ -0,0 +1,7 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export const PLUGIN_ID = 'dataSource'; +export const PLUGIN_NAME = 'data_source'; diff --git a/src/plugins/data_source/opensearch_dashboards.json b/src/plugins/data_source/opensearch_dashboards.json new file mode 100644 index 000000000000..e6556eca7988 --- /dev/null +++ b/src/plugins/data_source/opensearch_dashboards.json @@ -0,0 +1,9 @@ +{ + "id": "dataSource", + "version": "opensearchDashboards", + "opensearchDashboardsVersion": "opensearchDashboards", + "server": true, + "ui": false, + "requiredPlugins": [], + "optionalPlugins": [] +} diff --git a/src/plugins/data_source/server/index.ts b/src/plugins/data_source/server/index.ts new file mode 100644 index 000000000000..41df94090986 --- /dev/null +++ b/src/plugins/data_source/server/index.ts @@ -0,0 +1,24 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { schema, TypeOf } from '@osd/config-schema'; +import { PluginConfigDescriptor, PluginInitializerContext } from 'src/core/server'; +import { DataSourcePlugin } from './plugin'; + +export const configSchema = schema.object({ + enabled: schema.boolean({ defaultValue: false }), +}); + +export type DataSourcePluginConfigType = TypeOf; + +export const config: PluginConfigDescriptor = { + schema: configSchema, +}; + +export function plugin(initializerContext: PluginInitializerContext) { + return new DataSourcePlugin(initializerContext); +} + +export { DataSourcePluginSetup, DataSourcePluginStart } from './types'; diff --git a/src/plugins/data_source/server/plugin.ts b/src/plugins/data_source/server/plugin.ts new file mode 100644 index 000000000000..dc5c53b9cfb2 --- /dev/null +++ b/src/plugins/data_source/server/plugin.ts @@ -0,0 +1,29 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { PluginInitializerContext, CoreSetup, CoreStart, Plugin, Logger } from 'src/core/server'; + +import { DataSourcePluginSetup, DataSourcePluginStart } from './types'; + +export class DataSourcePlugin implements Plugin { + private readonly logger: Logger; + + constructor(initializerContext: PluginInitializerContext) { + this.logger = initializerContext.logger.get(); + } + + public setup(core: CoreSetup) { + this.logger.debug('data_source: Setup'); + + return {}; + } + + public start(core: CoreStart) { + this.logger.debug('data_source: Started'); + return {}; + } + + public stop() {} +} diff --git a/src/plugins/data_source/server/types.ts b/src/plugins/data_source/server/types.ts new file mode 100644 index 000000000000..a70c8c1bf199 --- /dev/null +++ b/src/plugins/data_source/server/types.ts @@ -0,0 +1,9 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface DataSourcePluginSetup {} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface DataSourcePluginStart {}