Skip to content

Commit d68c99a

Browse files
authored
Merge pull request #1626 from re-vlad/feat/warn-deprecated-config-fields
feat(config): add deprecation warnings for legacy config fields (Phase 1: warnings in 2.x)
2 parents 027172e + 9876b77 commit d68c99a

3 files changed

Lines changed: 90 additions & 0 deletions

File tree

src/config/deprecatedFields.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright 2026 GitProxy Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { GitProxyConfig } from './generated/config';
18+
19+
/**
20+
* Returns deprecation warnings for legacy top-level config keys in user overrides.
21+
* PR 3.0 (#1545) will replace warnings with startup failure for legacy-only configs.
22+
*/
23+
export function getDeprecatedConfigWarnings(userSettings: Partial<GitProxyConfig>): string[] {
24+
const warnings: string[] = [];
25+
26+
if (userSettings.sslKeyPemPath?.trim() && !userSettings.tls?.key?.trim()) {
27+
warnings.push('"sslKeyPemPath" is deprecated; use "tls.key" instead (removal in GitProxy 3.0)');
28+
}
29+
30+
if (userSettings.sslCertPemPath?.trim() && !userSettings.tls?.cert?.trim()) {
31+
warnings.push(
32+
'"sslCertPemPath" is deprecated; use "tls.cert" instead (removal in GitProxy 3.0)',
33+
);
34+
}
35+
36+
if (typeof userSettings.proxyUrl === 'string' && userSettings.proxyUrl.trim() !== '') {
37+
warnings.push('"proxyUrl" is deprecated and ignored; remove it before GitProxy 3.0');
38+
}
39+
40+
return warnings;
41+
}

src/config/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { serverConfig } from './env';
2424
import { getConfigFile } from './file';
2525
import { GIGABYTE } from '../constants';
2626
import { validateConfig } from './validators';
27+
import { getDeprecatedConfigWarnings } from './deprecatedFields';
2728
import { handleErrorAndLog, handleErrorAndThrow } from '../utils/errors';
2829

2930
export { setConfigFile, getConfigFile, validate } from './file';
@@ -159,6 +160,10 @@ function loadFullConfiguration(): FullGitProxyConfig {
159160
}
160161
}
161162

163+
for (const message of getDeprecatedConfigWarnings(userSettings)) {
164+
console.warn(message);
165+
}
166+
162167
_currentConfig = mergeConfigurations(defaultConfig, userSettings);
163168

164169
if (!validateConfig(_currentConfig)) {

test/deprecatedFields.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright 2026 GitProxy Contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { describe, it, expect } from 'vitest';
18+
import { getDeprecatedConfigWarnings } from '../src/config/deprecatedFields';
19+
20+
describe('getDeprecatedConfigWarnings', () => {
21+
it('returns warnings for legacy TLS-only user config', () => {
22+
const warnings = getDeprecatedConfigWarnings({
23+
sslKeyPemPath: 'key.pem',
24+
sslCertPemPath: 'cert.pem',
25+
});
26+
27+
expect(warnings).toHaveLength(2);
28+
expect(warnings).toContain(
29+
'"sslKeyPemPath" is deprecated; use "tls.key" instead (removal in GitProxy 3.0)',
30+
);
31+
expect(warnings).toContain(
32+
'"sslCertPemPath" is deprecated; use "tls.cert" instead (removal in GitProxy 3.0)',
33+
);
34+
});
35+
36+
it('returns no warnings for non-deprecated overrides', () => {
37+
expect(getDeprecatedConfigWarnings({ uiPort: 9000 })).toEqual([]);
38+
expect(
39+
getDeprecatedConfigWarnings({
40+
tls: { enabled: true, key: 'k.pem', cert: 'c.pem' },
41+
}),
42+
).toEqual([]);
43+
});
44+
});

0 commit comments

Comments
 (0)