Merge pull request #8343 from backstage/rugvip/presence
catalog-backend: fix handling of optional locations
This commit is contained in:
@@ -165,6 +165,7 @@ describe('AzureDevOpsDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://dev.azure.com/shopify/engineering/_git/backstage?path=/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -174,6 +175,7 @@ describe('AzureDevOpsDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://dev.azure.com/shopify/engineering/_git/ios-app?path=/src/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -211,6 +213,7 @@ describe('AzureDevOpsDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://dev.azure.com/shopify/engineering/_git/backstage?path=/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -249,6 +252,7 @@ describe('AzureDevOpsDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://dev.azure.com/shopify/engineering/_git/backstage?path=/src/main/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
|
||||
@@ -95,6 +95,7 @@ export class AzureDevOpsDiscoveryProcessor implements CatalogProcessor {
|
||||
{
|
||||
type: 'url',
|
||||
target: `${baseUrl}/${org}/${project}/_git/${file.repository.name}?path=${file.path}`,
|
||||
presence: 'optional',
|
||||
},
|
||||
// Not all locations may actually exist, since the user defined them as a wildcard pattern.
|
||||
// Thus, we emit them as optional and let the downstream processor find them while not outputting
|
||||
|
||||
@@ -208,6 +208,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.mycompany.com/projects/backstage/repos/backstage/browse/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -217,6 +218,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.mycompany.com/projects/demo/repos/demo/browse/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -242,6 +244,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.mycompany.com/projects/backstage/repos/techdocs-cli/browse/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -263,6 +266,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.mycompany.com/projects/backstage/repos/test/browse/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -291,6 +295,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.mycompany.com/projects/backstage/repos/techdocs-cli/browse/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -334,6 +339,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.org/myworkspace/repository-one/src/master/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -343,6 +349,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.org/myworkspace/repository-two/src/master/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -370,6 +377,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.org/myworkspace/repository-one/src/master/my/nested/path/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -379,6 +387,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.org/myworkspace/repository-two/src/master/my/nested/path/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -406,6 +415,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.org/myworkspace/repository-one/src/master/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -415,6 +425,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.org/myworkspace/repository-two/src/master/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -441,6 +452,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.org/myworkspace/repository-one/src/master/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -468,6 +480,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.org/myworkspace/repository-three/src/master/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -493,6 +506,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.org/myworkspace/repository-one/src/master/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -528,6 +542,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://bitbucket.org/myworkspace/repository-one/src/master/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
|
||||
@@ -201,6 +201,7 @@ describe('GitlabDiscoveryProcessor', () => {
|
||||
location: {
|
||||
type: 'url',
|
||||
target: 'https://gitlab.fake/1/-/blob/main/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
},
|
||||
@@ -209,6 +210,7 @@ describe('GitlabDiscoveryProcessor', () => {
|
||||
location: {
|
||||
type: 'url',
|
||||
target: 'https://gitlab.fake/2/-/blob/master/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
},
|
||||
@@ -246,6 +248,7 @@ describe('GitlabDiscoveryProcessor', () => {
|
||||
location: {
|
||||
type: 'url',
|
||||
target: 'https://gitlab.fake/1/-/blob/master/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
},
|
||||
|
||||
@@ -113,6 +113,7 @@ export class GitLabDiscoveryProcessor implements CatalogProcessor {
|
||||
// The alternative is using the `buildRawUrl` function, which does not support subgroups, so providing a raw
|
||||
// URL here won't work either.
|
||||
target: `${project.web_url}/-/blob/${project_branch}/${catalogPath}`,
|
||||
presence: 'optional',
|
||||
},
|
||||
true,
|
||||
),
|
||||
|
||||
@@ -157,6 +157,7 @@ describe('GithubDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://github.com/backstage/backstage/blob/master/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -165,6 +166,7 @@ describe('GithubDiscoveryProcessor', () => {
|
||||
location: {
|
||||
type: 'url',
|
||||
target: 'https://github.com/backstage/demo/blob/master/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -197,6 +199,7 @@ describe('GithubDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://github.com/backstage/tech-docs/blob/main/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -251,6 +254,7 @@ describe('GithubDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -306,6 +310,7 @@ describe('GithubDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://github.com/backstage/techdocs-cli/blob/master/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -315,6 +320,7 @@ describe('GithubDiscoveryProcessor', () => {
|
||||
type: 'url',
|
||||
target:
|
||||
'https://github.com/backstage/techdocs-container/blob/master/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
@@ -370,6 +376,7 @@ describe('GithubDiscoveryProcessor', () => {
|
||||
location: {
|
||||
type: 'url',
|
||||
target: 'https://github.com/backstage/test/blob/master/catalog.yaml',
|
||||
presence: 'optional',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
|
||||
@@ -125,6 +125,7 @@ export class GithubDiscoveryProcessor implements CatalogProcessor {
|
||||
{
|
||||
type: 'url',
|
||||
target: `${repository.url}${path}`,
|
||||
presence: 'optional',
|
||||
},
|
||||
// Not all locations may actually exist, since the user defined them as a wildcard pattern.
|
||||
// Thus, we emit them as optional and let the downstream processor find them while not outputting
|
||||
|
||||
+1
@@ -29,6 +29,7 @@ describe('BitbucketRepositoryParser', () => {
|
||||
{
|
||||
type: 'url',
|
||||
target: `${browseUrl}${path}`,
|
||||
presence: 'optional',
|
||||
},
|
||||
true,
|
||||
),
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ export const defaultRepositoryParser: BitbucketRepositoryParser =
|
||||
{
|
||||
type: 'url',
|
||||
target: target,
|
||||
presence: 'optional',
|
||||
},
|
||||
// Not all locations may actually exist, since the user defined them as a wildcard pattern.
|
||||
// Thus, we emit them as optional and let the downstream processor find them while not outputting
|
||||
|
||||
@@ -284,7 +284,7 @@ export class DefaultCatalogProcessingOrchestrator
|
||||
entity: LocationEntity,
|
||||
context: Context,
|
||||
): Promise<void> {
|
||||
const { type = context.location.type } = entity.spec;
|
||||
const { type = context.location.type, presence = 'required' } = entity.spec;
|
||||
const targets = new Array<string>();
|
||||
if (entity.spec.target) {
|
||||
targets.push(entity.spec.target);
|
||||
@@ -318,9 +318,9 @@ export class DefaultCatalogProcessingOrchestrator
|
||||
{
|
||||
type,
|
||||
target,
|
||||
presence: 'required',
|
||||
presence,
|
||||
},
|
||||
false,
|
||||
presence === 'optional',
|
||||
context.collector.onEmit,
|
||||
this.options.parser,
|
||||
context.cache.forProcessor(processor, target),
|
||||
|
||||
@@ -105,8 +105,9 @@ export class ProcessorOutputCollector {
|
||||
|
||||
this.deferredEntities.push({ entity, locationKey: location });
|
||||
} else if (i.type === 'location') {
|
||||
const presence = i.optional ? 'optional' : 'required';
|
||||
const entity = locationSpecToLocationEntity(
|
||||
i.location,
|
||||
{ presence, ...i.location },
|
||||
this.parentEntity,
|
||||
);
|
||||
const locationKey = getEntityLocationRef(entity);
|
||||
|
||||
@@ -81,6 +81,7 @@ export function locationSpecToLocationEntity(
|
||||
spec: {
|
||||
type: location.type,
|
||||
target: location.target,
|
||||
presence: location.presence,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user