Skip to content

Commit

Permalink
add mapping for osd index
Browse files Browse the repository at this point in the history
Signed-off-by: Hailong Cui <ihailong@amazon.com>
  • Loading branch information
Hailong-am committed Feb 28, 2024
1 parent fe9a4c1 commit 0326f9e
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,18 @@ function defaultMapping(): IndexMapping {
},
},
},
workspaces: {
type: 'keyword',
},
permissions: {
properties: {
read: principals,
write: principals,
management: principals,
library_read: principals,
library_write: principals,
},
},
// workspaces: {
// type: 'keyword',
// },
// permissions: {
// properties: {
// read: principals,
// write: principals,
// management: principals,
// library_read: principals,
// library_write: principals,
// },
// },
},
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/saved_objects/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

import { SavedObjectsClient } from './service/saved_objects_client';
import { SavedObjectsTypeMappingDefinition } from './mappings';
import { SavedObjectsFieldMapping, SavedObjectsTypeMappingDefinition } from './mappings';
import { SavedObjectMigrationMap } from './migrations';

export {
Expand Down Expand Up @@ -246,7 +246,7 @@ export interface SavedObjectsType {
/**
* The {@link SavedObjectsTypeMappingDefinition | mapping definition} for the type.
*/
mappings: SavedObjectsTypeMappingDefinition;
mappings: SavedObjectsTypeMappingDefinition | SavedObjectsFieldMapping;
/**
* An optional map of {@link SavedObjectMigrationFn | migrations} to be used to migrate the type.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/workspace/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { registerPermissionCheckRoutes } from './permission_control/routes';
import { ConfigSchema } from '../config';
import { cleanWorkspaceId, getWorkspaceIdFromUrl } from '../../../core/server/utils';
import { permission, workspaces } from './saved_objects/workspace';

export class WorkspacePlugin implements Plugin<{}, {}> {
private readonly logger: Logger;
Expand Down Expand Up @@ -59,6 +60,8 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
config.permission.enabled === undefined ? true : config.permission.enabled;

this.client = new WorkspaceClientWithSavedObject(core, this.logger);
core.savedObjects.registerType(permission);
core.savedObjects.registerType(workspaces);

await this.client.setup(core);

Expand Down
50 changes: 49 additions & 1 deletion src/plugins/workspace/server/saved_objects/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { SavedObjectsType, WORKSPACE_TYPE } from '../../../../core/server';
import {
SavedObjectsFieldMapping,
SavedObjectsType,
WORKSPACE_TYPE,
} from '../../../../core/server';

export const workspace: SavedObjectsType = {
name: WORKSPACE_TYPE,
Expand Down Expand Up @@ -42,3 +46,47 @@ export const workspace: SavedObjectsType = {
},
},
};

const principals: SavedObjectsFieldMapping = {
properties: {
users: {
type: 'keyword',
},
groups: {
type: 'keyword',
},
},
};
export const permission: SavedObjectsType = {
name: 'permission',
namespaceType: 'agnostic',
/**
* Disable operation by using saved objects APIs on workspace metadata
*/
hidden: true,
/**
* workspace won't appear in management page.
*/
mappings: {
dynamic: false,
properties: {
read: principals,
write: principals,
management: principals,
library_read: principals,
library_write: principals,
},
},
};

export const workspaces: SavedObjectsType = {
name: 'workspaces',
namespaceType: 'agnostic',
/**
* Disable operation by using saved objects APIs on workspace metadata
*/
hidden: true,
mappings: {
type: 'keyword',
},
};

0 comments on commit 0326f9e

Please sign in to comment.