backend-app-api: use ConfigSources
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-app-api': patch
|
||||
---
|
||||
|
||||
Switch `configServiceFactory` to use `ConfigSources` from `@backstage/config-loader` to load config.
|
||||
@@ -26,6 +26,7 @@ import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
import { PermissionsService } from '@backstage/backend-plugin-api';
|
||||
import { PluginDatabaseManager } from '@backstage/backend-common';
|
||||
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
||||
import { RemoteConfigSourceOptions } from '@backstage/config-loader';
|
||||
import { RequestHandler } from 'express';
|
||||
import { RequestListener } from 'http';
|
||||
import { RootHttpRouterService } from '@backstage/backend-plugin-api';
|
||||
@@ -54,7 +55,7 @@ export const cacheServiceFactory: () => ServiceFactory<CacheClient, 'plugin'>;
|
||||
// @public (undocumented)
|
||||
export interface ConfigFactoryOptions {
|
||||
argv?: string[];
|
||||
remote?: LoadConfigOptionsRemote;
|
||||
remote?: Pick<RemoteConfigSourceOptions, 'reloadIntervalSeconds'>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
|
||||
+12
-7
@@ -18,8 +18,10 @@ import {
|
||||
coreServices,
|
||||
createServiceFactory,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { LoadConfigOptionsRemote } from '@backstage/config-loader';
|
||||
import { loadBackendConfig } from '../../../config';
|
||||
import {
|
||||
ConfigSources,
|
||||
RemoteConfigSourceOptions,
|
||||
} from '@backstage/config-loader';
|
||||
|
||||
/** @public */
|
||||
export interface ConfigFactoryOptions {
|
||||
@@ -31,7 +33,7 @@ export interface ConfigFactoryOptions {
|
||||
/**
|
||||
* Enables and sets options for remote configuration loading.
|
||||
*/
|
||||
remote?: LoadConfigOptionsRemote;
|
||||
remote?: Pick<RemoteConfigSourceOptions, 'reloadIntervalSeconds'>;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
@@ -39,10 +41,13 @@ export const configServiceFactory = createServiceFactory(
|
||||
(options?: ConfigFactoryOptions) => ({
|
||||
service: coreServices.config,
|
||||
deps: {},
|
||||
async factory({}) {
|
||||
const { argv = process.argv, remote } = options ?? {};
|
||||
const { config } = await loadBackendConfig({ argv, remote });
|
||||
return config;
|
||||
async factory() {
|
||||
const source = ConfigSources.default({
|
||||
argv: options?.argv,
|
||||
remote: options?.remote,
|
||||
});
|
||||
console.log(`Loading config from ${source}`);
|
||||
return await ConfigSources.toConfig(source);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user