Merge pull request #17824 from kmarkow/Issue-17779
Deprecate target field and make targetRef required
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/catalog-model': minor
|
||||
---
|
||||
|
||||
Deprecate target field and make targetRef required in common.schema.json
|
||||
@@ -364,6 +364,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", "target", "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,11 +365,16 @@ describe('entitySchemaValidator', () => {
|
||||
expect(() => validator(entity)).toThrow(/relations/);
|
||||
});
|
||||
|
||||
it('rejects missing relations.target', () => {
|
||||
it('does reject missing relations.target', () => {
|
||||
delete entity.relations[0].target;
|
||||
expect(() => validator(entity)).toThrow(/relations/);
|
||||
});
|
||||
|
||||
it('does reject missing relations.targetRef', () => {
|
||||
delete entity.relations[0].targetRef;
|
||||
expect(() => validator(entity)).toThrow(/relations/);
|
||||
});
|
||||
|
||||
it('rejects empty relations.target', () => {
|
||||
entity.relations[0].target = '';
|
||||
expect(() => validator(entity)).toThrow(/relations/);
|
||||
|
||||
Reference in New Issue
Block a user