backend-defaults: deprecate config service options

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-07-11 11:12:21 +02:00
parent 0a474ae85a
commit e28af58b4b
4 changed files with 27 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-defaults': patch
---
The `RootConfigFactoryOptions` have been deprecated alongside the deprecation of service factory options. For more information on how to customize the config service, see the [Root Config Service docs](https://backstage.io/docs/backend-system/core-services/root-config#configuring-the-service).
@@ -36,12 +36,12 @@ createBackendPlugin({
## Configuring the service
There's additional configuration that you can optionally pass to setup the `config` core service.
There are several APIs from the `@backstage/config-loader` package that allow you to customize the implementation of the config service. The default implementation uses the `ConfigSources.default` method, which has several options, for example:
- `argv` - Override the arguments that are passed to the config loader, instead of using `process.argv`
- `remote` - Configure remote configuration loading
You can configure these additional options by adding an override for the core service when calling `createBackend` like follows:
You can use these to create your own config service implementation:
```ts
import { rootConfigServiceFactory } from '@backstage/backend-app-api';
@@ -49,14 +49,24 @@ import { rootConfigServiceFactory } from '@backstage/backend-app-api';
const backend = createBackend();
backend.add(
rootConfigServiceFactory({
argv: [
'--config',
'/backstage/app-config.development.yaml',
'--config',
'/backstage/app-config.yaml',
],
remote: { reloadIntervalSeconds: 60 },
createServiceFactory({
service: coreServices.rootConfig,
deps: {},
async factory() {
const source = ConfigSources.default({
argv: [
'--config',
'/backstage/app-config.development.yaml',
'--config',
'/backstage/app-config.yaml',
],
remote: { reloadIntervalSeconds: 60 },
});
console.log(`Loading config from ${source}`);
return await ConfigSources.toConfig(source);
},
}),
);
```
You can also use other config source such as `StaticConfigSource` and combine them with other sources using `ConfigSources.merge(...)`. You can also create your own config source by implementing the `ConfigSource` interface.
@@ -17,7 +17,7 @@ export function createConfigSecretEnumerator(options: {
schema?: ConfigSchema;
}): Promise<(config: Config) => Iterable<string>>;
// @public
// @public @deprecated
export interface RootConfigFactoryOptions {
argv?: string[];
remote?: Pick<RemoteConfigSourceOptions, 'reloadInterval'>;
@@ -31,6 +31,7 @@ import {
* for more information.
*
* @public
* @deprecated These service options will be removed, please use the `ConfigSources` API from `@backstage/config-loader` to implement your own version of the service factory instead.
*/
export interface RootConfigFactoryOptions {
/**