Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/config/deprecatedFields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright 2026 GitProxy Contributors
*
* 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.
*/

import { GitProxyConfig } from './generated/config';

/**
* Returns deprecation warnings for legacy top-level config keys in user overrides.
* PR 3.0 (#1545) will replace warnings with startup failure for legacy-only configs.
*/
export function getDeprecatedConfigWarnings(userSettings: Partial<GitProxyConfig>): string[] {
const warnings: string[] = [];

if (userSettings.sslKeyPemPath?.trim() && !userSettings.tls?.key?.trim()) {
warnings.push('"sslKeyPemPath" is deprecated; use "tls.key" instead (removal in GitProxy 3.0)');
}

if (userSettings.sslCertPemPath?.trim() && !userSettings.tls?.cert?.trim()) {
warnings.push(
'"sslCertPemPath" is deprecated; use "tls.cert" instead (removal in GitProxy 3.0)',
);
}

if (typeof userSettings.proxyUrl === 'string' && userSettings.proxyUrl.trim() !== '') {
warnings.push('"proxyUrl" is deprecated and ignored; remove it before GitProxy 3.0');
}

return warnings;
}
5 changes: 5 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { serverConfig } from './env';
import { getConfigFile } from './file';
import { GIGABYTE } from '../constants';
import { validateConfig } from './validators';
import { getDeprecatedConfigWarnings } from './deprecatedFields';
import { handleErrorAndLog, handleErrorAndThrow } from '../utils/errors';

export { setConfigFile, getConfigFile, validate } from './file';
Expand Down Expand Up @@ -158,6 +159,10 @@ function loadFullConfiguration(): FullGitProxyConfig {
}
}

for (const message of getDeprecatedConfigWarnings(userSettings)) {
console.warn(message);
}

_currentConfig = mergeConfigurations(defaultConfig, userSettings);

if (!validateConfig(_currentConfig)) {
Expand Down
44 changes: 44 additions & 0 deletions test/deprecatedFields.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright 2026 GitProxy Contributors
*
* 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.
*/

import { describe, it, expect } from 'vitest';
import { getDeprecatedConfigWarnings } from '../src/config/deprecatedFields';

describe('getDeprecatedConfigWarnings', () => {
it('returns warnings for legacy TLS-only user config', () => {
const warnings = getDeprecatedConfigWarnings({
sslKeyPemPath: 'key.pem',
sslCertPemPath: 'cert.pem',
});

expect(warnings).toHaveLength(2);
expect(warnings).toContain(
'"sslKeyPemPath" is deprecated; use "tls.key" instead (removal in GitProxy 3.0)',
);
expect(warnings).toContain(
'"sslCertPemPath" is deprecated; use "tls.cert" instead (removal in GitProxy 3.0)',
);
});

it('returns no warnings for non-deprecated overrides', () => {
expect(getDeprecatedConfigWarnings({ uiPort: 9000 })).toEqual([]);
expect(
getDeprecatedConfigWarnings({
tls: { enabled: true, key: 'k.pem', cert: 'c.pem' },
}),
).toEqual([]);
});
});
Loading