From 3825687f5aed23c17e434315f77cc068ef71d58e Mon Sep 17 00:00:00 2001 From: Marc Bruins Date: Sat, 24 Dec 2022 18:43:24 +0100 Subject: [PATCH] Update docs and fix tests Signed-off-by: Marc Bruins --- docs/integrations/azure/discovery.md | 2 +- .../providers/AzureDevOpsEntityProvider.test.ts | 15 +++++++++++++++ .../src/providers/AzureDevOpsEntityProvider.ts | 7 ++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/integrations/azure/discovery.md b/docs/integrations/azure/discovery.md index 18686ebdc3..a7ddd9c4a9 100644 --- a/docs/integrations/azure/discovery.md +++ b/docs/integrations/azure/discovery.md @@ -149,7 +149,7 @@ When using a custom pattern, the target is composed of five parts: - The base instance URL, `https://dev.azure.com` in this case - The organization name which is required, `myorg` in this case -- The project name which is required, `myproject` in this case +- The project name which is optional, `myproject` in this case. This defaults to \*, which scans all the projects where the token has access to. - The repository blob to scan, which accepts \* wildcard tokens and must be added after `_git/`. This can simply be `*` to scan all repositories in the project. diff --git a/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.test.ts b/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.test.ts index f7a63f259e..dff1164899 100644 --- a/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.test.ts +++ b/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.test.ts @@ -164,6 +164,9 @@ describe('AzureDevOpsEntityProvider', () => { repository: { name: 'myrepo', }, + project: { + name: 'myproject', + }, }, ], 'https://dev.azure.com/myorganization/myproject', @@ -189,6 +192,9 @@ describe('AzureDevOpsEntityProvider', () => { repository: { name: 'myrepo', }, + project: { + name: 'myproject', + }, }, { fileName: 'catalog-info.yaml', @@ -196,6 +202,9 @@ describe('AzureDevOpsEntityProvider', () => { repository: { name: 'myotherrepo', }, + project: { + name: 'myproject', + }, }, ], 'https://dev.azure.com/myorganization/myproject', @@ -277,6 +286,9 @@ describe('AzureDevOpsEntityProvider', () => { repository: { name: 'myrepo', }, + project: { + name: 'myproject', + }, }, { fileName: 'catalog-info.yaml', @@ -284,6 +296,9 @@ describe('AzureDevOpsEntityProvider', () => { repository: { name: 'myotherrepo', }, + project: { + name: 'myproject', + }, }, ], 'https://dev.azure.com/myorganization/myproject', diff --git a/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.ts b/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.ts index 87ddde78d3..c9ad3fb05b 100644 --- a/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.ts +++ b/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.ts @@ -176,8 +176,9 @@ export class AzureDevOpsEntityProvider implements EntityProvider { } private createObjectUrl(file: CodeSearchResultItem): string { - const baseUrl = `https://${this.config.host}/${this.config.organization}`; - const encodedUri = `${baseUrl}/${file.project.name}/_git/${file.repository.name}?path=${file.path}`; - return encodedUri; + const baseUrl = `https://${this.config.host}/${this.config.organization}/${file.project.name}`; + return encodeURI( + `${baseUrl}/_git/${file.repository.name}?path=${file.path}`, + ); } }