From 9248b06316302fe610bde4ea6dac0d79776afef7 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Fri, 10 May 2024 13:33:12 +0200 Subject: [PATCH] github-org: add org cleaner provider Signed-off-by: Vincenzo Scamporlino --- .../src/GithubOrgEntityCleanerProvider.tsx | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 plugins/catalog-backend-module-github-org/src/GithubOrgEntityCleanerProvider.tsx diff --git a/plugins/catalog-backend-module-github-org/src/GithubOrgEntityCleanerProvider.tsx b/plugins/catalog-backend-module-github-org/src/GithubOrgEntityCleanerProvider.tsx new file mode 100644 index 0000000000..386fd367c2 --- /dev/null +++ b/plugins/catalog-backend-module-github-org/src/GithubOrgEntityCleanerProvider.tsx @@ -0,0 +1,38 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + EntityProvider, + EntityProviderConnection, +} from '@backstage/plugin-catalog-node'; + +export class GithubOrgEntityCleanerProvider implements EntityProvider { + constructor(private readonly options: { id: string }) {} + + getProviderName() { + return `GithubOrgEntityProvider:${this.options.id}`; + } + async connect(connection: EntityProviderConnection) { + // Clean up any existing entities + connection + .applyMutation({ + type: 'full', + entities: [], + }) + .catch(error => { + console.error('Failed to clean up entities', error); + }); + } +}