From 8acca63fa9cab7d67cd319cf5c0e99b36a82ba73 Mon Sep 17 00:00:00 2001 From: Dede Hamzah Date: Tue, 21 Sep 2021 14:01:53 +0700 Subject: [PATCH 1/4] Allow url with extension .yml in gitlab processor Signed-off-by: Dede Hamzah --- packages/integration/src/gitlab/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integration/src/gitlab/core.ts b/packages/integration/src/gitlab/core.ts index 83ab29c62e..b30d44e2db 100644 --- a/packages/integration/src/gitlab/core.ts +++ b/packages/integration/src/gitlab/core.ts @@ -76,7 +76,7 @@ export function buildRawUrl(target: string): URL { userOrOrg === '' || repoName === '' || blobKeyword !== 'blob' || - !restOfPath.join('/').match(/\.yaml$/) + !restOfPath.join('/').match(/\.(yaml|yml)$/) ) { throw new Error('Wrong GitLab URL'); } From 8113ba5ebbdee128869621793fb9d0972dadbc27 Mon Sep 17 00:00:00 2001 From: Dede Hamzah Date: Tue, 21 Sep 2021 14:58:03 +0700 Subject: [PATCH 2/4] add changest Signed-off-by: Dede Hamzah --- .changeset/great-squids-deliver.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/great-squids-deliver.md diff --git a/.changeset/great-squids-deliver.md b/.changeset/great-squids-deliver.md new file mode 100644 index 0000000000..1d31e3b651 --- /dev/null +++ b/.changeset/great-squids-deliver.md @@ -0,0 +1,5 @@ +--- +'@backstage/integration': patch +--- + +Allow file extension .yml to be ingested in gitlab processor From 14e01923b4d6c122d97eae15e5b26565c6279584 Mon Sep 17 00:00:00 2001 From: Dede Hamzah Date: Tue, 21 Sep 2021 15:38:49 +0700 Subject: [PATCH 3/4] add test Signed-off-by: Dede Hamzah --- packages/integration/src/gitlab/core.test.ts | 47 +++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/packages/integration/src/gitlab/core.test.ts b/packages/integration/src/gitlab/core.test.ts index f07d65e02a..4f39fb2fe7 100644 --- a/packages/integration/src/gitlab/core.test.ts +++ b/packages/integration/src/gitlab/core.test.ts @@ -47,7 +47,7 @@ describe('gitlab core', () => { baseUrl: '', }; - describe('getGitLabFileFetchUrl', () => { + describe('getGitLabFileFetchUrl with .yaml extension', () => { it.each([ // Project URLs { @@ -91,4 +91,49 @@ describe('gitlab core', () => { await expect(getGitLabFileFetchUrl(url, config)).resolves.toBe(result); }); }); + + describe('getGitLabFileFetchUrl with .yml extension', () => { + it.each([ + // Project URLs + { + config: configWithNoToken, + url: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path/to/file.yml', + result: + 'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yml/raw?ref=branch', + }, + { + config: configWithNoToken, + // Works with non URI encoded link + url: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path/to/file with spaces.yml', + result: + 'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile%20with%20spaces.yml/raw?ref=branch', + }, + { + config: configWithNoToken, + url: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path%20with%20spaces/to/file.yml', + result: + 'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%20with%20spaces%2Fto%2Ffile.yml/raw?ref=branch', + }, + { + config: configWithToken, + url: 'https://gitlab.example.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path%20with%20spaces/to/file.yml', + result: + 'https://gitlab.example.com/api/v4/projects/12345/repository/files/my%2Fpath%20with%20spaces%2Fto%2Ffile.yml/raw?ref=branch', + }, + { + config: configWithNoToken, + url: 'https://gitlab.com/groupA/teams/teamA/repoA/-/blob/branch/my/path%20with%20spaces/to/file.yml', // Repo not in subgroup + result: + 'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%20with%20spaces%2Fto%2Ffile.yml/raw?ref=branch', + }, + // Raw URLs + { + config: configWithNoToken, + url: 'https://gitlab.example.com/a/b/blob/master/c.yml', + result: 'https://gitlab.example.com/a/b/raw/master/c.yml', + }, + ])('should handle happy path %#', async ({ config, url, result }) => { + await expect(getGitLabFileFetchUrl(url, config)).resolves.toBe(result); + }); + }); }); From 08600d0368db70acf37b7d27378eb0279d61b5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 23 Sep 2021 08:56:20 +0200 Subject: [PATCH 4/4] fix spelling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/great-squids-deliver.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/great-squids-deliver.md b/.changeset/great-squids-deliver.md index 1d31e3b651..a6ad0ef87f 100644 --- a/.changeset/great-squids-deliver.md +++ b/.changeset/great-squids-deliver.md @@ -2,4 +2,4 @@ '@backstage/integration': patch --- -Allow file extension .yml to be ingested in gitlab processor +Allow file extension `.yml` to be ingested in GitLab processor