log BackendFeatureMeta nicer
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-app-api': patch
|
||||
---
|
||||
|
||||
Add a `toString` on the default `BackendFeatureMeta` implementations
|
||||
@@ -885,7 +885,7 @@ describe('BackendInitializer', () => {
|
||||
});
|
||||
|
||||
it('should properly add plugins + modules to the instance metadata service', async () => {
|
||||
expect.assertions(1);
|
||||
expect.assertions(2);
|
||||
const backend = new BackendInitializer(baseFactories);
|
||||
const plugin = createBackendPlugin({
|
||||
pluginId: 'test',
|
||||
@@ -919,6 +919,13 @@ describe('BackendInitializer', () => {
|
||||
type: 'plugin',
|
||||
},
|
||||
]);
|
||||
expect(instanceMetadata.getInstalledFeatures().map(String)).toEqual(
|
||||
[
|
||||
'plugin{pluginId=test}',
|
||||
'module{moduleId=test,pluginId=test}',
|
||||
'plugin{pluginId=instance-metadata}',
|
||||
],
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
@@ -111,13 +111,33 @@ function createInstanceMetadataServiceFactory(
|
||||
.getRegistrations()
|
||||
.map(feature => {
|
||||
if (feature.type === 'plugin') {
|
||||
return { type: 'plugin', pluginId: feature.pluginId };
|
||||
return Object.defineProperty(
|
||||
{
|
||||
type: 'plugin',
|
||||
pluginId: feature.pluginId,
|
||||
},
|
||||
'toString',
|
||||
{
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
value: () => `plugin{pluginId=${feature.pluginId}}`,
|
||||
},
|
||||
);
|
||||
} else if (feature.type === 'module') {
|
||||
return {
|
||||
type: 'module',
|
||||
pluginId: feature.pluginId,
|
||||
moduleId: feature.moduleId,
|
||||
};
|
||||
return Object.defineProperty(
|
||||
{
|
||||
type: 'module',
|
||||
pluginId: feature.pluginId,
|
||||
moduleId: feature.moduleId,
|
||||
},
|
||||
'toString',
|
||||
{
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
value: () =>
|
||||
`module{moduleId=${feature.moduleId},pluginId=${feature.pluginId}}`,
|
||||
},
|
||||
);
|
||||
}
|
||||
// Ignore unknown feature types.
|
||||
return undefined;
|
||||
|
||||
@@ -30,7 +30,9 @@ export default createBackendPlugin({
|
||||
},
|
||||
async init({ instanceMetadata, logger }) {
|
||||
logger.info(
|
||||
`Installed features on this instance: ${instanceMetadata.getInstalledFeatures()}`,
|
||||
`Installed features on this instance: ${instanceMetadata
|
||||
.getInstalledFeatures()
|
||||
.join(', ')}`,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user