From 82d14dd868f6701673f56e80a8a88dcda21945c4 Mon Sep 17 00:00:00 2001 From: aramissennyeydd Date: Tue, 2 Jul 2024 09:29:01 -0400 Subject: [PATCH] show how to do it for the old backend as well Signed-off-by: aramissennyeydd --- .../software-catalog/external-integrations.md | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/docs/features/software-catalog/external-integrations.md b/docs/features/software-catalog/external-integrations.md index c9fed03e23..56423c9392 100644 --- a/docs/features/software-catalog/external-integrations.md +++ b/docs/features/software-catalog/external-integrations.md @@ -336,7 +336,7 @@ backend.start(); If you want to go a step further and increase the configurability of your new `FrobsProvider`, you can define the schedule that the task runs at in `app-config.yaml` instead of requiring code changes to adjust. -```yaml +```yaml title="app-config.yaml" catalog: providers: frobs-provider: @@ -350,7 +350,7 @@ This approach will also allow you to customize the schedule per environment #### New Backend -```ts +```ts title="packages/backend/src/index.ts" import { SchedulerServiceTaskScheduleDefinition, /* highlight-add-start */ @@ -392,6 +392,38 @@ export const catalogModuleFrobsProvider = createBackendModule({ }); ``` +#### Old Backend + +```ts title="packages/backend/src/plugins/catalog.ts" +/* highlight-add-next-line */ +import { FrobsProvider } from '../path/to/class'; +import { + /* highlight-add-start */ + readSchedulerServiceTaskScheduleDefinitionFromConfig, + /* highlight-add-end */ +} from '@backstage/backend-plugin-api'; + +export default async function createPlugin( + env: PluginEnvironment, +): Promise { + /* highlight-add-start */ + const config = env.config.getConfig('catalog.providers.frobs-provider'); // Generally, catalog config goes under catalog.providers.pluginId + // Add a default schedule if you don't define one in config. + const schedule = config.has('schedule') + ? readSchedulerServiceTaskScheduleDefinitionFromConfig( + config.getConfig('schedule'), + ) + : { + frequency: { minutes: 30 }, + timeout: { minutes: 10 }, + }; + const taskRunner = env.scheduler.createScheduledTaskRunner(schedule); + /* highlight-add-end */ + + // .. +} +``` + ### Example User Entity Provider If you have a 3rd party entity provider such as an internal HR system that you wish to use you are not limited to using our entity providers, (or simply wish to add to existing entity providers with your own data).