Split fact retrievers

Split fact retriever into severeal more specialised retrievers.
Ditch the dynamic addition of annotation facts in favour of
explicit annotation facts. Having dynamic facts makes the
versioning system somewhat meaningless.

Signed-off-by: Iain Billett <iain@roadie.io>
This commit is contained in:
Iain Billett
2021-11-17 15:21:18 +00:00
parent 8cf89aab38
commit ccc8a7ff5d
10 changed files with 542 additions and 150 deletions
+29 -6
View File
@@ -17,7 +17,9 @@ import {
createRouter,
buildTechInsightsContext,
createFactRetrieverRegistration,
createCatalogFactRetriever,
entityOwnershipFactRetriever,
entityMetadataFactRetriever,
techdocsFactRetriever,
} from '@backstage/plugin-tech-insights-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
@@ -40,8 +42,10 @@ export default async function createPlugin({
factRetrievers: [
createFactRetrieverRegistration(
'* * * * *', // Example cron, every minute
createCatalogFactRetriever(),
entityOwnershipFactRetriever,
),
createFactRetrieverRegistration('* * * * *', entityMetadataFactRetriever),
createFactRetrieverRegistration('* * * * *', techdocsFactRetriever),
],
factCheckerFactory: new JsonRulesEngineFactCheckerFactory({
checks: [
@@ -50,14 +54,33 @@ export default async function createPlugin({
type: JSON_RULE_ENGINE_CHECK_TYPE,
name: 'simpleTestCheck',
description: 'Simple Check For Testing',
factIds: ['testRetriever'],
factIds: [
'entityMetadataFactRetriever',
'techdocsFactRetriever',
'entityOwnershipFactRetriever',
],
rule: {
conditions: {
all: [
{
fact: 'examplenumberfact',
operator: 'lessThan',
value: 5,
fact: 'hasGroupOwner',
operator: 'equal',
value: true,
},
{
fact: 'hasTitle',
operator: 'equal',
value: true,
},
{
fact: 'hasDescription',
operator: 'equal',
value: true,
},
{
fact: 'hasAnnotationBackstageIoTechdocsRef',
operator: 'equal',
value: true,
},
],
},