refactor: rename helpers.ts to OctokitProvider.ts and add docstrings

Signed-off-by: @pawelmitka <pawel.mitka@brainly.com>
This commit is contained in:
@pawelmitka
2021-09-01 09:30:50 +02:00
parent 2b69f8a4fd
commit a239a4a5e5
5 changed files with 13 additions and 5 deletions
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { OctokitProvider } from './helpers';
import { OctokitProvider } from './OctokitProvider';
import { ScmIntegrations } from '@backstage/integration';
import { ConfigReader } from '@backstage/config';
@@ -28,7 +28,10 @@ export type OctokitIntegration = {
owner: string;
repo: string;
};
/**
* OctokitProvider provides Octokit client based on ScmIntegrationsRegistry configuration.
* OctokitProvider supports GitHub credentials caching out of the box.
*/
export class OctokitProvider {
private readonly integrations: ScmIntegrationRegistry;
private readonly credentialsProviders: Map<string, GithubCredentialsProvider>;
@@ -43,6 +46,11 @@ export class OctokitProvider {
);
}
/**
* gets standard Octokit client based on repository URL.
*
* @param repoUrl Repository URL
*/
async getOctokit(repoUrl: string): Promise<OctokitIntegration> {
const { owner, repo, host } = parseRepoUrl(repoUrl, this.integrations);
@@ -15,7 +15,7 @@
*/
import { ScmIntegrationRegistry } from '@backstage/integration';
import { createTemplateAction } from '../../createTemplateAction';
import { OctokitProvider } from './helpers';
import { OctokitProvider } from './OctokitProvider';
export function createGithubActionsDispatchAction(options: {
integrations: ScmIntegrationRegistry;
@@ -15,7 +15,7 @@
*/
import { ScmIntegrationRegistry } from '@backstage/integration';
import { createTemplateAction } from '../../createTemplateAction';
import { OctokitProvider } from './helpers';
import { OctokitProvider } from './OctokitProvider';
type ContentType = 'form' | 'json';
@@ -21,7 +21,7 @@ import {
import { getRepoSourceDirectory } from './util';
import { createTemplateAction } from '../../createTemplateAction';
import { Config } from '@backstage/config';
import { OctokitProvider } from '../github/helpers';
import { OctokitProvider } from '../github/OctokitProvider';
type Permission = 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
type Collaborator = { access: Permission; username: string };