chore(integration): use consistent naming of [gG]ithub in code
Relates to the discussion at PR #14039. Relates-to: PR #14039 Relates-to: PR #14174 Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
This commit is contained in:
@@ -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`
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
|
||||
@@ -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',
|
||||
}),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -323,16 +323,19 @@ export function getGerritRequestOptions(config: GerritIntegrationConfig): {
|
||||
headers?: Record<string, string>;
|
||||
};
|
||||
|
||||
// @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<string, string>;
|
||||
@@ -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<GitHubIntegration>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export class GithubIntegration implements ScmIntegration {
|
||||
constructor(integrationConfig: GithubIntegrationConfig);
|
||||
// (undocumented)
|
||||
get config(): GithubIntegrationConfig;
|
||||
// (undocumented)
|
||||
static factory: ScmIntegrationsFactory<GithubIntegration>;
|
||||
// (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<GerritIntegration>;
|
||||
// (undocumented)
|
||||
github: ScmIntegrationsGroup<GitHubIntegration>;
|
||||
github: ScmIntegrationsGroup<GithubIntegration>;
|
||||
// (undocumented)
|
||||
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
||||
}
|
||||
@@ -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<GerritIntegration>;
|
||||
// (undocumented)
|
||||
github: ScmIntegrationsGroup<GitHubIntegration>;
|
||||
github: ScmIntegrationsGroup<GithubIntegration>;
|
||||
// (undocumented)
|
||||
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
||||
resolveEditUrl(url: string): string;
|
||||
@@ -649,7 +673,7 @@ export class ScmIntegrations implements ScmIntegrationRegistry {
|
||||
// (undocumented)
|
||||
get gerrit(): ScmIntegrationsGroup<GerritIntegration>;
|
||||
// (undocumented)
|
||||
get github(): ScmIntegrationsGroup<GitHubIntegration>;
|
||||
get github(): ScmIntegrationsGroup<GithubIntegration>;
|
||||
// (undocumented)
|
||||
get gitlab(): ScmIntegrationsGroup<GitLabIntegration>;
|
||||
// (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<GithubCredentials>;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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<BitbucketCloudIntegration>;
|
||||
bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;
|
||||
gerrit: ScmIntegrationsGroup<GerritIntegration>;
|
||||
github: ScmIntegrationsGroup<GitHubIntegration>;
|
||||
github: ScmIntegrationsGroup<GithubIntegration>;
|
||||
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
||||
}
|
||||
|
||||
@@ -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<GitHubIntegration> {
|
||||
get github(): ScmIntegrationsGroup<GithubIntegration> {
|
||||
return this.byType.github;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 }) => {
|
||||
|
||||
+11
-11
@@ -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',
|
||||
),
|
||||
+11
-11
@@ -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<GitHubIntegration> = ({ config }) => {
|
||||
const configs = readGitHubIntegrationConfigs(
|
||||
export class GithubIntegration implements ScmIntegration {
|
||||
static factory: ScmIntegrationsFactory<GithubIntegration> = ({ 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 {
|
||||
@@ -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),
|
||||
|
||||
@@ -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<GitHubIntegrationConfig>) {
|
||||
describe('readGithubIntegrationConfig', () => {
|
||||
function buildConfig(provider: Partial<GithubIntegrationConfig>) {
|
||||
return new ConfigReader(provider);
|
||||
}
|
||||
|
||||
async function buildFrontendConfig(
|
||||
data: Partial<GitHubIntegrationConfig>,
|
||||
data: Partial<GithubIntegrationConfig>,
|
||||
): Promise<Config> {
|
||||
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<GitHubIntegrationConfig>[],
|
||||
providers: Partial<GithubIntegrationConfig>[],
|
||||
): 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',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<string, string> } {
|
||||
const headers: Record<string, string> = {};
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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> =
|
||||
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;
|
||||
@@ -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';
|
||||
|
||||
@@ -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<BitbucketCloudIntegration>;
|
||||
bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;
|
||||
gerrit: ScmIntegrationsGroup<GerritIntegration>;
|
||||
github: ScmIntegrationsGroup<GitHubIntegration>;
|
||||
github: ScmIntegrationsGroup<GithubIntegration>;
|
||||
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
+2
-2
@@ -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<GithubMultiOrgConfig> {
|
||||
const githubAppMux = new GithubAppCredentialsMux(gitHubConfig);
|
||||
const installs = await githubAppMux.getAllInstallations();
|
||||
|
||||
@@ -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<void>;
|
||||
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,
|
||||
) {
|
||||
|
||||
@@ -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',
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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<Octokit> {
|
||||
// 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(
|
||||
|
||||
@@ -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] = (
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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('/')) || [];
|
||||
|
||||
@@ -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('/')) || [];
|
||||
|
||||
@@ -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('/');
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 = <T>() => {
|
||||
const auth = useApi(githubAuthApiRef);
|
||||
const config = useApi(configApiRef);
|
||||
|
||||
const baseUrl = readGitHubIntegrationConfigs(
|
||||
const baseUrl = readGithubIntegrationConfigs(
|
||||
config.getOptionalConfigArray('integrations.github') ?? [],
|
||||
)[0].apiBaseUrl;
|
||||
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user