removes some breaking compatability changes

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2022-01-07 14:13:23 +00:00
parent db49de335f
commit ce82656901
7 changed files with 26 additions and 11 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
'@backstage/integration': patch
---
Adds a new GitHub credentials provider. It handles multiple app configurations. It looks up the app configuration based on the url.
Adds a new GitHub credentials provider (DefaultGithubCredentialsProvider). It handles multiple app configurations. It looks up the app configuration based on the url.
@@ -58,7 +58,11 @@ export class DefaultGithubCredentialsProvider
* @example
* ```ts
* const { token, headers } = await getCredentials({
* url: 'github.com/backstage/foobar'
* url: 'https://github.com/backstage/foobar'
* })
*
* const { token, headers } = await getCredentials({
* url: 'https://github.com/backstage'
* })
* ```
*
+1 -1
View File
@@ -1063,7 +1063,7 @@ export class GitHubOrgEntityProvider implements EntityProvider {
orgUrl: string;
gitHubConfig: GitHubIntegrationConfig;
logger: Logger_2;
githubCredentialsProvider: GithubCredentialsProvider;
githubCredentialsProvider?: GithubCredentialsProvider;
});
// (undocumented)
connect(connection: EntityProviderConnection): Promise<void>;
@@ -24,6 +24,7 @@ import {
GithubCredentialsProvider,
GitHubIntegrationConfig,
ScmIntegrations,
SingleInstanceGithubCredentialsProvider,
} from '@backstage/integration';
import { graphql } from '@octokit/graphql';
import { merge } from 'lodash';
@@ -81,10 +82,12 @@ export class GitHubOrgEntityProvider implements EntityProvider {
orgUrl: string;
gitHubConfig: GitHubIntegrationConfig;
logger: Logger;
githubCredentialsProvider: GithubCredentialsProvider;
githubCredentialsProvider?: GithubCredentialsProvider;
},
) {
this.githubCredentialsProvider = options.githubCredentialsProvider;
this.githubCredentialsProvider =
options.githubCredentialsProvider ||
SingleInstanceGithubCredentialsProvider.create(options.gitHubConfig);
}
getProviderName() {
+1 -1
View File
@@ -288,7 +288,7 @@ export function fetchContents({
export class OctokitProvider {
constructor(
integrations: ScmIntegrationRegistry,
githubCredentialsProvider: GithubCredentialsProvider,
githubCredentialsProvider?: GithubCredentialsProvider,
);
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// Warning: (ae-forgotten-export) The symbol "OctokitIntegration" needs to be exported by the entry point index.d.ts
@@ -16,6 +16,7 @@
import { InputError } from '@backstage/errors';
import {
DefaultGithubCredentialsProvider,
GithubCredentialsProvider,
ScmIntegrationRegistry,
} from '@backstage/integration';
@@ -38,10 +39,12 @@ export class OctokitProvider {
constructor(
integrations: ScmIntegrationRegistry,
githubCredentialsProvider: GithubCredentialsProvider,
githubCredentialsProvider?: GithubCredentialsProvider,
) {
this.integrations = integrations;
this.githubCredentialsProvider = githubCredentialsProvider;
this.githubCredentialsProvider =
githubCredentialsProvider ||
DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);
}
/**
@@ -20,6 +20,7 @@ import { parseRepoUrl, isExecutable } from './util';
import {
GithubCredentialsProvider,
ScmIntegrationRegistry,
SingleInstanceGithubCredentialsProvider,
} from '@backstage/integration';
import { zipObject } from 'lodash';
import { createTemplateAction } from '../../createTemplateAction';
@@ -58,7 +59,7 @@ export type GithubPullRequestActionInput = {
export type ClientFactoryInput = {
integrations: ScmIntegrationRegistry;
githubCredentialsProvider: GithubCredentialsProvider;
githubCredentialsProvider?: GithubCredentialsProvider;
host: string;
owner: string;
repo: string;
@@ -77,7 +78,11 @@ export const defaultClientFactory = async ({
throw new InputError(`No integration for host ${host}`);
}
const { token } = await githubCredentialsProvider.getCredentials({
const credentialsProvider =
githubCredentialsProvider ||
SingleInstanceGithubCredentialsProvider.create(integrationConfig);
const { token } = await credentialsProvider.getCredentials({
url: `https://${host}/${encodeURIComponent(owner)}/${encodeURIComponent(
repo,
)}`,
@@ -99,7 +104,7 @@ export const defaultClientFactory = async ({
interface CreateGithubPullRequestActionOptions {
integrations: ScmIntegrationRegistry;
githubCredentialsProvider: GithubCredentialsProvider;
githubCredentialsProvider?: GithubCredentialsProvider;
clientFactory?: (input: ClientFactoryInput) => Promise<PullRequestCreator>;
}