Merge pull request #17125 from dawngerpony/dawngerpony/parent-domain-v1
Allow a domain entity to have an optional domain
This commit is contained in:
@@ -122,6 +122,7 @@ interface DomainEntityV1alpha1 extends Entity {
|
||||
// (undocumented)
|
||||
spec: {
|
||||
owner: string;
|
||||
subdomainOf?: string;
|
||||
};
|
||||
}
|
||||
export { DomainEntityV1alpha1 as DomainEntity };
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -12,3 +12,4 @@ metadata:
|
||||
icon: dashboard
|
||||
spec:
|
||||
owner: team-a
|
||||
subdomainOf: 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
|
||||
@@ -5,3 +5,4 @@ metadata:
|
||||
description: Everything related to audio playback
|
||||
spec:
|
||||
owner: user:frank.tiernan
|
||||
subdomainOf: audio
|
||||
|
||||
@@ -31,6 +31,7 @@ describe('DomainV1alpha1Validator', () => {
|
||||
},
|
||||
spec: {
|
||||
owner: 'me',
|
||||
subdomainOf: 'parent-domain',
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -68,4 +69,19 @@ describe('DomainV1alpha1Validator', () => {
|
||||
(entity as any).spec.owner = '';
|
||||
await expect(validator.check(entity)).rejects.toThrow(/owner/);
|
||||
});
|
||||
|
||||
it('accepts missing subdomainOf', async () => {
|
||||
delete (entity as any).spec.subdomainOf;
|
||||
await expect(validator.check(entity)).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it('rejects wrong subdomainOf', async () => {
|
||||
(entity as any).spec.subdomainOf = 7;
|
||||
await expect(validator.check(entity)).rejects.toThrow(/subdomainOf/);
|
||||
});
|
||||
|
||||
it('rejects empty subdomainOf', async () => {
|
||||
(entity as any).spec.subdomainOf = '';
|
||||
await expect(validator.check(entity)).rejects.toThrow(/subdomainOf/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,6 +32,7 @@ export interface DomainEntityV1alpha1 extends Entity {
|
||||
kind: 'Domain';
|
||||
spec: {
|
||||
owner: string;
|
||||
subdomainOf?: string;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"description": "Everything about artists"
|
||||
},
|
||||
"spec": {
|
||||
"owner": "artist-relations-team"
|
||||
"owner": "artist-relations-team",
|
||||
"subdomainOf": "audio"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -38,6 +39,12 @@
|
||||
"description": "An entity reference to the owner of the component.",
|
||||
"examples": ["artist-relations-team", "user:john.johnson"],
|
||||
"minLength": 1
|
||||
},
|
||||
"subdomainOf": {
|
||||
"type": "string",
|
||||
"description": "An entity reference to another domain of which the domain is a part.",
|
||||
"examples": ["audio"],
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user