Remove options for Explore & TechDocs module
- Quick fix for permission-backend Signed-off-by: Philipp Hugenroth <philipph@spotify.com>
This commit is contained in:
@@ -80,7 +80,7 @@ export const permissionModuleAllowAllPolicy = createBackendModule({
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export const permissionPlugin = createBackendPlugin(() => ({
|
||||
export const permissionPlugin = createBackendPlugin({
|
||||
pluginId: 'permission',
|
||||
register(env) {
|
||||
const policies = new PolicyExtensionPointImpl();
|
||||
@@ -115,4 +115,4 @@ export const permissionPlugin = createBackendPlugin(() => ({
|
||||
},
|
||||
});
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TaskScheduleDefinitionConfig } from '@backstage/backend-tasks';
|
||||
|
||||
export interface Config {
|
||||
search?: {
|
||||
explore?: {
|
||||
schedule?: TaskScheduleDefinitionConfig;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -23,66 +23,59 @@ import {
|
||||
coreServices,
|
||||
createBackendModule,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { TaskScheduleDefinition } from '@backstage/backend-tasks';
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
|
||||
|
||||
import { ToolDocumentCollatorFactory } from '@backstage/plugin-search-backend-module-explore';
|
||||
|
||||
/**
|
||||
* Options for {@link searchModuleExploreCollator}.
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export type SearchModuleExploreCollatorOptions = {
|
||||
schedule?: TaskScheduleDefinition;
|
||||
};
|
||||
import { readTaskScheduleDefinitionFromConfig } from '@backstage/backend-tasks';
|
||||
|
||||
/**
|
||||
* Search backend module for the Explore index.
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export const searchModuleExploreCollator = createBackendModule(
|
||||
(options?: SearchModuleExploreCollatorOptions) => ({
|
||||
moduleId: 'exploreCollator',
|
||||
pluginId: 'search',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
config: coreServices.rootConfig,
|
||||
logger: coreServices.logger,
|
||||
discovery: coreServices.discovery,
|
||||
scheduler: coreServices.scheduler,
|
||||
tokenManager: coreServices.tokenManager,
|
||||
indexRegistry: searchIndexRegistryExtensionPoint,
|
||||
},
|
||||
async init({
|
||||
config,
|
||||
logger,
|
||||
discovery,
|
||||
scheduler,
|
||||
indexRegistry,
|
||||
tokenManager,
|
||||
}) {
|
||||
const defaultSchedule = {
|
||||
frequency: { minutes: 10 },
|
||||
timeout: { minutes: 15 },
|
||||
initialDelay: { seconds: 3 },
|
||||
};
|
||||
export const searchModuleExploreCollator = createBackendModule({
|
||||
moduleId: 'exploreCollator',
|
||||
pluginId: 'search',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
config: coreServices.rootConfig,
|
||||
logger: coreServices.logger,
|
||||
discovery: coreServices.discovery,
|
||||
scheduler: coreServices.scheduler,
|
||||
tokenManager: coreServices.tokenManager,
|
||||
indexRegistry: searchIndexRegistryExtensionPoint,
|
||||
},
|
||||
async init({
|
||||
config,
|
||||
logger,
|
||||
discovery,
|
||||
scheduler,
|
||||
indexRegistry,
|
||||
tokenManager,
|
||||
}) {
|
||||
const defaultSchedule = {
|
||||
frequency: { minutes: 10 },
|
||||
timeout: { minutes: 15 },
|
||||
initialDelay: { seconds: 3 },
|
||||
};
|
||||
|
||||
indexRegistry.addCollator({
|
||||
schedule: scheduler.createScheduledTaskRunner(
|
||||
options?.schedule ?? defaultSchedule,
|
||||
),
|
||||
factory: ToolDocumentCollatorFactory.fromConfig(config, {
|
||||
discovery,
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
tokenManager,
|
||||
}),
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
const schedule = config.has('search.explore.schedule')
|
||||
? readTaskScheduleDefinitionFromConfig(
|
||||
config.getConfig('search.explore.schedule'),
|
||||
)
|
||||
: defaultSchedule;
|
||||
|
||||
indexRegistry.addCollator({
|
||||
schedule: scheduler.createScheduledTaskRunner(schedule),
|
||||
factory: ToolDocumentCollatorFactory.fromConfig(config, {
|
||||
discovery,
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
tokenManager,
|
||||
}),
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TaskScheduleDefinitionConfig } from '@backstage/backend-tasks';
|
||||
|
||||
export interface Config {
|
||||
search?: {
|
||||
techdocs?: {
|
||||
schedule?: TaskScheduleDefinitionConfig;
|
||||
collatorsFactory?: {
|
||||
locationTemplate?: string;
|
||||
parallelismLimit?: number;
|
||||
legacyPathCasing?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -19,79 +19,74 @@
|
||||
* A module for the search backend that exports TechDocs modules.
|
||||
*/
|
||||
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
coreServices,
|
||||
createBackendModule,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { TaskScheduleDefinition } from '@backstage/backend-tasks';
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
|
||||
import { readTaskScheduleDefinitionFromConfig } from '@backstage/backend-tasks';
|
||||
import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';
|
||||
|
||||
import {
|
||||
DefaultTechDocsCollatorFactory,
|
||||
TechDocsCollatorFactoryOptions,
|
||||
} from '@backstage/plugin-search-backend-module-techdocs';
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
* Options for {@link searchModuleTechDocsCollator}.
|
||||
*/
|
||||
export type SearchModuleTechDocsCollatorOptions = Omit<
|
||||
TechDocsCollatorFactoryOptions,
|
||||
'logger' | 'discovery' | 'tokenManager' | 'catalogClient'
|
||||
> & {
|
||||
schedule?: TaskScheduleDefinition;
|
||||
};
|
||||
import { DefaultTechDocsCollatorFactory } from '@backstage/plugin-search-backend-module-techdocs';
|
||||
import { searchIndexRegistryExtensionPoint } from '@backstage/plugin-search-backend-node/alpha';
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
* Search backend module for the TechDocs index.
|
||||
*/
|
||||
export const searchModuleTechDocsCollator = createBackendModule(
|
||||
(options?: SearchModuleTechDocsCollatorOptions) => ({
|
||||
moduleId: 'techDocsCollator',
|
||||
pluginId: 'search',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
config: coreServices.rootConfig,
|
||||
logger: coreServices.logger,
|
||||
discovery: coreServices.discovery,
|
||||
tokenManager: coreServices.tokenManager,
|
||||
scheduler: coreServices.scheduler,
|
||||
catalog: catalogServiceRef,
|
||||
indexRegistry: searchIndexRegistryExtensionPoint,
|
||||
},
|
||||
async init({
|
||||
config,
|
||||
logger,
|
||||
discovery,
|
||||
tokenManager,
|
||||
scheduler,
|
||||
catalog,
|
||||
indexRegistry,
|
||||
}) {
|
||||
const defaultSchedule = {
|
||||
frequency: { minutes: 10 },
|
||||
timeout: { minutes: 15 },
|
||||
initialDelay: { seconds: 3 },
|
||||
};
|
||||
export const searchModuleTechDocsCollator = createBackendModule({
|
||||
moduleId: 'techDocsCollator',
|
||||
pluginId: 'search',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
config: coreServices.rootConfig,
|
||||
logger: coreServices.logger,
|
||||
discovery: coreServices.discovery,
|
||||
tokenManager: coreServices.tokenManager,
|
||||
scheduler: coreServices.scheduler,
|
||||
catalog: catalogServiceRef,
|
||||
indexRegistry: searchIndexRegistryExtensionPoint,
|
||||
},
|
||||
async init({
|
||||
config,
|
||||
logger,
|
||||
discovery,
|
||||
tokenManager,
|
||||
scheduler,
|
||||
catalog,
|
||||
indexRegistry,
|
||||
}) {
|
||||
const defaultSchedule = {
|
||||
frequency: { minutes: 10 },
|
||||
timeout: { minutes: 15 },
|
||||
initialDelay: { seconds: 3 },
|
||||
};
|
||||
|
||||
indexRegistry.addCollator({
|
||||
schedule: scheduler.createScheduledTaskRunner(
|
||||
options?.schedule ?? defaultSchedule,
|
||||
const schedule = config.has('search.explore.schedule')
|
||||
? readTaskScheduleDefinitionFromConfig(
|
||||
config.getConfig('search.explore.schedule'),
|
||||
)
|
||||
: defaultSchedule;
|
||||
|
||||
indexRegistry.addCollator({
|
||||
schedule: scheduler.createScheduledTaskRunner(schedule),
|
||||
factory: DefaultTechDocsCollatorFactory.fromConfig(config, {
|
||||
locationTemplate: config.getOptionalString(
|
||||
'search.techdocs.collatorsFactory.locationTemplate',
|
||||
),
|
||||
factory: DefaultTechDocsCollatorFactory.fromConfig(config, {
|
||||
...options,
|
||||
discovery,
|
||||
tokenManager,
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
catalogClient: catalog,
|
||||
}),
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
parallelismLimit: config.getOptionalNumber(
|
||||
'search.techdocs.collatorsFactory.parallelismLimit',
|
||||
),
|
||||
legacyPathCasing: config.getOptionalBoolean(
|
||||
'search.techdocs.collatorsFactory.legacyPathCasing',
|
||||
),
|
||||
discovery,
|
||||
tokenManager,
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
catalogClient: catalog,
|
||||
}),
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user