Allow a domain entity to have a domain so that a domain hierarchy can be represented.

Signed-off-by: Dawn James <dawnj@spotify.com>
This commit is contained in:
Dawn James
2023-03-27 17:41:04 +01:00
parent 99a6dfa964
commit cbcfa722ab
6 changed files with 40 additions and 1 deletions
@@ -5,5 +5,6 @@ metadata:
description: A collection of all Backstage example domains
spec:
targets:
- ./domains/audio-domain.yaml
- ./domains/artists-domain.yaml
- ./domains/playback-domain.yaml
@@ -11,3 +11,4 @@ metadata:
icon: dashboard
spec:
owner: team-a
domain: audio
@@ -0,0 +1,13 @@
apiVersion: backstage.io/v1alpha1
kind: Domain
metadata:
name: audio
description: Everything related to audio
links:
- url: http://example.com/domain/audio/
title: Domain Readme
- url: http://example.com/domains/audio/dashboard
title: Domain Metrics Dashboard
icon: dashboard
spec:
owner: acme-corp
@@ -31,6 +31,7 @@ describe('DomainV1alpha1Validator', () => {
},
spec: {
owner: 'me',
domain: 'parent',
},
};
});
@@ -68,4 +69,19 @@ describe('DomainV1alpha1Validator', () => {
(entity as any).spec.owner = '';
await expect(validator.check(entity)).rejects.toThrow(/owner/);
});
it('accepts missing domain', async () => {
delete (entity as any).spec.domain;
await expect(validator.check(entity)).resolves.toBe(true);
});
it('rejects wrong domain', async () => {
(entity as any).spec.domain = 7;
await expect(validator.check(entity)).rejects.toThrow(/domain/);
});
it('rejects empty domain', async () => {
(entity as any).spec.domain = '';
await expect(validator.check(entity)).rejects.toThrow(/domain/);
});
});
@@ -32,6 +32,7 @@ export interface DomainEntityV1alpha1 extends Entity {
kind: 'Domain';
spec: {
owner: string;
domain?: string;
};
}
@@ -11,7 +11,8 @@
"description": "Everything about artists"
},
"spec": {
"owner": "artist-relations-team"
"owner": "artist-relations-team",
"domain": "artists"
}
}
],
@@ -38,6 +39,12 @@
"description": "An entity reference to the owner of the component.",
"examples": ["artist-relations-team", "user:john.johnson"],
"minLength": 1
},
"domain": {
"type": "string",
"description": "An entity reference to the domain that the system belongs to.",
"examples": ["artists"],
"minLength": 1
}
}
}