Regression via 33c27a1
Given a user proxy.config.json, values specified in this file are not set by the configuration loading steps. This is related to the use of a module variable, which is initialized when the src/config module is imported but is then is not set in time for configuration to be loaded into the app. See minimal repro below:
$ git clone https://github.com/finos/git-proxy && cd git-proxy
Cloning into 'git-proxy'...
remote: Enumerating objects: 14377, done.
remote: Counting objects: 100% (254/254), done.
remote: Compressing objects: 100% (135/135), done.
remote: Total 14377 (delta 204), reused 120 (delta 119), pack-reused 14123 (from 3)
Receiving objects: 100% (14377/14377), 15.82 MiB | 4.03 MiB/s, done.
Resolving deltas: 100% (8680/8680), done.
$ npm install @finos/git-proxy-plugin-samples
added 1 package, and changed 1 package in 9s
$ jq -n '{plugins:["finos/git-proxy-plugin-samples"]}' > user.config.json
$ npm run server -- --config user.config.json
> @finos/git-proxy@1.19.1 server
> tsx index.ts --config user.config.json
Configuration sources are disabled
No plugins configured
Found 0 plugin modules <--- No plugins loaded
Service Listening on 8080
HTTP Proxy Listening on 8000
$ npm run server -- --config user.config.json -v
> @finos/git-proxy@1.19.1 server
> tsx index.ts --config user.config.json -v
Configuration sources are disabled
user.config.json is valid
Wrapping the setting of _userSettings in a function + calling that during app startup should restore the prior behaviour.
diff --git a/index.ts b/index.ts
index 880ccfe..767f887 100755
--- a/index.ts
+++ b/index.ts
@@ -4,6 +4,7 @@ import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import * as fs from 'fs';
import { configFile, setConfigFile, validate } from './src/config/file';
+import { initUserConfig } from './src/config';
import proxy from './src/proxy';
import service from './src/service';
@@ -29,6 +30,7 @@ const argv = yargs(hideBin(process.argv))
.parseSync();
setConfigFile(argv.c as string || "");
+initUserConfig();
if (argv.v) {
if (!fs.existsSync(configFile)) {
diff --git a/src/config/index.ts b/src/config/index.ts
index a13cfef..2d6406d 100644
--- a/src/config/index.ts
+++ b/src/config/index.ts
@@ -14,9 +14,15 @@ import {
} from './types';
let _userSettings: UserSettings | null = null;
-if (existsSync(configFile)) {
- _userSettings = JSON.parse(readFileSync(configFile, 'utf-8'));
-}
+console.log(`_userSettings during import: ${_userSettings}`); // for debugging only
+
+export const initUserConfig = () => {
+ console.log(`Initializing user configuration from ${configFile}`); // for debugging only
+ if (existsSync(configFile)) {
+ _userSettings = JSON.parse(readFileSync(configFile, 'utf-8'));
+ }
+};
+
let _authorisedList: AuthorisedRepo[] = defaultSettings.authorisedList;
let _database: Database[] = defaultSettings.sink;
let _authentication: Authentication[] = defaultSettings.authentication;
$ npm run server -- --config user.config.json
> @finos/git-proxy@1.19.1 server
> tsx index.ts --config user.config.json
_userSettings during import: null
Configuration sources are disabled
Initializing user configuration from user.config.json
Service Listening on 8080
Configuration sources are disabled
Found 1 plugin modules
found pull plugin RunOnPullPlugin
Loaded plugin: RunOnPullPlugin
HTTP Proxy Listening on 8000
FYI @jescalada
Regression via 33c27a1
Given a user
proxy.config.json, values specified in this file are not set by the configuration loading steps. This is related to the use of a module variable, which is initialized when thesrc/configmodule is imported but is then is not set in time for configuration to be loaded into the app. See minimal repro below:Wrapping the setting of
_userSettingsin a function + calling that during app startup should restore the prior behaviour.FYI @jescalada