backend-defaults: update root config implementation to use manual factory pattern + update docs

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-07-16 10:20:11 +02:00
parent e28af58b4b
commit e375bb93df
4 changed files with 42 additions and 17 deletions
@@ -36,18 +36,39 @@ createBackendPlugin({
## Configuring the 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:
There's additional configuration that you can optionally pass to setup the `config` core service.
- `argv` - Override the arguments that are passed to the config loader, instead of using `process.argv`
- `remote` - Configure remote configuration loading
You can use these to create your own config service implementation:
You can configure these additional options by adding an override for the core service when calling `createBackend` like follows:
```ts
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 },
}),
);
```
For more advanced customization, 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 the same options as the `rootConfigServiceFactory` function. You can use these to create your own config service implementation:
```ts
import { ConfigSources } from '@backstage/config-loader';
import { createServiceFactory } from '@backstage/backend-plugin-api';
const backend = createBackend();
backend.add(
createServiceFactory({
service: coreServices.rootConfig,