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

Add a tag parameter in createInternalRepository #8521

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 2 additions & 0 deletions changelogs/fragments/8521.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Add a tag parameter to createInternalRepository API ([#8521](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8521))
18 changes: 13 additions & 5 deletions src/core/server/saved_objects/saved_objects_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ export interface SavedObjectsServiceStart {
*
* @param includedHiddenTypes - A list of additional hidden types the repository should have access to.
*/
createInternalRepository: (includedHiddenTypes?: string[]) => ISavedObjectsRepository;
createInternalRepository: (
includedHiddenTypes?: string[],
tag?: string
) => ISavedObjectsRepository;
/**
* Creates a {@link SavedObjectsSerializer | serializer} that is aware of all registered types.
*/
Expand Down Expand Up @@ -275,7 +278,10 @@ export interface SavedObjectsRepositoryFactory {
*
* @param includedHiddenTypes - A list of additional hidden types the repository should have access to.
*/
createInternalRepository: (includedHiddenTypes?: string[]) => ISavedObjectsRepository;
createInternalRepository: (
includedHiddenTypes?: string[],
tag?: string
) => ISavedObjectsRepository;
}

/** @internal */
Expand Down Expand Up @@ -491,13 +497,15 @@ export class SavedObjectsService

const createRepository = (
opensearchClient: OpenSearchClient,
includedHiddenTypes: string[] = []
includedHiddenTypes: string[] = [],
tag?: string
) => {
if (this.respositoryFactoryProvider) {
return this.respositoryFactoryProvider({
migrator,
typeRegistry: this.typeRegistry,
includedHiddenTypes,
tag,
});
} else {
return SavedObjectsRepository.createRepository(
Expand All @@ -511,8 +519,8 @@ export class SavedObjectsService
};

const repositoryFactory: SavedObjectsRepositoryFactory = {
createInternalRepository: (includedHiddenTypes?: string[]) =>
createRepository(client.asInternalUser, includedHiddenTypes),
createInternalRepository: (includedHiddenTypes?: string[], tag?: string) =>
createRepository(client.asInternalUser, includedHiddenTypes, tag),
createScopedRepository: (req: OpenSearchDashboardsRequest, includedHiddenTypes?: string[]) =>
createRepository(client.asScoped(req).asCurrentUser, includedHiddenTypes),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface SavedObjectsRepositoryOptions {
migrator: IOpenSearchDashboardsMigrator;
typeRegistry: SavedObjectTypeRegistry;
includedHiddenTypes: string[];
tag?: string;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/usage_collection/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class UsageCollectionPlugin implements Plugin<CollectorSet> {

public start({ savedObjects }: CoreStart) {
this.logger.debug('Starting plugin');
this.savedObjects = savedObjects.createInternalRepository();
this.savedObjects = savedObjects.createInternalRepository([], 'usage_collection');
}

public stop() {
Expand Down
Loading