From 5798d2566f2d6898863568793de556cbc58c3e2d Mon Sep 17 00:00:00 2001 From: Hellgren Heikki Date: Mon, 8 Sep 2025 08:47:51 +0300 Subject: [PATCH] chore: change to BACKSTAGE_ENV as per review Signed-off-by: Hellgren Heikki --- .changeset/better-eagles-tickle.md | 2 +- docs/conf/index.md | 8 ++++---- .../config-loader/src/sources/ConfigSources.test.ts | 2 +- packages/config-loader/src/sources/ConfigSources.ts | 11 ++++------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.changeset/better-eagles-tickle.md b/.changeset/better-eagles-tickle.md index b199ae21d7..418f0bcae0 100644 --- a/.changeset/better-eagles-tickle.md +++ b/.changeset/better-eagles-tickle.md @@ -2,4 +2,4 @@ '@backstage/config-loader': patch --- -Allow using `BACKSTAGE_ENVIRONMENT` for loading environment specific config files +Allow using `BACKSTAGE_ENV` for loading environment specific config files diff --git a/docs/conf/index.md b/docs/conf/index.md index 0b2240e2de..029c5b88fd 100644 --- a/docs/conf/index.md +++ b/docs/conf/index.md @@ -17,15 +17,15 @@ allowing for customization. Configuration is stored in YAML files where the defaults are `app-config.yaml` and `app-config.local.yaml` for local overrides. Additionally, it is possible -to define environment based configuration files with `BACKSTAGE_ENVIRONMENT` -environment variable, which will load `app-config..yaml`. +to define environment based configuration files with `BACKSTAGE_ENV` +environment variable, which will load `app-config..yaml`. Loading order of these files is as follows: 1. `app-config.yaml` -2. `app-config..yaml` +2. `app-config..yaml` 3. `app-config.local.yaml` -4. `app-config..local.yaml` +4. `app-config..local.yaml` Other sets of files can by loaded by passing `--config ` flags. Read more about the configuration loading order in the diff --git a/packages/config-loader/src/sources/ConfigSources.test.ts b/packages/config-loader/src/sources/ConfigSources.test.ts index da56f5ccf9..a6b0648889 100644 --- a/packages/config-loader/src/sources/ConfigSources.test.ts +++ b/packages/config-loader/src/sources/ConfigSources.test.ts @@ -90,7 +90,7 @@ describe('ConfigSources', () => { { name: 'FileConfigSource', path: `${root}app-config.local.yaml` }, ]); - process.env = Object.assign(process.env, { BACKSTAGE_ENVIRONMENT: 'test' }); + process.env = Object.assign(process.env, { BACKSTAGE_ENV: 'test' }); expect( mergeSources( ConfigSources.defaultForTargets({ rootDir: '/', targets: [] }), diff --git a/packages/config-loader/src/sources/ConfigSources.ts b/packages/config-loader/src/sources/ConfigSources.ts index 1dacdc4752..18d0443986 100644 --- a/packages/config-loader/src/sources/ConfigSources.ts +++ b/packages/config-loader/src/sources/ConfigSources.ts @@ -184,11 +184,11 @@ export class ConfigSources { const localPath = resolvePath(rootDir, 'app-config.local.yaml'); const envPath = resolvePath( rootDir, - `app-config.${process.env.BACKSTAGE_ENVIRONMENT}.yaml`, + `app-config.${process.env.BACKSTAGE_ENV}.yaml`, ); const envLocalPath = resolvePath( rootDir, - `app-config.${process.env.BACKSTAGE_ENVIRONMENT}.local.yaml`, + `app-config.${process.env.BACKSTAGE_ENV}.local.yaml`, ); const alwaysIncludeDefaultConfigSource = !options.allowMissingDefaultConfig; @@ -203,7 +203,7 @@ export class ConfigSources { ); } - if (process.env.BACKSTAGE_ENVIRONMENT && fs.pathExistsSync(envPath)) { + if (process.env.BACKSTAGE_ENV && fs.pathExistsSync(envPath)) { argSources.push( FileConfigSource.create({ watch: options.watch, @@ -223,10 +223,7 @@ export class ConfigSources { ); } - if ( - process.env.BACKSTAGE_ENVIRONMENT && - fs.pathExistsSync(envLocalPath) - ) { + if (process.env.BACKSTAGE_ENV && fs.pathExistsSync(envLocalPath)) { argSources.push( FileConfigSource.create({ watch: options.watch,