review comments

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-03-10 09:18:04 +01:00
parent 47a5ae5dd2
commit 80724779ca
6 changed files with 30 additions and 40 deletions
+1 -1
View File
@@ -34,4 +34,4 @@
**BREAKING**: Removed `AzureDevOpsDiscoveryProcessor`, which now instead should be imported from `@backstage/plugin-catalog-backend-module-azure`. This processor was not part of the set of default processors. If you were using it, you should already have a reference to it in your backend code and only need to update the import.
**BREAKING**: Removed the formerly deprecated type `BitbucketRepositoryParser`, which is no longer necessary since its only use was in `BitbucketDiscoveryProcessor` but is now instead inlined there.
**BREAKING**: Removed the formerly deprecated type `BitbucketRepositoryParser`, which is instead reintroduced in `@backstage/plugin-catalog-backend-module-bitbucket`.
@@ -16,24 +16,14 @@ import { ScmIntegrationRegistry } from '@backstage/integration';
export class BitbucketDiscoveryProcessor implements CatalogProcessor {
constructor(options: {
integrations: ScmIntegrationRegistry;
parser?: (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
parser?: BitbucketRepositoryParser;
logger: Logger;
});
// (undocumented)
static fromConfig(
config: Config,
options: {
parser?: (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
parser?: BitbucketRepositoryParser;
logger: Logger;
},
): BitbucketDiscoveryProcessor;
@@ -46,4 +36,12 @@ export class BitbucketDiscoveryProcessor implements CatalogProcessor {
emit: CatalogProcessorEmit,
): Promise<boolean>;
}
// @public
export type BitbucketRepositoryParser = (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
```
@@ -33,12 +33,12 @@
"start": "backstage-cli package start"
},
"dependencies": {
"@backstage/backend-common": "^0.12.0",
"@backstage/catalog-model": "^0.12.0",
"@backstage/backend-common": "^0.13.0-next.0",
"@backstage/catalog-model": "^0.13.0-next.0",
"@backstage/config": "^0.1.15",
"@backstage/errors": "^0.2.2",
"@backstage/integration": "^0.8.0",
"@backstage/plugin-catalog-backend": "^0.23.0",
"@backstage/plugin-catalog-backend": "^0.24.0-next.0",
"@backstage/types": "^0.1.3",
"lodash": "^4.17.21",
"msw": "^0.35.0",
@@ -46,8 +46,8 @@
"winston": "^3.2.1"
},
"devDependencies": {
"@backstage/backend-test-utils": "^0.1.20",
"@backstage/cli": "^0.15.0",
"@backstage/backend-test-utils": "^0.1.21-next.0",
"@backstage/cli": "^0.15.2-next.0",
"@types/lodash": "^4.14.151"
},
"files": [
@@ -23,7 +23,6 @@ import {
import {
CatalogProcessor,
CatalogProcessorEmit,
CatalogProcessorResult,
LocationSpec,
} from '@backstage/plugin-catalog-backend';
import { Logger } from 'winston';
@@ -31,6 +30,7 @@ import {
BitbucketClient,
BitbucketRepository,
BitbucketRepository20,
BitbucketRepositoryParser,
defaultRepositoryParser,
paginated,
paginated20,
@@ -42,23 +42,13 @@ const DEFAULT_CATALOG_LOCATION = '/catalog-info.yaml';
/** @public */
export class BitbucketDiscoveryProcessor implements CatalogProcessor {
private readonly integrations: ScmIntegrationRegistry;
private readonly parser: (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
private readonly parser: BitbucketRepositoryParser;
private readonly logger: Logger;
static fromConfig(
config: Config,
options: {
parser?: (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
parser?: BitbucketRepositoryParser;
logger: Logger;
},
) {
@@ -72,12 +62,7 @@ export class BitbucketDiscoveryProcessor implements CatalogProcessor {
constructor(options: {
integrations: ScmIntegrationRegistry;
parser?: (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
parser?: BitbucketRepositoryParser;
logger: Logger;
}) {
this.integrations = options.integrations;
@@ -122,7 +107,7 @@ export class BitbucketDiscoveryProcessor implements CatalogProcessor {
const { scanned, matches } = isBitbucketCloud
? await this.processCloudRepositories(processOptions)
: await this.processOrganisationRepositories(processOptions);
: await this.processOrganizationRepositories(processOptions);
const duration = ((Date.now() - startTimestamp) / 1000).toFixed(1);
this.logger.debug(
@@ -159,7 +144,7 @@ export class BitbucketDiscoveryProcessor implements CatalogProcessor {
};
}
private async processOrganisationRepositories(
private async processOrganizationRepositories(
options: ProcessOptions,
): Promise<ResultSummary> {
const { client, location, integration, emit } = options;
@@ -15,9 +15,10 @@
*/
/**
* A Backstage catalog backend module that helps integrate towards GitLab
* A Backstage catalog backend module that helps integrate towards Bitbucket
*
* @packageDocumentation
*/
export { BitbucketDiscoveryProcessor } from './BitbucketDiscoveryProcessor';
export type { BitbucketRepositoryParser } from './lib/BitbucketRepositoryParser';
@@ -21,6 +21,12 @@ import {
} from '@backstage/plugin-catalog-backend';
import { Logger } from 'winston';
/**
* A custom callback that reacts to finding a repository by yielding processing
* results.
*
* @public
*/
export type BitbucketRepositoryParser = (options: {
integration: BitbucketIntegration;
target: string;