Make functions private

Signed-off-by: Max Morton <mamorton@paloaltonetworks.com>
This commit is contained in:
Max Morton
2022-11-17 09:11:59 -08:00
parent 468cd24bec
commit fb6b403647
2 changed files with 11 additions and 11 deletions
@@ -585,7 +585,7 @@ describe('GitlabUrlReader', () => {
});
it('should fall back to getGitLabFileFetchUrl for blob urls', async () => {
await expect(
gitlabProcessor.getGitlabFetchUrl(
(gitlabProcessor as any).getGitlabFetchUrl(
'https://gitlab.com/group/subgroup/project/-/blob/branch/my/path/to/file.yaml',
),
).resolves.toEqual(
@@ -594,7 +594,7 @@ describe('GitlabUrlReader', () => {
});
it('should work for job artifact urls', async () => {
await expect(
gitlabProcessor.getGitlabFetchUrl(
(gitlabProcessor as any).getGitlabFetchUrl(
'https://gitlab.com/group/subgroup/project/-/jobs/artifacts/branch/raw/my/path/to/file.yaml?job=myJob',
),
).resolves.toEqual(
@@ -603,13 +603,13 @@ describe('GitlabUrlReader', () => {
});
it('should pass API urls naively', async () => {
const apiUrl = 'https://gitlab.com/api/v4/my/api/path';
await expect(gitlabProcessor.getGitlabFetchUrl(apiUrl)).resolves.toEqual(
apiUrl,
);
await expect(
(gitlabProcessor as any).getGitlabFetchUrl(apiUrl)
).resolves.toEqual(apiUrl,);
});
it('should fail on unfamiliar or non-Gitlab urls', async () => {
await expect(
gitlabProcessor.getGitlabFetchUrl(
(gitlabProcessor as any).getGitlabFetchUrl(
'https://gitlab.com/some/random/endpoint',
),
).rejects.toThrow('Please provide full path to yaml file from GitLab');
@@ -633,14 +633,14 @@ describe('GitlabUrlReader', () => {
});
it('should reject urls that are not for the job artifacts API', async () => {
await expect(
gitlabProcessor.getGitlabArtifactFetchUrl(
(gitlabProcessor as any).getGitlabArtifactFetchUrl(
'https://gitlab.com/some/url',
),
).rejects.toThrow('Unable to process url as an GitLab artifact');
});
it('should work for job artifact urls', async () => {
await expect(
gitlabProcessor.getGitlabFetchUrl(
(gitlabProcessor as any).getGitlabFetchUrl(
'https://gitlab.com/group/subgroup/project/-/jobs/artifacts/branch/raw/my/path/to/file.yaml?job=myJob',
),
).resolves.toEqual(
@@ -649,7 +649,7 @@ describe('GitlabUrlReader', () => {
});
it('errors in mapping the project ID should be captured', async () => {
await expect(
gitlabProcessor.getGitlabFetchUrl(
(gitlabProcessor as any).getGitlabFetchUrl(
'https://gitlab.com/groupA/subgroup/project/-/jobs/artifacts/branch/raw/my/path/to/file.yaml?job=myJob',
),
).rejects.toThrow(/^Unable to translate GitLab artifact URL:/);
@@ -257,7 +257,7 @@ export class GitlabUrlReader implements UrlReader {
return `gitlab{host=${host},authed=${Boolean(token)}}`;
}
async getGitlabFetchUrl(target: string): Promise<string> {
private async getGitlabFetchUrl(target: string): Promise<string> {
// If the target is a raw API url then trust that no parsing is needed
if (target.includes('/api/v4/')) {
return target;
@@ -276,7 +276,7 @@ export class GitlabUrlReader implements UrlReader {
// https://example.com/<namespace>/<project>/-/jobs/artifacts/<ref>/raw/<path_to_file>?job=<job_name>
// to urls of the form:
// https://example.com/api/v4/projects/:id/jobs/artifacts/:ref_name/raw/*artifact_path?job=<job_name>
async getGitlabArtifactFetchUrl(target: string): Promise<URL> {
private async getGitlabArtifactFetchUrl(target: string): Promise<URL> {
const url = new URL(target);
if (!url.pathname.includes('/-/jobs/artifacts/')) {
throw new Error('Unable to process url as an GitLab artifact');