diff --git a/packages/config-loader/src/sources/EnvConfigSource.ts b/packages/config-loader/src/sources/EnvConfigSource.ts index ffb615754f..988110b370 100644 --- a/packages/config-loader/src/sources/EnvConfigSource.ts +++ b/packages/config-loader/src/sources/EnvConfigSource.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { AppConfig, CONFIG_KEY_PART_PATTERN } from '@backstage/config'; +import { AppConfig } from '@backstage/config'; import { assertError } from '@backstage/errors'; import { JsonObject } from '@backstage/types'; import { AsyncConfigSourceGenerator, ConfigSource } from './types'; @@ -84,6 +84,9 @@ export class EnvConfigSource implements ConfigSource { const ENV_PREFIX = 'APP_CONFIG_'; +// Update the same pattern in config package if this is changed +const CONFIG_KEY_PART_PATTERN = /^[a-z][a-z0-9]*(?:[-_:][a-z0-9]+)*$/i; + /** * Read runtime configuration from the environment. * diff --git a/packages/config/report.api.md b/packages/config/report.api.md index 2963960973..94c4652b44 100644 --- a/packages/config/report.api.md +++ b/packages/config/report.api.md @@ -43,9 +43,6 @@ export type Config = { getOptionalStringArray(key: string): string[] | undefined; }; -// @public -export const CONFIG_KEY_PART_PATTERN: RegExp; - // @public export class ConfigReader implements Config { constructor( diff --git a/packages/config/src/constants.ts b/packages/config/src/constants.ts deleted file mode 100644 index 35a1d3652b..0000000000 --- a/packages/config/src/constants.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2025 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. - */ - -/** - * The pattern that config keys must match. - * - * @remarks - * keys must only contain the letters `a` through `z` and digits, in groups separated by - * dashes or underscores and colon. Additionally, the very first character of each such group - * must be a letter, not a digit - * - * @public - */ -export const CONFIG_KEY_PART_PATTERN = /^[a-z][a-z0-9]*(?:[-_:][a-z0-9]+)*$/i; diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index 2f3ade0189..c6254e97ba 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -29,4 +29,3 @@ export type { export { readDurationFromConfig } from './readDurationFromConfig'; export { ConfigReader } from './reader'; export type { AppConfig, Config } from './types'; -export { CONFIG_KEY_PART_PATTERN } from './constants'; diff --git a/packages/config/src/reader.ts b/packages/config/src/reader.ts index 18f010daac..8186ee8faa 100644 --- a/packages/config/src/reader.ts +++ b/packages/config/src/reader.ts @@ -17,7 +17,8 @@ import { JsonObject, JsonValue } from '@backstage/types'; import { AppConfig, Config } from './types'; -import { CONFIG_KEY_PART_PATTERN } from './constants'; +// Update the same pattern in config-loader package if this is changed +const CONFIG_KEY_PART_PATTERN = /^[a-z][a-z0-9]*(?:[-_:][a-z0-9]+)*$/i; function isObject(value: JsonValue | undefined): value is JsonObject { return typeof value === 'object' && value !== null && !Array.isArray(value);