Generate relations for subdomainOf

Signed-off-by: Jano González <info@janogonzalez.com>
Signed-off-by: Dawn James <dawnj@spotify.com>
This commit is contained in:
Jano González
2024-04-05 16:40:02 +02:00
committed by Dawn James
parent 645668a1b3
commit 889b017b90
2 changed files with 24 additions and 1 deletions
@@ -418,12 +418,13 @@ describe('BuiltinKindsEntityProcessor', () => {
metadata: { name: 'n' },
spec: {
owner: 'o',
subdomainOf: 'p',
},
};
await processor.postProcessEntity(entity, location, emit);
expect(emit).toHaveBeenCalledTimes(2);
expect(emit).toHaveBeenCalledTimes(4);
expect(emit).toHaveBeenCalledWith({
type: 'relation',
relation: {
@@ -440,6 +441,22 @@ describe('BuiltinKindsEntityProcessor', () => {
target: { kind: 'Group', namespace: 'default', name: 'o' },
},
});
expect(emit).toHaveBeenCalledWith({
type: 'relation',
relation: {
source: { kind: 'Domain', namespace: 'default', name: 'n' },
type: 'partOf',
target: { kind: 'Domain', namespace: 'default', name: 'p' },
},
});
expect(emit).toHaveBeenCalledWith({
type: 'relation',
relation: {
source: { kind: 'Domain', namespace: 'default', name: 'p' },
type: 'hasPart',
target: { kind: 'Domain', namespace: 'default', name: 'n' },
},
});
});
it('generates relations for user entities', async () => {
@@ -298,6 +298,12 @@ export class BuiltinKindsEntityProcessor implements CatalogProcessor {
RELATION_OWNED_BY,
RELATION_OWNER_OF,
);
doEmit(
domain.spec.subdomainOf,
{ defaultKind: 'Domain', defaultNamespace: selfRef.namespace },
RELATION_PART_OF,
RELATION_HAS_PART,
);
}
return entity;