add check for externalized processors

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-03-10 11:25:58 +01:00
parent 2a1670bae9
commit a6e2851902
2 changed files with 88 additions and 0 deletions
@@ -549,6 +549,8 @@ export class CatalogBuilder {
// Add the ones (if any) that the user added
processors.push(...this.processors);
this.checkMissingExternalProcessors(processors);
return processors;
}
@@ -577,4 +579,88 @@ export class CatalogBuilder {
);
}
}
// TODO(freben): This can be removed no sooner than June 2022, after adopters have had some time to adapt to the new package structure
private checkMissingExternalProcessors(processors: CatalogProcessor[]) {
const skipCheckVarName = 'BACKSTAGE_CATALOG_SKIP_MISSING_PROCESSORS_CHECK';
if (process.env[skipCheckVarName]) {
return;
}
const locationTypes = new Set(
this.env.config
.getOptionalConfigArray('catalog.locations')
?.map(l => l.getString('type')) ?? [],
);
const processorNames = new Set(processors.map(p => p.getProcessorName()));
function check(
locationType: string,
processorName: string,
installationUrl: string,
) {
if (
locationTypes.has(locationType) &&
!processorNames.has(processorName)
) {
throw new Error(
[
`Your config contains a "catalog.locations" entry of type ${locationType},`,
`but does not have the corresponding catalog processor ${processorName} installed.`,
`This processor used to be built into the catalog itself, but is now moved to an`,
`external module that has to be installed manually. Please follow the installation`,
`instructions at ${installationUrl} if you are using this ability, or remove the`,
`location from your app config if you do not. You can also silence this check entirely`,
`by setting the environment variable ${skipCheckVarName} to 'true'.`,
].join(' '),
);
}
}
check(
'aws-cloud-accounts',
'AwsOrganizationCloudAccountProcessor',
'https://backstage.io/docs/integrations',
);
check(
's3-discovery',
'AwsS3DiscoveryProcessor',
'https://backstage.io/docs/integrations/aws-s3/discovery',
);
check(
'azure-discovery',
'AzureDevOpsDiscoveryProcessor',
'https://backstage.io/docs/integrations/azure/discovery',
);
check(
'bitbucket-discovery',
'BitbucketDiscoveryProcessor',
'https://backstage.io/docs/integrations/bitbucket/discovery',
);
check(
'github-discovery',
'GithubDiscoveryProcessor',
'https://backstage.io/docs/integrations/github/discovery',
);
check(
'github-org',
'GithubOrgReaderProcessor',
'https://backstage.io/docs/integrations/github/org',
);
check(
'gitlab-discovery',
'GitLabDiscoveryProcessor',
'https://backstage.io/docs/integrations/gitlab/discovery',
);
check(
'ldap-org',
'LdapOrgReaderProcessor',
'https://backstage.io/docs/integrations/ldap/org',
);
check(
'microsoft-graph-org',
'MicrosoftGraphOrgReaderProcessor',
'https://backstage.io/docs/integrations/azure/org',
);
}
}
+2
View File
@@ -224,6 +224,8 @@ const NO_WARNING_PACKAGES = [
'plugins/catalog-backend',
'plugins/catalog-backend-module-aws',
'plugins/catalog-backend-module-azure',
'plugins/catalog-backend-module-bitbucket',
'plugins/catalog-backend-module-github',
'plugins/catalog-backend-module-gitlab',
'plugins/catalog-backend-module-ldap',
'plugins/catalog-backend-module-msgraph',