Update the 'create-app' template to use the new constructor for DefaultCatalogCollator

Signed-off-by: Roy Jacobs <roy.jacobs@gmail.com>
This commit is contained in:
Roy Jacobs
2021-09-02 15:10:15 +02:00
parent 800a95bace
commit a5013957e4
2 changed files with 25 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
---
'@backstage/create-app': patch
---
Updated the search configuration class to use the static `fromConfig`-based constructor for the `DefaultCatalogCollator`.
To apply this change to an existing app, replace the following line in `search.ts`:
```diff
-collator: new DefaultCatalogCollator({ discovery })
+collator: DefaultCatalogCollator.fromConfig(config, { discovery })
```
The `config` parameter was not needed before, so make sure you also add that in the signature of `createPlugin`
in `search.ts`:
```diff
export default async function createPlugin({
logger,
discovery,
+ config,
}: PluginEnvironment) {
```
@@ -10,6 +10,7 @@ import { DefaultCatalogCollator } from '@backstage/plugin-catalog-backend';
export default async function createPlugin({
logger,
discovery,
config,
}: PluginEnvironment) {
// Initialize a connection to a search engine.
const searchEngine = new LunrSearchEngine({ logger });
@@ -19,7 +20,7 @@ export default async function createPlugin({
// particular collator gathers entities from the software catalog.
indexBuilder.addCollator({
defaultRefreshIntervalSeconds: 600,
collator: new DefaultCatalogCollator({ discovery }),
collator: DefaultCatalogCollator.fromConfig(config, { discovery }),
});
// The scheduler controls when documents are gathered from collators and sent