Use Catalog REST API instead of assuming local process.

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2021-03-18 13:28:04 +01:00
parent 3560405cab
commit 44ec2571b6
4 changed files with 30 additions and 28 deletions
+15 -8
View File
@@ -13,22 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useHotCleanup } from '@backstage/backend-common';
import { createRouter } from '@backstage/plugin-search-backend';
import { IndexBuilder } from '@backstage/plugin-search-backend-node';
import { PluginEnvironment } from '../types';
// import { DefaultCatalogCollator } from '@backstage/plugin-catalog-backend';
import { DefaultCatalogCollator } from '@backstage/plugin-catalog-backend';
export default async function createPlugin({ logger }: PluginEnvironment) {
export default async function createPlugin({
logger,
discovery,
}: PluginEnvironment) {
const indexBuilder = new IndexBuilder();
// TODO: Within this PR, update to use REST API instead of Catalog Builder.
/* indexRegistry.addCollator({
indexBuilder.addCollator({
type: 'software-catalog',
defaultRefreshIntervalSeconds: 600,
collator: new DefaultCatalogCollator(entitiesCatalog),
});*/
collator: new DefaultCatalogCollator(discovery),
});
// TODO: Make this a more proper refresh loop.
indexBuilder.build();
// TODO: Move refresh loop logic into the builder.
const timerId = setInterval(() => {
indexBuilder.build();
}, 60000);
useHotCleanup(module, () => clearInterval(timerId));
return await createRouter({
logger,