diff --git a/.changeset/gorgeous-queens-pull.md b/.changeset/gorgeous-queens-pull.md new file mode 100644 index 0000000000..bb257e85f0 --- /dev/null +++ b/.changeset/gorgeous-queens-pull.md @@ -0,0 +1,14 @@ +--- +'@backstage/integration': minor +--- + +Replaces in-code uses of `GitHub` with `Github` and deprecates old versions. + +Deprecates: + +- `getGitHubFileFetchUrl` replaced by `getGithubFileFetchUrl` +- `GitHubIntegrationConfig` replaced by `GithubIntegrationConfig` +- `GitHubIntegration` replaced by `GithubIntegration` +- `readGitHubIntegrationConfig` replaced by `readGithubIntegrationConfig` +- `readGitHubIntegrationConfigs` replaced by `readGithubIntegrationConfigs` +- `replaceGitHubUrlType` replaced by `replaceGithubUrlType` diff --git a/.changeset/sixty-pigs-shave.md b/.changeset/sixty-pigs-shave.md new file mode 100644 index 0000000000..e1f4443ad4 --- /dev/null +++ b/.changeset/sixty-pigs-shave.md @@ -0,0 +1,13 @@ +--- +'@backstage/backend-common': patch +'@backstage/plugin-catalog-backend-module-github': patch +'@backstage/plugin-catalog-import': patch +'@backstage/plugin-git-release-manager': patch +'@backstage/plugin-github-actions': patch +'@backstage/plugin-github-issues': patch +'@backstage/plugin-github-pull-requests-board': patch +'@backstage/plugin-techdocs': patch +'@backstage/plugin-techdocs-module-addons-contrib': patch +--- + +Replaces in-code uses of `GitHub` with `Github` and deprecates old versions. diff --git a/packages/backend-common/api-report.md b/packages/backend-common/api-report.md index 600e3edef8..7e42157d8d 100644 --- a/packages/backend-common/api-report.md +++ b/packages/backend-common/api-report.md @@ -22,7 +22,7 @@ import { ErrorRequestHandler } from 'express'; import express from 'express'; import { GerritIntegration } from '@backstage/integration'; import { GithubCredentialsProvider } from '@backstage/integration'; -import { GitHubIntegration } from '@backstage/integration'; +import { GithubIntegration } from '@backstage/integration'; import { GitLabIntegration } from '@backstage/integration'; import { isChildPath } from '@backstage/cli-common'; import { JsonValue } from '@backstage/types'; @@ -409,7 +409,7 @@ export class Git { // @public export class GithubUrlReader implements UrlReader { constructor( - integration: GitHubIntegration, + integration: GithubIntegration, deps: { treeResponseFactory: ReadTreeResponseFactory; credentialsProvider: GithubCredentialsProvider; diff --git a/packages/backend-common/src/reading/GithubUrlReader.test.ts b/packages/backend-common/src/reading/GithubUrlReader.test.ts index fddb728648..a5f9d26de5 100644 --- a/packages/backend-common/src/reading/GithubUrlReader.test.ts +++ b/packages/backend-common/src/reading/GithubUrlReader.test.ts @@ -17,8 +17,8 @@ import { ConfigReader } from '@backstage/config'; import { GithubCredentialsProvider, - GitHubIntegration, - readGitHubIntegrationConfig, + GithubIntegration, + readGithubIntegrationConfig, } from '@backstage/integration'; import { setupRequestMockHandlers } from '@backstage/backend-test-utils'; import fs from 'fs-extra'; @@ -46,8 +46,8 @@ const mockCredentialsProvider = { } as unknown as GithubCredentialsProvider; const githubProcessor = new GithubUrlReader( - new GitHubIntegration( - readGitHubIntegrationConfig( + new GithubIntegration( + readGithubIntegrationConfig( new ConfigReader({ host: 'github.com', apiBaseUrl: 'https://api.github.com', @@ -58,8 +58,8 @@ const githubProcessor = new GithubUrlReader( ); const gheProcessor = new GithubUrlReader( - new GitHubIntegration( - readGitHubIntegrationConfig( + new GithubIntegration( + readGithubIntegrationConfig( new ConfigReader({ host: 'ghe.github.com', apiBaseUrl: 'https://ghe.github.com/api/v3', @@ -539,8 +539,8 @@ describe('GithubUrlReader', () => { expect(() => { /* eslint-disable no-new */ new GithubUrlReader( - new GitHubIntegration( - readGitHubIntegrationConfig( + new GithubIntegration( + readGithubIntegrationConfig( new ConfigReader({ host: 'ghe.mycompany.net', }), diff --git a/packages/backend-common/src/reading/GithubUrlReader.ts b/packages/backend-common/src/reading/GithubUrlReader.ts index 3806253a6f..7abf1b2518 100644 --- a/packages/backend-common/src/reading/GithubUrlReader.ts +++ b/packages/backend-common/src/reading/GithubUrlReader.ts @@ -15,10 +15,10 @@ */ import { - getGitHubFileFetchUrl, + getGithubFileFetchUrl, DefaultGithubCredentialsProvider, GithubCredentialsProvider, - GitHubIntegration, + GithubIntegration, ScmIntegrations, } from '@backstage/integration'; import { RestEndpointMethodTypes } from '@octokit/rest'; @@ -72,7 +72,7 @@ export class GithubUrlReader implements UrlReader { }; constructor( - private readonly integration: GitHubIntegration, + private readonly integration: GithubIntegration, private readonly deps: { treeResponseFactory: ReadTreeResponseFactory; credentialsProvider: GithubCredentialsProvider; @@ -97,7 +97,7 @@ export class GithubUrlReader implements UrlReader { const credentials = await this.deps.credentialsProvider.getCredentials({ url, }); - const ghUrl = getGitHubFileFetchUrl( + const ghUrl = getGithubFileFetchUrl( url, this.integration.config, credentials, diff --git a/packages/integration/api-report.md b/packages/integration/api-report.md index cf52bec65b..0f24ded066 100644 --- a/packages/integration/api-report.md +++ b/packages/integration/api-report.md @@ -323,16 +323,19 @@ export function getGerritRequestOptions(config: GerritIntegrationConfig): { headers?: Record; }; +// @public @deprecated (undocumented) +export const getGitHubFileFetchUrl: typeof getGithubFileFetchUrl; + // @public -export function getGitHubFileFetchUrl( +export function getGithubFileFetchUrl( url: string, - config: GitHubIntegrationConfig, + config: GithubIntegrationConfig, credentials: GithubCredentials, ): string; // @public @deprecated export function getGitHubRequestOptions( - config: GitHubIntegrationConfig, + config: GithubIntegrationConfig, credentials: GithubCredentials, ): { headers: Record; @@ -366,7 +369,7 @@ export type GithubAppConfig = { // @public export class GithubAppCredentialsMux { - constructor(config: GitHubIntegrationConfig); + constructor(config: GithubIntegrationConfig); // (undocumented) getAllInstallations(): Promise< RestEndpointMethodTypes['apps']['listInstallations']['response']['data'] @@ -393,13 +396,22 @@ export interface GithubCredentialsProvider { // @public export type GithubCredentialType = 'app' | 'token'; -// @public -export class GitHubIntegration implements ScmIntegration { +// @public @deprecated (undocumented) +export class GitHubIntegration extends GithubIntegration { constructor(integrationConfig: GitHubIntegrationConfig); // (undocumented) get config(): GitHubIntegrationConfig; // (undocumented) static factory: ScmIntegrationsFactory; +} + +// @public +export class GithubIntegration implements ScmIntegration { + constructor(integrationConfig: GithubIntegrationConfig); + // (undocumented) + get config(): GithubIntegrationConfig; + // (undocumented) + static factory: ScmIntegrationsFactory; // (undocumented) resolveEditUrl(url: string): string; // (undocumented) @@ -414,8 +426,11 @@ export class GitHubIntegration implements ScmIntegration { get type(): string; } +// @public @deprecated (undocumented) +export type GitHubIntegrationConfig = GithubIntegrationConfig; + // @public -export type GitHubIntegrationConfig = { +export type GithubIntegrationConfig = { host: string; apiBaseUrl?: string; rawBaseUrl?: string; @@ -473,7 +488,7 @@ export interface IntegrationsByType { // (undocumented) gerrit: ScmIntegrationsGroup; // (undocumented) - github: ScmIntegrationsGroup; + github: ScmIntegrationsGroup; // (undocumented) gitlab: ScmIntegrationsGroup; } @@ -551,15 +566,21 @@ export function readGerritIntegrationConfigs( configs: Config[], ): GerritIntegrationConfig[]; -// @public -export function readGitHubIntegrationConfig( - config: Config, -): GitHubIntegrationConfig; +// @public @deprecated (undocumented) +export const readGitHubIntegrationConfig: typeof readGithubIntegrationConfig; // @public -export function readGitHubIntegrationConfigs( +export function readGithubIntegrationConfig( + config: Config, +): GithubIntegrationConfig; + +// @public @deprecated (undocumented) +export const readGitHubIntegrationConfigs: typeof readGithubIntegrationConfigs; + +// @public +export function readGithubIntegrationConfigs( configs: Config[], -): GitHubIntegrationConfig[]; +): GithubIntegrationConfig[]; // @public export function readGitLabIntegrationConfig( @@ -576,8 +597,11 @@ export function readGoogleGcsIntegrationConfig( config: Config, ): GoogleGcsIntegrationConfig; +// @public @deprecated (undocumented) +export const replaceGitHubUrlType: typeof replaceGithubUrlType; + // @public -export function replaceGitHubUrlType( +export function replaceGithubUrlType( url: string, type: 'blob' | 'tree' | 'edit', ): string; @@ -616,7 +640,7 @@ export interface ScmIntegrationRegistry // (undocumented) gerrit: ScmIntegrationsGroup; // (undocumented) - github: ScmIntegrationsGroup; + github: ScmIntegrationsGroup; // (undocumented) gitlab: ScmIntegrationsGroup; resolveEditUrl(url: string): string; @@ -649,7 +673,7 @@ export class ScmIntegrations implements ScmIntegrationRegistry { // (undocumented) get gerrit(): ScmIntegrationsGroup; // (undocumented) - get github(): ScmIntegrationsGroup; + get github(): ScmIntegrationsGroup; // (undocumented) get gitlab(): ScmIntegrationsGroup; // (undocumented) @@ -681,7 +705,7 @@ export class SingleInstanceGithubCredentialsProvider implements GithubCredentialsProvider { // (undocumented) - static create: (config: GitHubIntegrationConfig) => GithubCredentialsProvider; + static create: (config: GithubIntegrationConfig) => GithubCredentialsProvider; getCredentials(opts: { url: string }): Promise; } ``` diff --git a/packages/integration/src/ScmIntegrations.test.ts b/packages/integration/src/ScmIntegrations.test.ts index d9fcaf36f0..f5fd480609 100644 --- a/packages/integration/src/ScmIntegrations.test.ts +++ b/packages/integration/src/ScmIntegrations.test.ts @@ -29,8 +29,8 @@ import { } from './bitbucketServer'; import { GerritIntegrationConfig } from './gerrit'; import { GerritIntegration } from './gerrit/GerritIntegration'; -import { GitHubIntegrationConfig } from './github'; -import { GitHubIntegration } from './github/GitHubIntegration'; +import { GithubIntegrationConfig } from './github'; +import { GithubIntegration } from './github/GithubIntegration'; import { GitLabIntegrationConfig } from './gitlab'; import { GitLabIntegration } from './gitlab/GitLabIntegration'; import { basicIntegrations } from './helpers'; @@ -61,9 +61,9 @@ describe('ScmIntegrations', () => { host: 'gerrit.local', } as GerritIntegrationConfig); - const github = new GitHubIntegration({ + const github = new GithubIntegration({ host: 'github.local', - } as GitHubIntegrationConfig); + } as GithubIntegrationConfig); const gitlab = new GitLabIntegration({ host: 'gitlab.local', diff --git a/packages/integration/src/ScmIntegrations.ts b/packages/integration/src/ScmIntegrations.ts index 6d745dcf1c..f5decebc66 100644 --- a/packages/integration/src/ScmIntegrations.ts +++ b/packages/integration/src/ScmIntegrations.ts @@ -21,7 +21,7 @@ import { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegr import { BitbucketIntegration } from './bitbucket/BitbucketIntegration'; import { BitbucketServerIntegration } from './bitbucketServer/BitbucketServerIntegration'; import { GerritIntegration } from './gerrit/GerritIntegration'; -import { GitHubIntegration } from './github/GitHubIntegration'; +import { GithubIntegration } from './github/GithubIntegration'; import { GitLabIntegration } from './gitlab/GitLabIntegration'; import { defaultScmResolveUrl } from './helpers'; import { ScmIntegration, ScmIntegrationsGroup } from './types'; @@ -42,7 +42,7 @@ export interface IntegrationsByType { bitbucketCloud: ScmIntegrationsGroup; bitbucketServer: ScmIntegrationsGroup; gerrit: ScmIntegrationsGroup; - github: ScmIntegrationsGroup; + github: ScmIntegrationsGroup; gitlab: ScmIntegrationsGroup; } @@ -62,7 +62,7 @@ export class ScmIntegrations implements ScmIntegrationRegistry { bitbucketCloud: BitbucketCloudIntegration.factory({ config }), bitbucketServer: BitbucketServerIntegration.factory({ config }), gerrit: GerritIntegration.factory({ config }), - github: GitHubIntegration.factory({ config }), + github: GithubIntegration.factory({ config }), gitlab: GitLabIntegration.factory({ config }), }); } @@ -98,7 +98,7 @@ export class ScmIntegrations implements ScmIntegrationRegistry { return this.byType.gerrit; } - get github(): ScmIntegrationsGroup { + get github(): ScmIntegrationsGroup { return this.byType.github; } diff --git a/packages/integration/src/github/DefaultGithubCredentialsProvider.test.ts b/packages/integration/src/github/DefaultGithubCredentialsProvider.test.ts index 7c2b53e822..98b8edecef 100644 --- a/packages/integration/src/github/DefaultGithubCredentialsProvider.test.ts +++ b/packages/integration/src/github/DefaultGithubCredentialsProvider.test.ts @@ -15,7 +15,7 @@ */ import { ScmIntegrations } from '../ScmIntegrations'; -import { GitHubIntegrationConfig } from './config'; +import { GithubIntegrationConfig } from './config'; import { SingleInstanceGithubCredentialsProvider } from './SingleInstanceGithubCredentialsProvider'; import { DefaultGithubCredentialsProvider } from './DefaultGithubCredentialsProvider'; @@ -65,7 +65,7 @@ describe('DefaultGithubCredentialsProvider tests', () => { ); jest.resetAllMocks(); SingleInstanceGithubCredentialsProvider.create = ( - config: GitHubIntegrationConfig, + config: GithubIntegrationConfig, ) => { return { getCredentials: (_opts: { url: string }) => { diff --git a/packages/integration/src/github/GitHubIntegration.test.ts b/packages/integration/src/github/GithubIntegration.test.ts similarity index 86% rename from packages/integration/src/github/GitHubIntegration.test.ts rename to packages/integration/src/github/GithubIntegration.test.ts index ccceb34d88..d8e6020a64 100644 --- a/packages/integration/src/github/GitHubIntegration.test.ts +++ b/packages/integration/src/github/GithubIntegration.test.ts @@ -15,11 +15,11 @@ */ import { ConfigReader } from '@backstage/config'; -import { GitHubIntegration, replaceGitHubUrlType } from './GitHubIntegration'; +import { GithubIntegration, replaceGithubUrlType } from './GithubIntegration'; -describe('GitHubIntegration', () => { +describe('GithubIntegration', () => { it('has a working factory', () => { - const integrations = GitHubIntegration.factory({ + const integrations = GithubIntegration.factory({ config: new ConfigReader({ integrations: { github: [ @@ -39,7 +39,7 @@ describe('GitHubIntegration', () => { }); it('returns the basics', () => { - const integration = new GitHubIntegration({ + const integration = new GithubIntegration({ host: 'h.com', apiBaseUrl: 'a', rawBaseUrl: 'r', @@ -51,7 +51,7 @@ describe('GitHubIntegration', () => { }); it('resolveUrl', () => { - const integration = new GitHubIntegration({ host: 'h.com' }); + const integration = new GithubIntegration({ host: 'h.com' }); expect( integration.resolveUrl({ @@ -70,7 +70,7 @@ describe('GitHubIntegration', () => { }); it('resolve edit URL', () => { - const integration = new GitHubIntegration({ host: 'h.com' }); + const integration = new GithubIntegration({ host: 'h.com' }); expect( integration.resolveEditUrl( @@ -80,28 +80,28 @@ describe('GitHubIntegration', () => { }); }); -describe('replaceGitHubUrlType', () => { +describe('replaceGithubUrlType', () => { it('should replace with expected type', () => { expect( - replaceGitHubUrlType( + replaceGithubUrlType( 'https://github.com/backstage/backstage/blob/master/README.md', 'edit', ), ).toBe('https://github.com/backstage/backstage/edit/master/README.md'); expect( - replaceGitHubUrlType( + replaceGithubUrlType( 'https://github.com/webmodules/blob/blob/master/test', 'tree', ), ).toBe('https://github.com/webmodules/blob/tree/master/test'); expect( - replaceGitHubUrlType( + replaceGithubUrlType( 'https://github.com/blob/blob/blob/master/test', 'tree', ), ).toBe('https://github.com/blob/blob/tree/master/test'); expect( - replaceGitHubUrlType( + replaceGithubUrlType( 'https://github.com/backstage/backstage/edit/tree/README.md', 'blob', ), diff --git a/packages/integration/src/github/GitHubIntegration.ts b/packages/integration/src/github/GithubIntegration.ts similarity index 78% rename from packages/integration/src/github/GitHubIntegration.ts rename to packages/integration/src/github/GithubIntegration.ts index 1db0b1fae5..50fc129ccf 100644 --- a/packages/integration/src/github/GitHubIntegration.ts +++ b/packages/integration/src/github/GithubIntegration.ts @@ -17,8 +17,8 @@ import { basicIntegrations, defaultScmResolveUrl } from '../helpers'; import { ScmIntegration, ScmIntegrationsFactory } from '../types'; import { - GitHubIntegrationConfig, - readGitHubIntegrationConfigs, + GithubIntegrationConfig, + readGithubIntegrationConfigs, } from './config'; /** @@ -26,18 +26,18 @@ import { * * @public */ -export class GitHubIntegration implements ScmIntegration { - static factory: ScmIntegrationsFactory = ({ config }) => { - const configs = readGitHubIntegrationConfigs( +export class GithubIntegration implements ScmIntegration { + static factory: ScmIntegrationsFactory = ({ config }) => { + const configs = readGithubIntegrationConfigs( config.getOptionalConfigArray('integrations.github') ?? [], ); return basicIntegrations( - configs.map(c => new GitHubIntegration(c)), + configs.map(c => new GithubIntegration(c)), i => i.config.host, ); }; - constructor(private readonly integrationConfig: GitHubIntegrationConfig) {} + constructor(private readonly integrationConfig: GithubIntegrationConfig) {} get type(): string { return 'github'; @@ -47,7 +47,7 @@ export class GitHubIntegration implements ScmIntegration { return this.integrationConfig.host; } - get config(): GitHubIntegrationConfig { + get config(): GithubIntegrationConfig { return this.integrationConfig; } @@ -59,11 +59,11 @@ export class GitHubIntegration implements ScmIntegration { // GitHub uses blob URLs for files and tree urls for directory listings. But // there is a redirect from tree to blob for files, so we can always return // tree urls here. - return replaceGitHubUrlType(defaultScmResolveUrl(options), 'tree'); + return replaceGithubUrlType(defaultScmResolveUrl(options), 'tree'); } resolveEditUrl(url: string): string { - return replaceGitHubUrlType(url, 'edit'); + return replaceGithubUrlType(url, 'edit'); } } @@ -74,7 +74,7 @@ export class GitHubIntegration implements ScmIntegration { * @param type - The desired type, e.g. "blob" * @public */ -export function replaceGitHubUrlType( +export function replaceGithubUrlType( url: string, type: 'blob' | 'tree' | 'edit', ): string { diff --git a/packages/integration/src/github/SingleInstanceGithubCredentialsProvider.ts b/packages/integration/src/github/SingleInstanceGithubCredentialsProvider.ts index 02f050f69f..d42ad4597d 100644 --- a/packages/integration/src/github/SingleInstanceGithubCredentialsProvider.ts +++ b/packages/integration/src/github/SingleInstanceGithubCredentialsProvider.ts @@ -15,7 +15,7 @@ */ import parseGitUrl from 'git-url-parse'; -import { GithubAppConfig, GitHubIntegrationConfig } from './config'; +import { GithubAppConfig, GithubIntegrationConfig } from './config'; import { createAppAuth } from '@octokit/auth-app'; import { Octokit, RestEndpointMethodTypes } from '@octokit/rest'; import { DateTime } from 'luxon'; @@ -199,7 +199,7 @@ class GithubAppManager { export class GithubAppCredentialsMux { private readonly apps: GithubAppManager[]; - constructor(config: GitHubIntegrationConfig) { + constructor(config: GithubIntegrationConfig) { this.apps = config.apps?.map(ac => new GithubAppManager(ac, config.apiBaseUrl)) ?? []; } @@ -259,7 +259,7 @@ export class SingleInstanceGithubCredentialsProvider implements GithubCredentialsProvider { static create: ( - config: GitHubIntegrationConfig, + config: GithubIntegrationConfig, ) => GithubCredentialsProvider = config => { return new SingleInstanceGithubCredentialsProvider( new GithubAppCredentialsMux(config), diff --git a/packages/integration/src/github/config.test.ts b/packages/integration/src/github/config.test.ts index 73efb4f81a..c4d9eb1900 100644 --- a/packages/integration/src/github/config.test.ts +++ b/packages/integration/src/github/config.test.ts @@ -17,18 +17,18 @@ import { Config, ConfigReader } from '@backstage/config'; import { loadConfigSchema } from '@backstage/config-loader'; import { - GitHubIntegrationConfig, - readGitHubIntegrationConfig, - readGitHubIntegrationConfigs, + GithubIntegrationConfig, + readGithubIntegrationConfig, + readGithubIntegrationConfigs, } from './config'; -describe('readGitHubIntegrationConfig', () => { - function buildConfig(provider: Partial) { +describe('readGithubIntegrationConfig', () => { + function buildConfig(provider: Partial) { return new ConfigReader(provider); } async function buildFrontendConfig( - data: Partial, + data: Partial, ): Promise { const fullSchema = await loadConfigSchema({ dependencies: ['@backstage/integration'], @@ -52,7 +52,7 @@ describe('readGitHubIntegrationConfig', () => { } it('reads all values', () => { - const output = readGitHubIntegrationConfig( + const output = readGithubIntegrationConfig( buildConfig({ host: 'a.com', apiBaseUrl: 'https://a.com/api', @@ -69,7 +69,7 @@ describe('readGitHubIntegrationConfig', () => { }); it('injects the correct GitHub API base URL when missing', () => { - const output = readGitHubIntegrationConfig( + const output = readGithubIntegrationConfig( buildConfig({ host: 'github.com' }), ); expect(output).toEqual({ @@ -87,22 +87,22 @@ describe('readGitHubIntegrationConfig', () => { token: 't', }; expect(() => - readGitHubIntegrationConfig(buildConfig({ ...valid, host: 7 })), + readGithubIntegrationConfig(buildConfig({ ...valid, host: 7 })), ).toThrow(/host/); expect(() => - readGitHubIntegrationConfig(buildConfig({ ...valid, apiBaseUrl: 7 })), + readGithubIntegrationConfig(buildConfig({ ...valid, apiBaseUrl: 7 })), ).toThrow(/apiBaseUrl/); expect(() => - readGitHubIntegrationConfig(buildConfig({ ...valid, rawBaseUrl: 7 })), + readGithubIntegrationConfig(buildConfig({ ...valid, rawBaseUrl: 7 })), ).toThrow(/rawBaseUrl/); expect(() => - readGitHubIntegrationConfig(buildConfig({ ...valid, token: 7 })), + readGithubIntegrationConfig(buildConfig({ ...valid, token: 7 })), ).toThrow(/token/); }); it('works on the frontend', async () => { expect( - readGitHubIntegrationConfig( + readGithubIntegrationConfig( await buildFrontendConfig({ host: 'a.com', apiBaseUrl: 'https://a.com/api', @@ -118,15 +118,15 @@ describe('readGitHubIntegrationConfig', () => { }); }); -describe('readGitHubIntegrationConfigs', () => { +describe('readGithubIntegrationConfigs', () => { function buildConfig( - providers: Partial[], + providers: Partial[], ): Config[] { return providers.map(provider => new ConfigReader(provider)); } it('reads all values', () => { - const output = readGitHubIntegrationConfigs( + const output = readGithubIntegrationConfigs( buildConfig([ { host: 'a.com', @@ -145,7 +145,7 @@ describe('readGitHubIntegrationConfigs', () => { }); it('adds a default GitHub entry when missing', () => { - const output = readGitHubIntegrationConfigs(buildConfig([])); + const output = readGithubIntegrationConfigs(buildConfig([])); expect(output).toEqual([ { host: 'github.com', diff --git a/packages/integration/src/github/config.ts b/packages/integration/src/github/config.ts index 93801e96fb..cd76eba3d3 100644 --- a/packages/integration/src/github/config.ts +++ b/packages/integration/src/github/config.ts @@ -27,7 +27,7 @@ const GITHUB_RAW_BASE_URL = 'https://raw.githubusercontent.com'; * * @public */ -export type GitHubIntegrationConfig = { +export type GithubIntegrationConfig = { /** * The host of the target that this matches on, e.g. "github.com" */ @@ -117,9 +117,9 @@ export type GithubAppConfig = { * @param config - The config object of a single integration * @public */ -export function readGitHubIntegrationConfig( +export function readGithubIntegrationConfig( config: Config, -): GitHubIntegrationConfig { +): GithubIntegrationConfig { const host = config.getOptionalString('host') ?? GITHUB_HOST; let apiBaseUrl = config.getOptionalString('apiBaseUrl'); let rawBaseUrl = config.getOptionalString('rawBaseUrl'); @@ -163,11 +163,11 @@ export function readGitHubIntegrationConfig( * @param configs - All of the integration config objects * @public */ -export function readGitHubIntegrationConfigs( +export function readGithubIntegrationConfigs( configs: Config[], -): GitHubIntegrationConfig[] { +): GithubIntegrationConfig[] { // First read all the explicit integrations - const result = configs.map(readGitHubIntegrationConfig); + const result = configs.map(readGithubIntegrationConfig); // If no explicit github.com integration was added, put one in the list as // a convenience diff --git a/packages/integration/src/github/core.test.ts b/packages/integration/src/github/core.test.ts index c5d04f5b4f..982a096b43 100644 --- a/packages/integration/src/github/core.test.ts +++ b/packages/integration/src/github/core.test.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { GitHubIntegrationConfig } from './config'; -import { getGitHubFileFetchUrl, getGitHubRequestOptions } from './core'; +import { GithubIntegrationConfig } from './config'; +import { getGithubFileFetchUrl, getGitHubRequestOptions } from './core'; import { GithubCredentials } from './types'; describe('github core', () => { @@ -37,12 +37,12 @@ describe('github core', () => { describe('getGitHubRequestOptions', () => { it('inserts a token when needed', () => { - const withToken: GitHubIntegrationConfig = { + const withToken: GithubIntegrationConfig = { host: '', rawBaseUrl: '', token: 'A', }; - const withoutToken: GitHubIntegrationConfig = { + const withoutToken: GithubIntegrationConfig = { host: '', rawBaseUrl: '', }; @@ -57,21 +57,21 @@ describe('github core', () => { }); }); - describe('getGitHubFileFetchUrl', () => { + describe('getGithubFileFetchUrl', () => { it('rejects targets that do not look like URLs', () => { - const config: GitHubIntegrationConfig = { host: '', apiBaseUrl: '' }; - expect(() => getGitHubFileFetchUrl('a/b', config, noCredentials)).toThrow( + const config: GithubIntegrationConfig = { host: '', apiBaseUrl: '' }; + expect(() => getGithubFileFetchUrl('a/b', config, noCredentials)).toThrow( /Incorrect URL: a\/b/, ); }); it('happy path for github api', () => { - const config: GitHubIntegrationConfig = { + const config: GithubIntegrationConfig = { host: 'github.com', apiBaseUrl: 'https://api.github.com', }; expect( - getGitHubFileFetchUrl( + getGithubFileFetchUrl( 'https://github.com/a/b/blob/branchname/path/to/c.yaml', config, appCredentials, @@ -80,7 +80,7 @@ describe('github core', () => { 'https://api.github.com/repos/a/b/contents/path/to/c.yaml?ref=branchname', ); expect( - getGitHubFileFetchUrl( + getGithubFileFetchUrl( 'https://github.com/a/b/blob/branchname/path/to/c.yaml', config, tokenCredentials, @@ -91,12 +91,12 @@ describe('github core', () => { }); it('happy path for ghe api', () => { - const config: GitHubIntegrationConfig = { + const config: GithubIntegrationConfig = { host: 'ghe.mycompany.net', apiBaseUrl: 'https://ghe.mycompany.net/api/v3', }; expect( - getGitHubFileFetchUrl( + getGithubFileFetchUrl( 'https://ghe.mycompany.net/a/b/blob/branchname/path/to/c.yaml', config, appCredentials, @@ -105,7 +105,7 @@ describe('github core', () => { 'https://ghe.mycompany.net/api/v3/repos/a/b/contents/path/to/c.yaml?ref=branchname', ); expect( - getGitHubFileFetchUrl( + getGithubFileFetchUrl( 'https://ghe.mycompany.net/a/b/blob/branchname/path/to/c.yaml', config, tokenCredentials, @@ -116,12 +116,12 @@ describe('github core', () => { }); it('happy path for github tree', () => { - const config: GitHubIntegrationConfig = { + const config: GithubIntegrationConfig = { host: 'github.com', apiBaseUrl: 'https://api.github.com', }; expect( - getGitHubFileFetchUrl( + getGithubFileFetchUrl( 'https://github.com/a/b/tree/branchname/path/to/c.yaml', config, tokenCredentials, @@ -132,12 +132,12 @@ describe('github core', () => { }); it('happy path for ghe tree', () => { - const config: GitHubIntegrationConfig = { + const config: GithubIntegrationConfig = { host: 'ghe.mycompany.net', apiBaseUrl: 'https://ghe.mycompany.net/api/v3', }; expect( - getGitHubFileFetchUrl( + getGithubFileFetchUrl( 'https://ghe.mycompany.net/a/b/tree/branchname/path/to/c.yaml', config, tokenCredentials, @@ -148,12 +148,12 @@ describe('github core', () => { }); it('happy path for github raw', () => { - const config: GitHubIntegrationConfig = { + const config: GithubIntegrationConfig = { host: 'github.com', rawBaseUrl: 'https://raw.githubusercontent.com', }; expect( - getGitHubFileFetchUrl( + getGithubFileFetchUrl( 'https://github.com/a/b/blob/branchname/path/to/c.yaml', config, tokenCredentials, @@ -164,12 +164,12 @@ describe('github core', () => { }); it('happy path for ghe raw', () => { - const config: GitHubIntegrationConfig = { + const config: GithubIntegrationConfig = { host: 'ghe.mycompany.net', rawBaseUrl: 'https://ghe.mycompany.net/raw', }; expect( - getGitHubFileFetchUrl( + getGithubFileFetchUrl( 'https://ghe.mycompany.net/a/b/blob/branchname/path/to/c.yaml', config, tokenCredentials, diff --git a/packages/integration/src/github/core.ts b/packages/integration/src/github/core.ts index 5b630d5182..a755f3383c 100644 --- a/packages/integration/src/github/core.ts +++ b/packages/integration/src/github/core.ts @@ -15,7 +15,7 @@ */ import parseGitUrl from 'git-url-parse'; -import { GitHubIntegrationConfig } from './config'; +import { GithubIntegrationConfig } from './config'; import { GithubCredentials } from './types'; /** @@ -33,9 +33,9 @@ import { GithubCredentials } from './types'; * @param config - The relevant provider config * @public */ -export function getGitHubFileFetchUrl( +export function getGithubFileFetchUrl( url: string, - config: GitHubIntegrationConfig, + config: GithubIntegrationConfig, credentials: GithubCredentials, ): string { try { @@ -71,7 +71,7 @@ export function getGitHubFileFetchUrl( * @public */ export function getGitHubRequestOptions( - config: GitHubIntegrationConfig, + config: GithubIntegrationConfig, credentials: GithubCredentials, ): { headers: Record } { const headers: Record = {}; @@ -88,7 +88,7 @@ export function getGitHubRequestOptions( } export function chooseEndpoint( - config: GitHubIntegrationConfig, + config: GithubIntegrationConfig, credentials: GithubCredentials, ): 'api' | 'raw' { if (config.apiBaseUrl && (credentials.token || !config.rawBaseUrl)) { diff --git a/packages/integration/src/github/deprecated.ts b/packages/integration/src/github/deprecated.ts new file mode 100644 index 0000000000..127040c1a7 --- /dev/null +++ b/packages/integration/src/github/deprecated.ts @@ -0,0 +1,71 @@ +/* + * Copyright 2022 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 { + GithubIntegrationConfig, + readGithubIntegrationConfig, + readGithubIntegrationConfigs, +} from './config'; +import { getGithubFileFetchUrl } from './core'; +import { GithubIntegration, replaceGithubUrlType } from './GithubIntegration'; +import { ScmIntegrationsFactory } from '../types'; + +/** + * @public + * @deprecated Use {@link getGithubFileFetchUrl} instead. + */ +export const getGitHubFileFetchUrl = getGithubFileFetchUrl; + +/** + * @public + * @deprecated Use {@link GithubIntegrationConfig} instead. + */ +export type GitHubIntegrationConfig = GithubIntegrationConfig; + +/** + * @public + * @deprecated Use {@link GithubIntegration} instead. + */ +export class GitHubIntegration extends GithubIntegration { + static factory: ScmIntegrationsFactory = + GithubIntegration.factory; + + constructor(integrationConfig: GitHubIntegrationConfig) { + super(integrationConfig as GithubIntegrationConfig); + } + + get config(): GitHubIntegrationConfig { + return super.config as GitHubIntegrationConfig; + } +} + +/** + * @public + * @deprecated Use {@link readGithubIntegrationConfig} instead. + */ +export const readGitHubIntegrationConfig = readGithubIntegrationConfig; + +/** + * @public + * @deprecated Use {@link readGithubIntegrationConfigs} instead. + */ +export const readGitHubIntegrationConfigs = readGithubIntegrationConfigs; + +/** + * @public + * @deprecated Use {@link replaceGithubUrlType} instead. + */ +export const replaceGitHubUrlType = replaceGithubUrlType; diff --git a/packages/integration/src/github/index.ts b/packages/integration/src/github/index.ts index c6a7799c3d..816b0d2ff9 100644 --- a/packages/integration/src/github/index.ts +++ b/packages/integration/src/github/index.ts @@ -15,11 +15,11 @@ */ export { - readGitHubIntegrationConfig, - readGitHubIntegrationConfigs, + readGithubIntegrationConfig, + readGithubIntegrationConfigs, } from './config'; -export type { GithubAppConfig, GitHubIntegrationConfig } from './config'; -export { getGitHubFileFetchUrl, getGitHubRequestOptions } from './core'; +export type { GithubAppConfig, GithubIntegrationConfig } from './config'; +export { getGithubFileFetchUrl, getGitHubRequestOptions } from './core'; export { DefaultGithubCredentialsProvider } from './DefaultGithubCredentialsProvider'; export { GithubAppCredentialsMux, @@ -30,4 +30,6 @@ export type { GithubCredentialsProvider, GithubCredentialType, } from './types'; -export { GitHubIntegration, replaceGitHubUrlType } from './GitHubIntegration'; +export { GithubIntegration, replaceGithubUrlType } from './GithubIntegration'; + +export * from './deprecated'; diff --git a/packages/integration/src/registry.ts b/packages/integration/src/registry.ts index f4f759cfe9..debb819156 100644 --- a/packages/integration/src/registry.ts +++ b/packages/integration/src/registry.ts @@ -21,7 +21,7 @@ import { BitbucketCloudIntegration } from './bitbucketCloud/BitbucketCloudIntegr import { BitbucketIntegration } from './bitbucket/BitbucketIntegration'; import { BitbucketServerIntegration } from './bitbucketServer/BitbucketServerIntegration'; import { GerritIntegration } from './gerrit/GerritIntegration'; -import { GitHubIntegration } from './github/GitHubIntegration'; +import { GithubIntegration } from './github/GithubIntegration'; import { GitLabIntegration } from './gitlab/GitLabIntegration'; /** @@ -40,7 +40,7 @@ export interface ScmIntegrationRegistry bitbucketCloud: ScmIntegrationsGroup; bitbucketServer: ScmIntegrationsGroup; gerrit: ScmIntegrationsGroup; - github: ScmIntegrationsGroup; + github: ScmIntegrationsGroup; gitlab: ScmIntegrationsGroup; /** diff --git a/plugins/catalog-backend-module-github/api-report.md b/plugins/catalog-backend-module-github/api-report.md index 5b94f7169e..195b150dea 100644 --- a/plugins/catalog-backend-module-github/api-report.md +++ b/plugins/catalog-backend-module-github/api-report.md @@ -12,7 +12,7 @@ import { Entity } from '@backstage/catalog-model'; import { EntityProvider } from '@backstage/plugin-catalog-backend'; import { EntityProviderConnection } from '@backstage/plugin-catalog-backend'; import { GithubCredentialsProvider } from '@backstage/integration'; -import { GitHubIntegrationConfig } from '@backstage/integration'; +import { GithubIntegrationConfig } from '@backstage/integration'; import { LocationSpec } from '@backstage/plugin-catalog-backend'; import { Logger } from 'winston'; import { PluginEndpointDiscovery } from '@backstage/backend-common'; @@ -160,7 +160,7 @@ export class GithubOrgEntityProvider implements EntityProvider { constructor(options: { id: string; orgUrl: string; - gitHubConfig: GitHubIntegrationConfig; + gitHubConfig: GithubIntegrationConfig; logger: Logger; githubCredentialsProvider?: GithubCredentialsProvider; }); diff --git a/plugins/catalog-backend-module-github/src/processors/GithubMultiOrgReaderProcessor.ts b/plugins/catalog-backend-module-github/src/processors/GithubMultiOrgReaderProcessor.ts index c5315ad166..7bb73990b3 100644 --- a/plugins/catalog-backend-module-github/src/processors/GithubMultiOrgReaderProcessor.ts +++ b/plugins/catalog-backend-module-github/src/processors/GithubMultiOrgReaderProcessor.ts @@ -19,7 +19,7 @@ import { DefaultGithubCredentialsProvider, GithubAppCredentialsMux, GithubCredentialsProvider, - GitHubIntegrationConfig, + GithubIntegrationConfig, ScmIntegrationRegistry, ScmIntegrations, } from '@backstage/integration'; @@ -182,7 +182,7 @@ export class GithubMultiOrgReaderProcessor implements CatalogProcessor { // Note: Does not support usage of PATs private async getAllOrgs( - gitHubConfig: GitHubIntegrationConfig, + gitHubConfig: GithubIntegrationConfig, ): Promise { const githubAppMux = new GithubAppCredentialsMux(gitHubConfig); const installs = await githubAppMux.getAllInstallations(); diff --git a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts index 2004cb7469..378e1a96a7 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubEntityProvider.ts @@ -19,8 +19,8 @@ import { Config } from '@backstage/config'; import { GithubCredentialsProvider, ScmIntegrations, - GitHubIntegrationConfig, - GitHubIntegration, + GithubIntegrationConfig, + GithubIntegration, SingleInstanceGithubCredentialsProvider, } from '@backstage/integration'; import { @@ -51,7 +51,7 @@ import { satisfiesTopicFilter } from '../lib/util'; export class GithubEntityProvider implements EntityProvider { private readonly config: GithubEntityProviderConfig; private readonly logger: Logger; - private readonly integration: GitHubIntegrationConfig; + private readonly integration: GithubIntegrationConfig; private readonly scheduleFn: () => Promise; private connection?: EntityProviderConnection; private readonly githubCredentialsProvider: GithubCredentialsProvider; @@ -101,7 +101,7 @@ export class GithubEntityProvider implements EntityProvider { private constructor( config: GithubEntityProviderConfig, - integration: GitHubIntegration, + integration: GithubIntegration, logger: Logger, taskRunner: TaskRunner, ) { diff --git a/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.test.ts b/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.test.ts index 1d8d125d91..b3fc5022ec 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.test.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.test.ts @@ -18,7 +18,7 @@ import { getVoidLogger } from '@backstage/backend-common'; import { GroupEntity, UserEntity } from '@backstage/catalog-model'; import { GithubCredentialsProvider, - GitHubIntegrationConfig, + GithubIntegrationConfig, } from '@backstage/integration'; import { EntityProviderConnection } from '@backstage/plugin-catalog-backend'; import { graphql } from '@octokit/graphql'; @@ -87,7 +87,7 @@ describe('GithubOrgEntityProvider', () => { }; const logger = getVoidLogger(); - const gitHubConfig: GitHubIntegrationConfig = { + const gitHubConfig: GithubIntegrationConfig = { host: 'https://github.com', }; diff --git a/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts b/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts index f8fafbe53c..2fc8ce7300 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts @@ -24,7 +24,7 @@ import { Config } from '@backstage/config'; import { DefaultGithubCredentialsProvider, GithubCredentialsProvider, - GitHubIntegrationConfig, + GithubIntegrationConfig, ScmIntegrations, SingleInstanceGithubCredentialsProvider, } from '@backstage/integration'; @@ -134,7 +134,7 @@ export class GithubOrgEntityProvider implements EntityProvider { private options: { id: string; orgUrl: string; - gitHubConfig: GitHubIntegrationConfig; + gitHubConfig: GithubIntegrationConfig; logger: Logger; githubCredentialsProvider?: GithubCredentialsProvider; }, diff --git a/plugins/catalog-import/src/api/CatalogImportClient.ts b/plugins/catalog-import/src/api/CatalogImportClient.ts index 0663122253..4981331c89 100644 --- a/plugins/catalog-import/src/api/CatalogImportClient.ts +++ b/plugins/catalog-import/src/api/CatalogImportClient.ts @@ -21,7 +21,7 @@ import { IdentityApi, } from '@backstage/core-plugin-api'; import { - GitHubIntegrationConfig, + GithubIntegrationConfig, ScmIntegrationRegistry, } from '@backstage/integration'; import { ScmAuthApi } from '@backstage/integration-react'; @@ -239,7 +239,7 @@ the component will become available.\n\nFor more information, read an \ body: string; fileContent: string; repositoryUrl: string; - githubIntegrationConfig: GitHubIntegrationConfig; + githubIntegrationConfig: GithubIntegrationConfig; }): Promise<{ link: string; location: string }> { const { owner, diff --git a/plugins/git-release-manager/src/api/GitReleaseClient.ts b/plugins/git-release-manager/src/api/GitReleaseClient.ts index 996b8bfdd3..91b1dbbecc 100644 --- a/plugins/git-release-manager/src/api/GitReleaseClient.ts +++ b/plugins/git-release-manager/src/api/GitReleaseClient.ts @@ -15,7 +15,7 @@ */ import { Octokit } from '@octokit/rest'; -import { GitHubIntegration, ScmIntegrations } from '@backstage/integration'; +import { GithubIntegration, ScmIntegrations } from '@backstage/integration'; import { DISABLE_CACHE } from '../constants/constants'; import { Project } from '../contexts/ProjectContext'; @@ -50,7 +50,7 @@ export class GitReleaseClient implements GitReleaseApi { private getGithubIntegrationConfig({ gitHubIntegrations, }: { - gitHubIntegrations: GitHubIntegration[]; + gitHubIntegrations: GithubIntegration[]; }) { const defaultIntegration = gitHubIntegrations.find( ({ config: { host } }) => host === 'github.com', diff --git a/plugins/github-actions/src/api/GithubActionsClient.ts b/plugins/github-actions/src/api/GithubActionsClient.ts index ebe3d92c4f..724081320f 100644 --- a/plugins/github-actions/src/api/GithubActionsClient.ts +++ b/plugins/github-actions/src/api/GithubActionsClient.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { readGitHubIntegrationConfigs } from '@backstage/integration'; +import { readGithubIntegrationConfigs } from '@backstage/integration'; import { GithubActionsApi } from './GithubActionsApi'; import { Octokit, RestEndpointMethodTypes } from '@octokit/rest'; import { ConfigApi, OAuthApi } from '@backstage/core-plugin-api'; @@ -36,7 +36,7 @@ export class GithubActionsClient implements GithubActionsApi { private async getOctokit(hostname?: string): Promise { // TODO: Get access token for the specified hostname const token = await this.githubAuthApi.getAccessToken(['repo']); - const configs = readGitHubIntegrationConfigs( + const configs = readGithubIntegrationConfigs( this.configApi.getOptionalConfigArray('integrations.github') ?? [], ); const githubIntegrationConfig = configs.find( diff --git a/plugins/github-actions/src/components/Cards/Cards.tsx b/plugins/github-actions/src/components/Cards/Cards.tsx index 79777ed8c3..e23f7f7d59 100644 --- a/plugins/github-actions/src/components/Cards/Cards.tsx +++ b/plugins/github-actions/src/components/Cards/Cards.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { readGitHubIntegrationConfigs } from '@backstage/integration'; +import { readGithubIntegrationConfigs } from '@backstage/integration'; import { useEntity } from '@backstage/plugin-catalog-react'; import { LinearProgress, @@ -88,7 +88,7 @@ export const LatestWorkflowRunCard = (props: { const config = useApi(configApiRef); const errorApi = useApi(errorApiRef); // TODO: Get github hostname from metadata annotation - const hostname = readGitHubIntegrationConfigs( + const hostname = readGithubIntegrationConfigs( config.getOptionalConfigArray('integrations.github') ?? [], )[0].host; const [owner, repo] = ( diff --git a/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx b/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx index 931b5b676e..89fd40da33 100644 --- a/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx +++ b/plugins/github-actions/src/components/Cards/RecentWorkflowRunsCard.tsx @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { readGitHubIntegrationConfigs } from '@backstage/integration'; +import { readGithubIntegrationConfigs } from '@backstage/integration'; import { useEntity } from '@backstage/plugin-catalog-react'; import React, { useEffect } from 'react'; import { Link as RouterLink } from 'react-router-dom'; @@ -52,7 +52,7 @@ export const RecentWorkflowRunsCard = (props: { const errorApi = useApi(errorApiRef); // TODO: Get github hostname from metadata annotation - const hostname = readGitHubIntegrationConfigs( + const hostname = readGithubIntegrationConfigs( config.getOptionalConfigArray('integrations.github') ?? [], )[0].host; diff --git a/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx b/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx index 4e920a4e3a..cda0b9c219 100644 --- a/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx +++ b/plugins/github-actions/src/components/WorkflowRunDetails/WorkflowRunDetails.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ import { Entity } from '@backstage/catalog-model'; -import { readGitHubIntegrationConfigs } from '@backstage/integration'; +import { readGithubIntegrationConfigs } from '@backstage/integration'; import { Accordion, AccordionDetails, @@ -170,7 +170,7 @@ export const WorkflowRunDetails = ({ entity }: { entity: Entity }) => { const projectName = getProjectNameFromEntity(entity); // TODO: Get github hostname from metadata annotation - const hostname = readGitHubIntegrationConfigs( + const hostname = readGithubIntegrationConfigs( config.getOptionalConfigArray('integrations.github') ?? [], )[0].host; const [owner, repo] = (projectName && projectName.split('/')) || []; diff --git a/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx b/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx index bf66399288..075b73dd98 100644 --- a/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx +++ b/plugins/github-actions/src/components/WorkflowRunLogs/WorkflowRunLogs.tsx @@ -17,7 +17,7 @@ import { Entity } from '@backstage/catalog-model'; import { LogViewer } from '@backstage/core-components'; import { configApiRef, useApi } from '@backstage/core-plugin-api'; -import { readGitHubIntegrationConfigs } from '@backstage/integration'; +import { readGithubIntegrationConfigs } from '@backstage/integration'; import { Accordion, AccordionSummary, @@ -80,7 +80,7 @@ export const WorkflowRunLogs = ({ const projectName = getProjectNameFromEntity(entity); // TODO: Get github hostname from metadata annotation - const hostname = readGitHubIntegrationConfigs( + const hostname = readGithubIntegrationConfigs( config.getOptionalConfigArray('integrations.github') ?? [], )[0].host; const [owner, repo] = (projectName && projectName.split('/')) || []; diff --git a/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx b/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx index c8c42eb1bc..fb80376354 100644 --- a/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx +++ b/plugins/github-actions/src/components/WorkflowRunsTable/WorkflowRunsTable.tsx @@ -31,7 +31,7 @@ import SyncIcon from '@material-ui/icons/Sync'; import { buildRouteRef } from '../../routes'; import { getProjectNameFromEntity } from '../getProjectNameFromEntity'; import { Entity } from '@backstage/catalog-model'; -import { readGitHubIntegrationConfigs } from '@backstage/integration'; +import { readGithubIntegrationConfigs } from '@backstage/integration'; import { EmptyState, Table, TableColumn } from '@backstage/core-components'; import { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api'; @@ -159,7 +159,7 @@ export const WorkflowRunsTable = ({ const config = useApi(configApiRef); const projectName = getProjectNameFromEntity(entity); // TODO: Get github hostname from metadata annotation - const hostname = readGitHubIntegrationConfigs( + const hostname = readGithubIntegrationConfigs( config.getOptionalConfigArray('integrations.github') ?? [], )[0].host; const [owner, repo] = (projectName ?? '/').split('/'); diff --git a/plugins/github-issues/src/api/gitHubIssuesApi.ts b/plugins/github-issues/src/api/gitHubIssuesApi.ts index b4be445d13..bef1b20441 100644 --- a/plugins/github-issues/src/api/gitHubIssuesApi.ts +++ b/plugins/github-issues/src/api/gitHubIssuesApi.ts @@ -20,7 +20,7 @@ import { ErrorApi, OAuthApi, } from '@backstage/core-plugin-api'; -import { readGitHubIntegrationConfigs } from '@backstage/integration'; +import { readGithubIntegrationConfigs } from '@backstage/integration'; import { ForwardedError } from '@backstage/errors'; /** @internal */ @@ -115,7 +115,7 @@ export const gitHubIssuesApi = ( let octokit: Octokit; const getOctokit = async () => { - const baseUrl = readGitHubIntegrationConfigs( + const baseUrl = readGithubIntegrationConfigs( configApi.getOptionalConfigArray('integrations.github') ?? [], )[0].apiBaseUrl; diff --git a/plugins/github-pull-requests-board/src/api/useOctokitGraphQl.ts b/plugins/github-pull-requests-board/src/api/useOctokitGraphQl.ts index a864f9950e..6dadcef6d2 100644 --- a/plugins/github-pull-requests-board/src/api/useOctokitGraphQl.ts +++ b/plugins/github-pull-requests-board/src/api/useOctokitGraphQl.ts @@ -19,7 +19,7 @@ import { githubAuthApiRef, configApiRef, } from '@backstage/core-plugin-api'; -import { readGitHubIntegrationConfigs } from '@backstage/integration'; +import { readGithubIntegrationConfigs } from '@backstage/integration'; let octokit: any; @@ -27,7 +27,7 @@ export const useOctokitGraphQl = () => { const auth = useApi(githubAuthApiRef); const config = useApi(configApiRef); - const baseUrl = readGitHubIntegrationConfigs( + const baseUrl = readGithubIntegrationConfigs( config.getOptionalConfigArray('integrations.github') ?? [], )[0].apiBaseUrl; diff --git a/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts b/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts index 19cb47ec40..22dc359942 100644 --- a/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts +++ b/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts @@ -18,7 +18,7 @@ import parseGitUrl from 'git-url-parse'; import { useApi } from '@backstage/core-plugin-api'; import { - replaceGitHubUrlType, + replaceGithubUrlType, replaceGitLabUrlType, } from '@backstage/integration'; import { scmIntegrationsApiRef } from '@backstage/integration-react'; @@ -31,7 +31,7 @@ import { PAGE_EDIT_LINK_SELECTOR } from './constants'; const resolveBlobUrl = (url: string, type: string) => { if (type === 'github') { - return replaceGitHubUrlType(url, 'blob'); + return replaceGithubUrlType(url, 'blob'); } else if (type === 'gitlab') { return replaceGitLabUrlType(url, 'blob'); } diff --git a/plugins/techdocs/src/reader/transformers/addGitFeedbackLink.ts b/plugins/techdocs/src/reader/transformers/addGitFeedbackLink.ts index 9c7865936c..3fca7ddeb9 100644 --- a/plugins/techdocs/src/reader/transformers/addGitFeedbackLink.ts +++ b/plugins/techdocs/src/reader/transformers/addGitFeedbackLink.ts @@ -16,7 +16,7 @@ import type { Transformer } from './index'; import { - replaceGitHubUrlType, + replaceGithubUrlType, ScmIntegrationRegistry, } from '@backstage/integration'; import FeedbackOutlinedIcon from '@material-ui/icons/FeedbackOutlined'; @@ -59,7 +59,7 @@ export const addGitFeedbackLink = ( // Convert GitHub edit url to blob type so it can be parsed by git-url-parse correctly const gitUrl = integration?.type === 'github' - ? replaceGitHubUrlType(sourceURL.href, 'blob') + ? replaceGithubUrlType(sourceURL.href, 'blob') : sourceURL.href; const gitInfo = parseGitUrl(gitUrl); const repoPath = `/${gitInfo.organization}/${gitInfo.name}`;