From ecdd407b1fde9223947cd873bbcce798c3a3b398 Mon Sep 17 00:00:00 2001 From: Nir Gazit Date: Mon, 1 Mar 2021 09:19:31 +0200 Subject: [PATCH 1/3] Made all locations outputted by GithubDiscoveryProcessor optional --- .changeset/curvy-pugs-type.md | 5 +++++ .../processors/GithubDiscoveryProcessor.test.ts | 10 +++++----- .../ingestion/processors/GithubDiscoveryProcessor.ts | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changeset/curvy-pugs-type.md diff --git a/.changeset/curvy-pugs-type.md b/.changeset/curvy-pugs-type.md new file mode 100644 index 0000000000..7e94a5b35f --- /dev/null +++ b/.changeset/curvy-pugs-type.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +GithubDiscoveryProcessor outputs locations as optional to avoid outputting errors for missing locations (see https://github.com/backstage/backstage/issues/4730). diff --git a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts index 41698e1d04..9c9aa41740 100644 --- a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts +++ b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts @@ -133,7 +133,7 @@ describe('GithubDiscoveryProcessor', () => { target: 'https://github.com/backstage/backstage/blob/master/catalog.yaml', }, - optional: false, + optional: true, }); expect(emitter).toHaveBeenCalledWith({ type: 'location', @@ -141,7 +141,7 @@ describe('GithubDiscoveryProcessor', () => { type: 'url', target: 'https://github.com/backstage/demo/blob/master/catalog.yaml', }, - optional: false, + optional: true, }); }); @@ -175,7 +175,7 @@ describe('GithubDiscoveryProcessor', () => { target: 'https://github.com/backstage/techdocs-cli/blob/master/catalog.yaml', }, - optional: false, + optional: true, }); expect(emitter).toHaveBeenCalledWith({ type: 'location', @@ -184,7 +184,7 @@ describe('GithubDiscoveryProcessor', () => { target: 'https://github.com/backstage/techdocs-container/blob/master/catalog.yaml', }, - optional: false, + optional: true, }); }); it('filter unrelated repositories', async () => { @@ -215,7 +215,7 @@ describe('GithubDiscoveryProcessor', () => { type: 'url', target: 'https://github.com/backstage/test/blob/master/catalog.yaml', }, - optional: false, + optional: true, }); }); }); diff --git a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts index 9af247fd25..983db66de4 100644 --- a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts +++ b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts @@ -94,7 +94,7 @@ export class GithubDiscoveryProcessor implements CatalogProcessor { type: 'url', target: `${repository.url}${catalogPath}`, }, - false, + true, ), ); } From 2eab0de64515fbf2f2925b43e04f0a17bd77fa19 Mon Sep 17 00:00:00 2001 From: Nir Gazit Date: Mon, 1 Mar 2021 09:27:01 +0200 Subject: [PATCH 2/3] Added comment explaining why emitting optional locations --- .../src/ingestion/processors/GithubDiscoveryProcessor.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts index 983db66de4..f5d317444e 100644 --- a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts +++ b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts @@ -94,6 +94,9 @@ export class GithubDiscoveryProcessor implements CatalogProcessor { type: 'url', target: `${repository.url}${catalogPath}`, }, + // Not all locations may actually exist, since the user defined them as a wildcard pattern. + // Thus, we omit them as optional and let the downstream processor find them while not outputting + // an error if it couldn't. true, ), ); From 80475c9af2cf6bdb1dbe39c3d2f047fca691acee Mon Sep 17 00:00:00 2001 From: Nir Gazit Date: Mon, 1 Mar 2021 10:14:52 +0200 Subject: [PATCH 3/3] Fixed typo --- .../src/ingestion/processors/GithubDiscoveryProcessor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts index f5d317444e..34f7fa2782 100644 --- a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts +++ b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.ts @@ -95,7 +95,7 @@ export class GithubDiscoveryProcessor implements CatalogProcessor { target: `${repository.url}${catalogPath}`, }, // Not all locations may actually exist, since the user defined them as a wildcard pattern. - // Thus, we omit them as optional and let the downstream processor find them while not outputting + // Thus, we emit them as optional and let the downstream processor find them while not outputting // an error if it couldn't. true, ),