From 889b017b907350e5de7ecf8c5c11be42152661e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jano=20Gonz=C3=A1lez?= Date: Fri, 5 Apr 2024 16:40:02 +0200 Subject: [PATCH] Generate relations for subdomainOf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jano González Signed-off-by: Dawn James --- .../core/BuiltinKindsEntityProcessor.test.ts | 19 ++++++++++++++++++- .../core/BuiltinKindsEntityProcessor.ts | 6 ++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.test.ts b/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.test.ts index dbb9922fe0..e0368d40a6 100644 --- a/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.test.ts +++ b/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.test.ts @@ -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 () => { diff --git a/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.ts b/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.ts index 4dbb23addc..c9ea0dbdc1 100644 --- a/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.ts +++ b/plugins/catalog-backend/src/modules/core/BuiltinKindsEntityProcessor.ts @@ -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;