From 47c77f209b9e1f6bd8f317494328f5c60a8aa442 Mon Sep 17 00:00:00 2001
From: Brian Phillips <28457+brianphillips@users.noreply.github.com>
Date: Wed, 24 May 2023 15:16:39 -0500
Subject: [PATCH] add ADRs to example app
Signed-off-by: Brian Phillips <28457+brianphillips@users.noreply.github.com>
---
app-config.yaml | 3 +++
packages/app/package.json | 1 +
packages/app/src/components/catalog/EntityPage.tsx | 5 +++++
packages/app/src/components/search/SearchPage.tsx | 7 +++++++
packages/backend/src/plugins/search.ts | 13 +++++++++++++
plugins/adr/examples/component/catalog-info.yaml | 13 +++++++++++++
yarn.lock | 3 ++-
7 files changed, 44 insertions(+), 1 deletion(-)
create mode 100644 plugins/adr/examples/component/catalog-info.yaml
diff --git a/app-config.yaml b/app-config.yaml
index e2b03786c4..95995025bc 100644
--- a/app-config.yaml
+++ b/app-config.yaml
@@ -274,6 +274,9 @@ catalog:
# Example component for TechDocs
- type: file
target: ../../plugins/techdocs-backend/examples/documented-component/catalog-info.yaml
+ # Example component for ADRs
+ - type: file
+ target: ../../plugins/adr/examples/component/catalog-info.yaml
# Backstage example templates
- type: file
target: ../../plugins/scaffolder-backend/sample-templates/all-templates.yaml
diff --git a/packages/app/package.json b/packages/app/package.json
index 010b2dd648..3b7726fe4a 100644
--- a/packages/app/package.json
+++ b/packages/app/package.json
@@ -15,6 +15,7 @@
"@backstage/core-components": "workspace:^",
"@backstage/core-plugin-api": "workspace:^",
"@backstage/integration-react": "workspace:^",
+ "@backstage/plugin-adr": "workspace:^",
"@backstage/plugin-airbrake": "workspace:^",
"@backstage/plugin-apache-airflow": "workspace:^",
"@backstage/plugin-api-docs": "workspace:^",
diff --git a/packages/app/src/components/catalog/EntityPage.tsx b/packages/app/src/components/catalog/EntityPage.tsx
index 026544ab26..ca6d09e318 100644
--- a/packages/app/src/components/catalog/EntityPage.tsx
+++ b/packages/app/src/components/catalog/EntityPage.tsx
@@ -26,6 +26,7 @@ import {
RELATION_PROVIDES_API,
} from '@backstage/catalog-model';
import { EmptyState, InfoCard } from '@backstage/core-components';
+import { EntityAdrContent, isAdrAvailable } from '@backstage/plugin-adr';
import {
EntityApiDefinitionCard,
EntityConsumedApisCard,
@@ -484,6 +485,10 @@ const serviceEntityPage = (
{techdocsContent}
+
+
+
+
{
name: 'Documentation',
icon: ,
},
+ {
+ value: 'adr',
+ name: 'Architecture Decision Records',
+ icon: ,
+ },
]}
/>
@@ -131,6 +137,7 @@ const SearchPage = () => {
} />
} />
} />
+ } />
diff --git a/packages/backend/src/plugins/search.ts b/packages/backend/src/plugins/search.ts
index 0e6982545f..4290fcd68a 100644
--- a/packages/backend/src/plugins/search.ts
+++ b/packages/backend/src/plugins/search.ts
@@ -15,6 +15,7 @@
*/
import { useHotCleanup } from '@backstage/backend-common';
+import { DefaultAdrCollatorFactory } from '@backstage/plugin-adr-backend';
import { DefaultCatalogCollatorFactory } from '@backstage/plugin-catalog-backend';
import { ToolDocumentCollatorFactory } from '@backstage/plugin-explore-backend';
import { createRouter } from '@backstage/plugin-search-backend';
@@ -68,6 +69,18 @@ export default async function createPlugin(
// Collators are responsible for gathering documents known to plugins. This
// particular collator gathers entities from the software catalog.
+ indexBuilder.addCollator({
+ schedule,
+ factory: DefaultAdrCollatorFactory.fromConfig({
+ cache: env.cache,
+ config: env.config,
+ discovery: env.discovery,
+ logger: env.logger,
+ reader: env.reader,
+ tokenManager: env.tokenManager,
+ }),
+ });
+
indexBuilder.addCollator({
schedule,
factory: DefaultCatalogCollatorFactory.fromConfig(env.config, {
diff --git a/plugins/adr/examples/component/catalog-info.yaml b/plugins/adr/examples/component/catalog-info.yaml
new file mode 100644
index 0000000000..580110243f
--- /dev/null
+++ b/plugins/adr/examples/component/catalog-info.yaml
@@ -0,0 +1,13 @@
+---
+apiVersion: backstage.io/v1alpha1
+kind: Component
+metadata:
+ name: component-with-adrs
+ title: Component With ADRs
+ description: A Service with ADRs registerd
+ annotations:
+ backstage.io/adr-location: https://github.com/adr/madr/tree/develop/docs/decisions
+spec:
+ type: service
+ lifecycle: experimental
+ owner: user:guest
diff --git a/yarn.lock b/yarn.lock
index d5fe3b1ec1..d61e80b77b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4525,7 +4525,7 @@ __metadata:
languageName: unknown
linkType: soft
-"@backstage/plugin-adr@workspace:plugins/adr":
+"@backstage/plugin-adr@workspace:^, @backstage/plugin-adr@workspace:plugins/adr":
version: 0.0.0-use.local
resolution: "@backstage/plugin-adr@workspace:plugins/adr"
dependencies:
@@ -24254,6 +24254,7 @@ __metadata:
"@backstage/core-components": "workspace:^"
"@backstage/core-plugin-api": "workspace:^"
"@backstage/integration-react": "workspace:^"
+ "@backstage/plugin-adr": "workspace:^"
"@backstage/plugin-airbrake": "workspace:^"
"@backstage/plugin-apache-airflow": "workspace:^"
"@backstage/plugin-api-docs": "workspace:^"