move alpha instance to default service factories
Signed-off-by: aramissennyeydd <aramis.sennyey@doordash.com>
This commit is contained in:
@@ -148,24 +148,6 @@ function createRootInstanceMetadataServiceFactory(
|
||||
});
|
||||
}
|
||||
|
||||
function createDeprecatedInstanceMetadataServiceFactory() {
|
||||
return createServiceFactory({
|
||||
service: instanceMetadataServiceRef,
|
||||
deps: {
|
||||
instanceMetadata: coreServices.rootInstanceMetadata,
|
||||
},
|
||||
factory: async ({ instanceMetadata }) => {
|
||||
const plugins = await instanceMetadata.getInstalledPlugins();
|
||||
const service = {
|
||||
getInstalledFeatures: () =>
|
||||
plugins.map(e => ({ type: 'plugin' as const, pluginId: e.pluginId })),
|
||||
};
|
||||
|
||||
return service;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export class BackendInitializer {
|
||||
#startPromise?: Promise<void>;
|
||||
#stopPromise?: Promise<void>;
|
||||
@@ -269,7 +251,6 @@ export class BackendInitializer {
|
||||
this.#serviceRegistry.add(
|
||||
createRootInstanceMetadataServiceFactory(this.#registrations),
|
||||
);
|
||||
this.#serviceRegistry.add(createDeprecatedInstanceMetadataServiceFactory());
|
||||
|
||||
// This makes sure that any uncaught errors or unhandled rejections are
|
||||
// caught and logged, rather than terminating the process. We register these
|
||||
|
||||
@@ -38,6 +38,7 @@ import { eventsServiceFactory } from '@backstage/plugin-events-node';
|
||||
import {
|
||||
actionsRegistryServiceFactory,
|
||||
actionsServiceFactory,
|
||||
instanceMetadataServiceFactory,
|
||||
} from '@backstage/backend-defaults/alpha';
|
||||
|
||||
export const defaultServiceFactories = [
|
||||
@@ -65,6 +66,7 @@ export const defaultServiceFactories = [
|
||||
// alpha services
|
||||
actionsRegistryServiceFactory,
|
||||
actionsServiceFactory,
|
||||
instanceMetadataServiceFactory,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2025 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { instanceMetadataServiceFactory } from './instanceMetadataServiceFactory';
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2025 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
coreServices,
|
||||
createServiceFactory,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { instanceMetadataServiceRef } from '@backstage/backend-plugin-api/alpha';
|
||||
|
||||
export const instanceMetadataServiceFactory = createServiceFactory({
|
||||
service: instanceMetadataServiceRef,
|
||||
deps: {
|
||||
instanceMetadata: coreServices.rootInstanceMetadata,
|
||||
},
|
||||
factory: async ({ instanceMetadata }) => {
|
||||
const plugins = await instanceMetadata.getInstalledPlugins();
|
||||
const service = {
|
||||
getInstalledFeatures: () =>
|
||||
plugins.map(e => ({ type: 'plugin' as const, pluginId: e.pluginId })),
|
||||
};
|
||||
|
||||
return service;
|
||||
},
|
||||
});
|
||||
@@ -15,3 +15,4 @@
|
||||
*/
|
||||
export { actionsRegistryServiceFactory } from './entrypoints/actionsRegistry';
|
||||
export { actionsServiceFactory } from './entrypoints/actions';
|
||||
export { instanceMetadataServiceFactory } from './entrypoints/instanceMetadata';
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
DatabaseService,
|
||||
DiscoveryService,
|
||||
HttpAuthService,
|
||||
InstanceMetadataService,
|
||||
RootInstanceMetadataService,
|
||||
LoggerService,
|
||||
PermissionsService,
|
||||
RootConfigService,
|
||||
@@ -558,18 +558,18 @@ export namespace mockServices {
|
||||
}));
|
||||
}
|
||||
|
||||
export function instanceMetadata(): InstanceMetadataService {
|
||||
export function rootInstanceMetadata(): RootInstanceMetadataService {
|
||||
return {
|
||||
getInstalledPlugins: () => Promise.resolve([]),
|
||||
};
|
||||
}
|
||||
export namespace instanceMetadata {
|
||||
export const mock = simpleMock(coreServices.instanceMetadata, () => ({
|
||||
export namespace rootInstanceMetadata {
|
||||
export const mock = simpleMock(coreServices.rootInstanceMetadata, () => ({
|
||||
getInstalledPlugins: jest.fn(),
|
||||
}));
|
||||
export const factory = simpleFactoryWithOptions(
|
||||
coreServices.instanceMetadata,
|
||||
instanceMetadata,
|
||||
coreServices.rootInstanceMetadata,
|
||||
rootInstanceMetadata,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user