From fb6b4036474c9f5073b77bb68f753d8136328217 Mon Sep 17 00:00:00 2001 From: Max Morton Date: Thu, 17 Nov 2022 09:11:59 -0800 Subject: [PATCH] Make functions private Signed-off-by: Max Morton --- .../src/reading/GitlabUrlReader.test.ts | 18 +++++++++--------- .../src/reading/GitlabUrlReader.ts | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/backend-common/src/reading/GitlabUrlReader.test.ts b/packages/backend-common/src/reading/GitlabUrlReader.test.ts index d88c6d8fb9..8bf0328432 100644 --- a/packages/backend-common/src/reading/GitlabUrlReader.test.ts +++ b/packages/backend-common/src/reading/GitlabUrlReader.test.ts @@ -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:/); diff --git a/packages/backend-common/src/reading/GitlabUrlReader.ts b/packages/backend-common/src/reading/GitlabUrlReader.ts index f704901650..3455de6f20 100644 --- a/packages/backend-common/src/reading/GitlabUrlReader.ts +++ b/packages/backend-common/src/reading/GitlabUrlReader.ts @@ -257,7 +257,7 @@ export class GitlabUrlReader implements UrlReader { return `gitlab{host=${host},authed=${Boolean(token)}}`; } - async getGitlabFetchUrl(target: string): Promise { + private async getGitlabFetchUrl(target: string): Promise { // 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///-/jobs/artifacts//raw/?job= // to urls of the form: // https://example.com/api/v4/projects/:id/jobs/artifacts/:ref_name/raw/*artifact_path?job= - async getGitlabArtifactFetchUrl(target: string): Promise { + private async getGitlabArtifactFetchUrl(target: string): Promise { const url = new URL(target); if (!url.pathname.includes('/-/jobs/artifacts/')) { throw new Error('Unable to process url as an GitLab artifact');