import type { RenovateConfig, RepoGlobalConfig } from './types'; export class GlobalConfig { // TODO: once global config work is complete, add a test to make sure this list includes all options with globalOnly=true (#9603) private static readonly OPTIONS: (keyof RepoGlobalConfig)[] = [ 'allowCustomCrateRegistries', 'allowedPostUpgradeCommands', 'allowPlugins', 'allowPostUpgradeCommandTemplating', 'allowScripts', 'binarySource', 'cacheDir', 'cacheHardTtlMinutes', 'cacheTtlOverride', 'containerbaseDir', 'customEnvVariables', 'dockerChildPrefix', 'dockerCliOptions', 'dockerSidecarImage', 'dockerUser', 'dryRun', 'exposeAllEnv', 'executionTimeout', 'githubTokenWarn', 'localDir', 'migratePresets', 'presetCachePersistence', 'privateKey', 'privateKeyOld', 'gitTimeout', 'platform', 'endpoint', ]; private static config: RepoGlobalConfig = {}; static get(): RepoGlobalConfig; static get( key: Key, ): RepoGlobalConfig[Key]; static get( key: Key, defaultValue: Required[Key], ): Required[Key]; static get( key?: Key, defaultValue?: RepoGlobalConfig[Key], ): RepoGlobalConfig | RepoGlobalConfig[Key] { return key ? GlobalConfig.config[key] ?? defaultValue : GlobalConfig.config; } static set(config: RenovateConfig | RepoGlobalConfig): RenovateConfig { GlobalConfig.reset(); const result = { ...config }; for (const option of GlobalConfig.OPTIONS) { GlobalConfig.config[option] = config[option] as never; delete result[option]; } return result; } static reset(): void { GlobalConfig.config = {}; } }