🚀 Feature: Make the AzureDevOpsEntityProvider multi project
See original GitHub issue🔖 Feature description
Right now for the Azure DevOps EntityProvider you need to specify a project like so:
catalog:
providers:
azureDevOps:
someId:
organization: 'MyOrg'
project: 'MyProjectName'
repository: '*'
path: catalog-info.yaml
What would be useful for companies with multiple projects is to use a wildcard just as for the repository specification:
catalog:
providers:
azureDevOps:
someId:
organization: 'MyOrg'
project: '*'
repository: '*'
path: catalog-info.yaml
🎤 Context
In my use-case we have over 30 projects that change dynamically and I have seen multiple users in the issues having the same issue.
Related: #10431
✌️ Possible Implementation
It seems that the AzureDevOpsEntityProvider calls the codesearch API(https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.ts#L141) for Azure Devops here: https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-azure/src/lib/azure.ts#L50
However, that call is opinionated towards a must-have project. That URL doesn’t need a project as stated in the docs: https://learn.microsoft.com/en-us/rest/api/azure/devops/search/code-search-results/fetch-code-search-results?view=azure-devops-rest-7.1&tabs=HTTP#examples
I would suggest that we use the baseurl from the start without a project:
const searchUrl = `${searchBaseUrl}/${org}/${project}/_apis/search/codesearchresults?api-version=6.0-preview.1`;
to
const searchUrl = `${searchBaseUrl}/${org}/_apis/search/codesearchresults?api-version=7.0-preview.1`;
And then, if there is a project specified, add it to the searchText property the same as with the repo:
searchText: `path:${path} repo:${repo || '*'} proj: ${project|| '*'}`,
I tested these calls with postman, and they work. I’m uncertain if more things need to change.
I would love to contribute, but I don’t know how to debug the plugin effectively and change things around. If somebody can help me get started, that would be great!
👀 Have you spent some time to check if this feature request has been raised before?
- I checked and didn’t find similar issue
🏢 Have you read the Code of Conduct?
- I have read the Contributing Guidelines
Are you willing to submit PR?
Yes I am willing to submit a PR!
Issue Analytics
- State:
- Created 10 months ago
- Comments:14 (7 by maintainers)
Top GitHub Comments
@awanlin I thought project was required, but if it’s possible to send the project as part of the query, I agree with this change, especially because it’s backwards compatible as you say 👍
Hi @MarcBruins, you had asked about tests. You can usually find any existing tests in the same locaiton as the code but with
test
in the name just before the file extension. In your case you’d be looking at:AzureDevOpsEntityProvider.test.ts
which is here: https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-azure/src/providers/AzureDevOpsEntityProvider.test.tsazure.test.ts
which is here: https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-azure/src/lib/azure.test.tsMy gut tells me that you’ll want to add tests to
azure.test.ts
as that is where the bulk of your change isTo run these navigate to the folder
plugins/catalog-backend-module-azure
and runyarn test
. This will run all the tests in this plugin. To run just a single test file navigate to the folder it’s in and then runyarn test name-of-test-file
. For example to run justazure.test.ts
you’d go toplugins/catalog-backend-module-azure/src/lib
and then runyarn test azure.test.ts