Merge pull request #29398 from benjidotsh/discovery/bitbucket-cloud-event-based-discovery-fix
fix(discovery): fix bug in event-based discovery for Bitbucket Cloud
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-bitbucket-cloud': patch
|
||||
---
|
||||
|
||||
Fixed bug in event-based discovery that caused unnecessary API calls to Bitbucket Cloud
|
||||
+1
-25
@@ -542,31 +542,11 @@ describe('BitbucketCloudEntityProvider', () => {
|
||||
})[0];
|
||||
|
||||
server.use(
|
||||
rest.get(
|
||||
`https://api.bitbucket.org/2.0/workspaces/test-ws/projects`,
|
||||
(_req, res, ctx) => {
|
||||
const response = {
|
||||
values: [
|
||||
{
|
||||
key: 'TEST',
|
||||
},
|
||||
{
|
||||
key: 'TEST2',
|
||||
},
|
||||
],
|
||||
};
|
||||
return res(ctx.json(response));
|
||||
},
|
||||
),
|
||||
rest.get(
|
||||
`https://api.bitbucket.org/2.0/workspaces/test-ws/search/code`,
|
||||
(req, res, ctx) => {
|
||||
const query = req.url.searchParams.get('search_query');
|
||||
if (
|
||||
!query ||
|
||||
!query.includes('repo:test-repo') ||
|
||||
!query.includes('project:TEST')
|
||||
) {
|
||||
if (!query || !query.includes('repo:test-repo')) {
|
||||
return res(ctx.json({ values: [] }));
|
||||
}
|
||||
|
||||
@@ -643,10 +623,6 @@ describe('BitbucketCloudEntityProvider', () => {
|
||||
entity: addedModule,
|
||||
locationKey: 'bitbucketCloud-provider:myProvider',
|
||||
},
|
||||
{
|
||||
entity: addedModule,
|
||||
locationKey: 'bitbucketCloud-provider:myProvider',
|
||||
},
|
||||
];
|
||||
const removedEntities = [
|
||||
{
|
||||
|
||||
+2
@@ -326,6 +326,8 @@ export class BitbucketCloudEntityProvider implements EntityProvider {
|
||||
const optRepoFilter = repoSlug ? ` repo:${repoSlug}` : '';
|
||||
const query = `"${catalogFilename}" path:${catalogPath}${optRepoFilter}`;
|
||||
|
||||
if (repoSlug) return this.processQuery(workspace, query);
|
||||
|
||||
const projects = this.client
|
||||
.listProjectsByWorkspace(workspace)
|
||||
.iterateResults();
|
||||
|
||||
Reference in New Issue
Block a user