address comments

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-08-24 14:46:54 +02:00
parent 246aee22f5
commit e22790d97a
2 changed files with 15 additions and 10 deletions
@@ -347,13 +347,12 @@ describe('expandShorthandExtensionParameters', () => {
});
});
it('supports object id', () => {
expect(
run({ 'core.router/routes': { id: 'example-package#MyRouter' } }),
).toEqual({
id: 'example-package#MyRouter',
at: 'core.router/routes',
});
it('supports object id only in the key', () => {
expect(() =>
run({ 'core.router/routes': { id: 'some.id' } }),
).toThrowErrorMatchingInlineSnapshot(
`"Invalid extension configuration at app.extensions[1][core.router/routes].id, must not specify 'id' when the extension input ID form of the key is used (with a slash); please replace the key 'core.router/routes' with the id instead, and put that key in the 'at' field"`,
);
expect(() =>
run({
'core.router/routes': {
@@ -153,7 +153,6 @@ export function expandShorthandExtensionParameters(
// The remaining case is the generic object. Example YAML:
// - core.router/routes:
// id: redirects.catalog
// extension: '@backstage/core-app-api#Redirect'
// config:
// path: /
@@ -186,9 +185,16 @@ export function expandShorthandExtensionParameters(
),
);
}
if (id === undefined) {
id = generateExtensionId();
if (id !== undefined) {
throw new Error(
errorMsg(
`must not specify 'id' when the extension input ID form of the key is used (with a slash); please replace the key '${key}' with the id instead, and put that key in the 'at' field`,
key,
'id',
),
);
}
id = generateExtensionId();
at = key;
} else {
if (id !== undefined) {