backend-app-api: Move deprecated loadBackendConfig to backend-common

Co-authored-by: Camila Belo <camilaibs@gmail.com>
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2024-08-14 11:34:39 +02:00
parent 0c40cd7d40
commit f24ba909bf
12 changed files with 36 additions and 81 deletions
-19
View File
@@ -3,14 +3,10 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import type { AppConfig } from '@backstage/config';
import { BackendFeature } from '@backstage/backend-plugin-api';
import type { Config } from '@backstage/config';
import { ConfigSchema } from '@backstage/config-loader';
import { Format } from 'logform';
import { IdentityService } from '@backstage/backend-plugin-api';
import { JsonObject } from '@backstage/types';
import { LoadConfigOptionsRemote } from '@backstage/config-loader';
import { LoggerService } from '@backstage/backend-plugin-api';
import { RootLoggerService } from '@backstage/backend-plugin-api';
import { ServiceFactory } from '@backstage/backend-plugin-api';
@@ -42,11 +38,6 @@ export interface Backend {
stop(): Promise<void>;
}
// Warning: (ae-forgotten-export) The symbol "createConfigSecretEnumerator_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export const createConfigSecretEnumerator: typeof createConfigSecretEnumerator_2;
// @public (undocumented)
export function createSpecializedBackend(
options: CreateSpecializedBackendOptions,
@@ -72,16 +63,6 @@ export const identityServiceFactory: ServiceFactoryCompat<
IdentityFactoryOptions
>;
// @public @deprecated
export function loadBackendConfig(options: {
remote?: LoadConfigOptionsRemote;
argv: string[];
additionalConfigs?: AppConfig[];
watch?: boolean;
}): Promise<{
config: Config;
}>;
// @public @deprecated (undocumented)
export const tokenManagerServiceFactory: ServiceFactoryCompat<
TokenManagerService,
-1
View File
@@ -20,7 +20,6 @@
* @packageDocumentation
*/
export * from './config';
export * from './logging';
export * from './wiring';
export * from './services/implementations';
+6
View File
@@ -21,6 +21,7 @@ import { CacheService } from '@backstage/backend-plugin-api';
import { CacheServiceOptions } from '@backstage/backend-plugin-api';
import { CacheServiceSetOptions } from '@backstage/backend-plugin-api';
import { Config } from '@backstage/config';
import { ConfigSchema } from '@backstage/config-loader';
import cors from 'cors';
import { DatabaseService } from '@backstage/backend-plugin-api';
import { DiscoveryService } from '@backstage/backend-plugin-api';
@@ -133,6 +134,11 @@ export interface ContainerRunner {
runContainer(opts: RunContainerOptions): Promise<void>;
}
// Warning: (ae-forgotten-export) The symbol "createConfigSecretEnumerator_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export const createConfigSecretEnumerator: typeof createConfigSecretEnumerator_2;
// @public @deprecated
export function createLegacyAuthAdapters<
TOptions extends {
@@ -1,54 +0,0 @@
/*
* Copyright 2020 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.
*/
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
import {
createConfigSecretEnumerator,
loadBackendConfig as newLoadBackendConfig,
} from '../../../backend-app-api/src/config';
import { LoggerService } from '@backstage/backend-plugin-api';
import { AppConfig, Config } from '@backstage/config';
import { LoadConfigOptionsRemote } from '@backstage/config-loader';
import { setRootLoggerRedactionList } from './logging/createRootLogger';
/**
* Load configuration for a Backend.
*
* This function should only be called once, during the initialization of the backend.
*
* @public
* @deprecated Use {@link @backstage/backend-app-api#loadBackendConfig} instead.
*/
export async function loadBackendConfig(options: {
logger: LoggerService;
// process.argv or any other overrides
remote?: LoadConfigOptionsRemote;
additionalConfigs?: AppConfig[];
argv: string[];
watch?: boolean;
}): Promise<Config> {
const secretEnumerator = await createConfigSecretEnumerator({
logger: options.logger,
});
const { config } = await newLoadBackendConfig(options);
setRootLoggerRedactionList(secretEnumerator(config));
config.subscribe?.(() =>
setRootLoggerRedactionList(secretEnumerator(config)),
);
return config;
}
@@ -15,8 +15,8 @@
*/
import { loadConfigSchema } from '@backstage/config-loader';
import { createConfigSecretEnumerator } from './config';
import { mockServices } from '@backstage/backend-test-utils';
import { createConfigSecretEnumerator } from './config';
describe('createConfigSecretEnumerator', () => {
it('should enumerate secrets', async () => {
@@ -14,8 +14,11 @@
* limitations under the License.
*/
import { LoggerService } from '@backstage/backend-plugin-api';
import { AppConfig, Config } from '@backstage/config';
import { setRootLoggerRedactionList } from '../logging/createRootLogger';
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
import { createConfigSecretEnumerator as _createConfigSecretEnumerator } from '../../../backend-defaults/src/entrypoints/rootConfig/createConfigSecretEnumerator';
import { createConfigSecretEnumerator as _createConfigSecretEnumerator } from '../../../../backend-defaults/src/entrypoints/rootConfig/createConfigSecretEnumerator';
import { resolve as resolvePath } from 'path';
import parseArgs from 'minimist';
@@ -26,13 +29,12 @@ import {
LoadConfigOptionsRemote,
} from '@backstage/config-loader';
import { ConfigReader } from '@backstage/config';
import type { Config, AppConfig } from '@backstage/config';
import { ObservableConfigProxy } from './ObservableConfigProxy';
import { isValidUrl } from '../lib/urls';
import { isValidUrl } from './urls';
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootConfig` instead.
* @deprecated Please migrate to the new backend system and use `coreServices.rootConfig` instead, or the {@link @backstage/config-loader#ConfigSources} facilities if required.
*/
export const createConfigSecretEnumerator = _createConfigSecretEnumerator;
@@ -45,6 +47,27 @@ export const createConfigSecretEnumerator = _createConfigSecretEnumerator;
* @deprecated Please migrate to the new backend system and use `coreServices.rootConfig` instead, or the {@link @backstage/config-loader#ConfigSources} facilities if required.
*/
export async function loadBackendConfig(options: {
logger: LoggerService;
// process.argv or any other overrides
remote?: LoadConfigOptionsRemote;
additionalConfigs?: AppConfig[];
argv: string[];
watch?: boolean;
}): Promise<Config> {
const secretEnumerator = await createConfigSecretEnumerator({
logger: options.logger,
});
const { config } = await newLoadBackendConfig(options);
setRootLoggerRedactionList(secretEnumerator(config));
config.subscribe?.(() =>
setRootLoggerRedactionList(secretEnumerator(config)),
);
return config;
}
async function newLoadBackendConfig(options: {
remote?: LoadConfigOptionsRemote;
argv: string[];
additionalConfigs?: AppConfig[];
@@ -1,5 +1,5 @@
/*
* Copyright 2023 The Backstage Authors
* Copyright 2024 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.
@@ -20,7 +20,7 @@ import {
} from '@backstage/backend-plugin-api';
import { WinstonLogger } from '@backstage/backend-app-api';
import { transports, format } from 'winston';
import { createConfigSecretEnumerator } from '@backstage/backend-app-api';
import { createConfigSecretEnumerator } from '@backstage/backend-common';
import { loadConfigSchema } from '@backstage/config-loader';
import { getPackages } from '@manypkg/get-packages';
import { dynamicPluginsSchemasServiceRef } from './schemas';