Merge pull request #6466 from ONordander/feature/bitbucket-default-catalog-value
Feature/bitbucket default catalog value
This commit is contained in:
@@ -225,6 +225,34 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
optional: true,
|
||||
});
|
||||
});
|
||||
|
||||
it.each`
|
||||
target
|
||||
${'https://bitbucket.mycompany.com/projects/backstage/repos/*'}
|
||||
${'https://bitbucket.mycompany.com/projects/backstage/repos/*/'}
|
||||
${'https://bitbucket.mycompany.com/projects/backstage/repos/techdocs-*/'}
|
||||
`("target '$target' adds default path to catalog", async ({ target }) => {
|
||||
setupStubs([{ key: 'backstage', repos: ['techdocs-cli'] }]);
|
||||
|
||||
const location: LocationSpec = {
|
||||
type: 'bitbucket-discovery',
|
||||
target: target,
|
||||
};
|
||||
|
||||
const emitter = jest.fn();
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toHaveBeenCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.mycompany.com/projects/backstage/repos/techdocs-cli/browse/catalog-info.yaml',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Custom repository parser', () => {
|
||||
|
||||
@@ -84,13 +84,15 @@ export class BitbucketDiscoveryProcessor implements CatalogProcessor {
|
||||
this.logger.info(`Reading Bitbucket repositories from ${location.target}`);
|
||||
|
||||
const { catalogPath } = parseUrl(location.target);
|
||||
const expandedCatalogPath =
|
||||
catalogPath === '/' ? '/catalog-info.yaml' : catalogPath;
|
||||
|
||||
const result = await readBitbucketOrg(client, location.target);
|
||||
|
||||
for (const repository of result.matches) {
|
||||
for await (const entity of this.parser({
|
||||
integration: integration,
|
||||
target: `${repository.links.self[0].href}${catalogPath}`,
|
||||
target: `${repository.links.self[0].href}${expandedCatalogPath}`,
|
||||
logger: this.logger,
|
||||
})) {
|
||||
emit(entity);
|
||||
|
||||
Reference in New Issue
Block a user