refactor: rename helpers.ts to OctokitProvider.ts and add docstrings
Signed-off-by: @pawelmitka <pawel.mitka@brainly.com>
This commit is contained in:
+1
-1
@@ -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';
|
||||
|
||||
+9
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user