Merge pull request #2994 from spotify/rugvip/conflagrate

config-loader: switch to using --config options to load in config
This commit is contained in:
Patrik Oldsberg
2020-10-22 18:01:21 +02:00
committed by GitHub
38 changed files with 271 additions and 370 deletions
+2
View File
@@ -46,6 +46,7 @@
"knex": "^0.21.1",
"lodash": "^4.17.15",
"logform": "^2.1.1",
"minimist": "^1.2.5",
"morgan": "^1.10.0",
"prom-client": "^12.0.0",
"selfsigned": "^1.10.7",
@@ -64,6 +65,7 @@
"@backstage/cli": "^0.1.1-alpha.25",
"@types/compression": "^1.7.0",
"@types/http-errors": "^1.6.3",
"@types/minimist": "^1.2.0",
"@types/morgan": "^1.9.0",
"@types/stoppable": "^1.1.0",
"@types/supertest": "^2.0.8",
+10 -2
View File
@@ -14,24 +14,32 @@
* limitations under the License.
*/
import { resolve as resolvePath } from 'path';
import parseArgs from 'minimist';
import { Logger } from 'winston';
import { findPaths } from '@backstage/cli-common';
import { Config, ConfigReader } from '@backstage/config';
import { loadConfig } from '@backstage/config-loader';
import { Logger } from 'winston';
type Options = {
logger: Logger;
// process.argv or any other overrides
argv: string[];
};
/**
* Load configuration for a Backend
*/
export async function loadBackendConfig(options: Options): Promise<Config> {
const args = parseArgs(options.argv);
const configOpts: string[] = [args.config ?? []].flat();
/* eslint-disable-next-line no-restricted-syntax */
const paths = findPaths(__dirname);
const configs = await loadConfig({
env: process.env.APP_ENV ?? process.env.NODE_ENV ?? 'development',
rootPaths: [paths.targetRoot, paths.targetDir],
configRoot: paths.targetRoot,
configPaths: configOpts.map(opt => resolvePath(opt)),
shouldReadSecrets: true,
});