Skip to content

Commit

Permalink
catalog-backend: use ScmIntegrationRegistry interface properly
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
  • Loading branch information
freben committed Feb 12, 2022
1 parent a57621b commit 379da9f
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 21 deletions.
13 changes: 13 additions & 0 deletions .changeset/brave-singers-burn.md
@@ -0,0 +1,13 @@
---
'@backstage/plugin-catalog-backend': patch
---

The following processors now properly accept an `ScmIntegrationRegistry` (an
interface) instead of an `ScmIntegrations` (which is a concrete class).

- `AzureDevOpsDiscoveryProcessor`
- `CodeOwnersProcessor`
- `GitLabDiscoveryProcessor`
- `GithubDiscoveryProcessor`
- `GithubMultiOrgReaderProcessor`
- `GithubOrgReaderProcessor`
14 changes: 8 additions & 6 deletions plugins/catalog-backend/api-report.md
Expand Up @@ -36,7 +36,6 @@ import { PluginEndpointDiscovery } from '@backstage/backend-common';
import { ResourceEntityV1alpha1 } from '@backstage/catalog-model';
import { Router } from 'express';
import { ScmIntegrationRegistry } from '@backstage/integration';
import { ScmIntegrations } from '@backstage/integration';
import { TokenManager } from '@backstage/backend-common';
import { UrlReader } from '@backstage/backend-common';
import { Validators } from '@backstage/catalog-model';
Expand Down Expand Up @@ -177,7 +176,10 @@ export class AwsS3DiscoveryProcessor implements CatalogProcessor {
//
// @public
export class AzureDevOpsDiscoveryProcessor implements CatalogProcessor {
constructor(options: { integrations: ScmIntegrations; logger: Logger_2 });
constructor(options: {
integrations: ScmIntegrationRegistry;
logger: Logger_2;
});
// (undocumented)
static fromConfig(
config: Config,
Expand Down Expand Up @@ -464,7 +466,7 @@ export type CatalogRulesEnforcer = {
// @public (undocumented)
export class CodeOwnersProcessor implements CatalogProcessor {
constructor(options: {
integrations: ScmIntegrations;
integrations: ScmIntegrationRegistry;
logger: Logger_2;
reader: UrlReader;
});
Expand Down Expand Up @@ -750,7 +752,7 @@ function generalError(
// @public
export class GithubDiscoveryProcessor implements CatalogProcessor {
constructor(options: {
integrations: ScmIntegrations;
integrations: ScmIntegrationRegistry;
logger: Logger_2;
githubCredentialsProvider?: GithubCredentialsProvider;
});
Expand All @@ -773,7 +775,7 @@ export class GithubDiscoveryProcessor implements CatalogProcessor {
// @alpha
export class GithubMultiOrgReaderProcessor implements CatalogProcessor {
constructor(options: {
integrations: ScmIntegrations;
integrations: ScmIntegrationRegistry;
logger: Logger_2;
orgs: GithubMultiOrgConfig;
githubCredentialsProvider?: GithubCredentialsProvider;
Expand Down Expand Up @@ -828,7 +830,7 @@ export class GitHubOrgEntityProvider implements EntityProvider {
// @public
export class GithubOrgReaderProcessor implements CatalogProcessor {
constructor(options: {
integrations: ScmIntegrations;
integrations: ScmIntegrationRegistry;
logger: Logger_2;
githubCredentialsProvider?: GithubCredentialsProvider;
});
Expand Down
Expand Up @@ -16,7 +16,10 @@

import { LocationSpec } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { ScmIntegrations } from '@backstage/integration';
import {
ScmIntegrationRegistry,
ScmIntegrations,
} from '@backstage/integration';
import { Logger } from 'winston';
import * as results from './results';
import { CatalogProcessor, CatalogProcessorEmit } from './types';
Expand All @@ -37,7 +40,7 @@ import { codeSearch } from './azure';
* target: https://dev.azure.com/org/project/_git/repo
**/
export class AzureDevOpsDiscoveryProcessor implements CatalogProcessor {
private readonly integrations: ScmIntegrations;
private readonly integrations: ScmIntegrationRegistry;
private readonly logger: Logger;

static fromConfig(config: Config, options: { logger: Logger }) {
Expand All @@ -49,7 +52,10 @@ export class AzureDevOpsDiscoveryProcessor implements CatalogProcessor {
});
}

constructor(options: { integrations: ScmIntegrations; logger: Logger }) {
constructor(options: {
integrations: ScmIntegrationRegistry;
logger: Logger;
}) {
this.integrations = options.integrations;
this.logger = options.logger;
}
Expand Down
Expand Up @@ -17,7 +17,10 @@
import { UrlReader } from '@backstage/backend-common';
import { Entity, LocationSpec } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { ScmIntegrations } from '@backstage/integration';
import {
ScmIntegrationRegistry,
ScmIntegrations,
} from '@backstage/integration';
import { Logger } from 'winston';
import { findCodeOwnerByTarget } from './codeowners';
import { CatalogProcessor } from './types';
Expand All @@ -35,7 +38,7 @@ const ALLOWED_LOCATION_TYPES = [
];

export class CodeOwnersProcessor implements CatalogProcessor {
private readonly integrations: ScmIntegrations;
private readonly integrations: ScmIntegrationRegistry;
private readonly logger: Logger;
private readonly reader: UrlReader;

Expand All @@ -52,7 +55,7 @@ export class CodeOwnersProcessor implements CatalogProcessor {
}

constructor(options: {
integrations: ScmIntegrations;
integrations: ScmIntegrationRegistry;
logger: Logger;
reader: UrlReader;
}) {
Expand Down
Expand Up @@ -16,7 +16,10 @@

import { LocationSpec } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import { ScmIntegrations } from '@backstage/integration';
import {
ScmIntegrationRegistry,
ScmIntegrations,
} from '@backstage/integration';
import { Logger } from 'winston';
import * as results from './results';
import { CatalogProcessor, CatalogProcessorEmit } from './types';
Expand All @@ -31,7 +34,7 @@ import {
* Extracts repositories out of an GitLab instance.
*/
export class GitLabDiscoveryProcessor implements CatalogProcessor {
private readonly integrations: ScmIntegrations;
private readonly integrations: ScmIntegrationRegistry;
private readonly logger: Logger;
private readonly cache: CacheClient;

Expand All @@ -48,7 +51,7 @@ export class GitLabDiscoveryProcessor implements CatalogProcessor {
}

private constructor(options: {
integrations: ScmIntegrations;
integrations: ScmIntegrationRegistry;
pluginCache: PluginCacheManager;
logger: Logger;
}) {
Expand Down
Expand Up @@ -19,6 +19,7 @@ import { Config } from '@backstage/config';
import {
DefaultGithubCredentialsProvider,
GithubCredentialsProvider,
ScmIntegrationRegistry,
ScmIntegrations,
} from '@backstage/integration';
import { graphql } from '@octokit/graphql';
Expand All @@ -42,7 +43,7 @@ import { CatalogProcessor, CatalogProcessorEmit } from './types';
* target: https://github.com/backstage/*\/blob/main/catalog-info.yaml
**/
export class GithubDiscoveryProcessor implements CatalogProcessor {
private readonly integrations: ScmIntegrations;
private readonly integrations: ScmIntegrationRegistry;
private readonly logger: Logger;
private readonly githubCredentialsProvider: GithubCredentialsProvider;

Expand All @@ -62,7 +63,7 @@ export class GithubDiscoveryProcessor implements CatalogProcessor {
}

constructor(options: {
integrations: ScmIntegrations;
integrations: ScmIntegrationRegistry;
logger: Logger;
githubCredentialsProvider?: GithubCredentialsProvider;
}) {
Expand Down
Expand Up @@ -21,6 +21,7 @@ import {
GithubAppCredentialsMux,
GithubCredentialsProvider,
GitHubIntegrationConfig,
ScmIntegrationRegistry,
ScmIntegrations,
} from '@backstage/integration';
import { graphql } from '@octokit/graphql';
Expand All @@ -42,7 +43,7 @@ import { buildOrgHierarchy } from './util/org';
* Be aware that this processor may not be compatible with future org structures in the catalog.
*/
export class GithubMultiOrgReaderProcessor implements CatalogProcessor {
private readonly integrations: ScmIntegrations;
private readonly integrations: ScmIntegrationRegistry;
private readonly orgs: GithubMultiOrgConfig;
private readonly logger: Logger;
private readonly githubCredentialsProvider: GithubCredentialsProvider;
Expand All @@ -65,7 +66,7 @@ export class GithubMultiOrgReaderProcessor implements CatalogProcessor {
}

constructor(options: {
integrations: ScmIntegrations;
integrations: ScmIntegrationRegistry;
logger: Logger;
orgs: GithubMultiOrgConfig;
githubCredentialsProvider?: GithubCredentialsProvider;
Expand Down
Expand Up @@ -18,6 +18,7 @@ import { LocationSpec } from '@backstage/catalog-model';
import { Config } from '@backstage/config';
import {
GithubCredentialType,
ScmIntegrationRegistry,
ScmIntegrations,
GithubCredentialsProvider,
DefaultGithubCredentialsProvider,
Expand All @@ -39,7 +40,7 @@ type GraphQL = typeof graphql;
* Extracts teams and users out of a GitHub org.
*/
export class GithubOrgReaderProcessor implements CatalogProcessor {
private readonly integrations: ScmIntegrations;
private readonly integrations: ScmIntegrationRegistry;
private readonly logger: Logger;
private readonly githubCredentialsProvider: GithubCredentialsProvider;

Expand All @@ -59,7 +60,7 @@ export class GithubOrgReaderProcessor implements CatalogProcessor {
}

constructor(options: {
integrations: ScmIntegrations;
integrations: ScmIntegrationRegistry;
logger: Logger;
githubCredentialsProvider?: GithubCredentialsProvider;
}) {
Expand Down

0 comments on commit 379da9f

Please sign in to comment.