Deprecate target field and make targetRef required

Signed-off-by: kmarkow <kamilmarkow@gmail.com>
This commit is contained in:
kmarkow
2023-05-16 10:09:18 -04:00
parent 93daeb898f
commit 33eae4b39a
5 changed files with 25 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/catalog-model': minor
---
Deprecate target field and make targetRef required in common.schema.json
+1
View File
@@ -361,6 +361,7 @@ SVGs
talkdesk
Talkdesk
Tanzu
targetRef
tasklist
techdocs
Telenor
@@ -32,7 +32,7 @@
"$id": "#relation",
"type": "object",
"description": "A directed relation from one entity to another.",
"required": ["type", "target"],
"required": ["type", "targetRef"],
"additionalProperties": false,
"properties": {
"type": {
@@ -42,7 +42,8 @@
"description": "The type of relation."
},
"target": {
"$ref": "#reference"
"$ref": "#reference",
"deprecated": true
},
"targetRef": {
"type": "string",
@@ -51,7 +51,11 @@ describe('entityKindSchemaValidator', () => {
owner: 'me',
},
relations: [
{ type: 't', target: { kind: 'k', namespace: 'ns', name: 'n' } },
{
type: 't',
targetRef: 'someTargetRef',
target: { kind: 'k', namespace: 'ns', name: 'n' },
},
],
status: {
items: [
@@ -52,7 +52,11 @@ describe('entitySchemaValidator', () => {
owner: 'me',
},
relations: [
{ type: 't', target: { kind: 'k', namespace: 'ns', name: 'n' } },
{
type: 't',
targetRef: 'someTargetRef',
target: { kind: 'k', namespace: 'ns', name: 'n' },
},
],
status: {
items: [
@@ -361,8 +365,13 @@ describe('entitySchemaValidator', () => {
expect(() => validator(entity)).toThrow(/relations/);
});
it('rejects missing relations.target', () => {
it('does not reject missing relations.target', () => {
delete entity.relations[0].target;
expect(() => validator(entity)).not.toThrow(/relations/);
});
it('does reject missing relations.targetRef', () => {
delete entity.relations[0].targetRef;
expect(() => validator(entity)).toThrow(/relations/);
});