Skip to content

Commit

Permalink
Add empty data source plugin (opensearch-project#2052)
Browse files Browse the repository at this point in the history
Adds empty data source plugin.
  • Loading branch information
zengyan-amazon authored and kristenTian committed Sep 14, 2022
1 parent 1d15a30 commit 247e9b0
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/plugins/data_source/README.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions src/plugins/data_source/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export const PLUGIN_ID = 'dataSource';
export const PLUGIN_NAME = 'data_source';
9 changes: 9 additions & 0 deletions src/plugins/data_source/opensearch_dashboards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "dataSource",
"version": "opensearchDashboards",
"opensearchDashboardsVersion": "opensearchDashboards",
"server": true,
"ui": false,
"requiredPlugins": [],
"optionalPlugins": []
}
24 changes: 24 additions & 0 deletions src/plugins/data_source/server/index.ts
Original file line number Diff line number Diff line change
@@ -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<typeof configSchema>;

export const config: PluginConfigDescriptor<DataSourcePluginConfigType> = {
schema: configSchema,
};

export function plugin(initializerContext: PluginInitializerContext) {
return new DataSourcePlugin(initializerContext);
}

export { DataSourcePluginSetup, DataSourcePluginStart } from './types';
29 changes: 29 additions & 0 deletions src/plugins/data_source/server/plugin.ts
Original file line number Diff line number Diff line change
@@ -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<DataSourcePluginSetup, DataSourcePluginStart> {
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() {}
}
9 changes: 9 additions & 0 deletions src/plugins/data_source/server/types.ts
Original file line number Diff line number Diff line change
@@ -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 {}

0 comments on commit 247e9b0

Please sign in to comment.