Skip to content

Commit

Permalink
feat(warnings): add encryptedWarning text parameter (#29120)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
  • Loading branch information
4 people authored May 27, 2024
1 parent 8e6f89b commit 1965526
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,12 @@ You can choose from the following behaviors for the `dryRun` config option:

Information provided mainly in debug log level.

## encryptedWarning

Use this if you want to stop supporting `encrypted` configuration capabilities but want to warn users first to migrate.

If set to a string value, Renovate will log warnings with the `encryptedWarning` text, meaning the message will be visible to users such as on the Dependency Dashboard.

## endpoint

## executionTimeout
Expand Down
5 changes: 5 additions & 0 deletions lib/config/decrypt.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { logger } from '../../test/util';
import { decryptConfig } from './decrypt';
import { GlobalConfig } from './global';
import type { RenovateConfig } from './types';
Expand All @@ -21,7 +22,11 @@ describe('config/decrypt', () => {

it('warns if no privateKey found', async () => {
config.encrypted = { a: '1' };
GlobalConfig.set({ encryptedWarning: 'text' });

const res = await decryptConfig(config, repository);

expect(logger.logger.once.warn).toHaveBeenCalledWith('text');
expect(res.encrypted).toBeUndefined();
expect(res.a).toBeUndefined();
});
Expand Down
6 changes: 6 additions & 0 deletions lib/config/decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ export async function decryptConfig(
for (const [key, val] of Object.entries(config)) {
if (key === 'encrypted' && is.object(val)) {
logger.debug({ config: val }, 'Found encrypted config');

const encryptedWarning = GlobalConfig.get('encryptedWarning');
if (is.string(encryptedWarning)) {
logger.once.warn(encryptedWarning);
}

if (privateKey) {
for (const [eKey, eVal] of Object.entries(val)) {
logger.debug('Trying to decrypt ' + eKey);
Expand Down
1 change: 1 addition & 0 deletions lib/config/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class GlobalConfig {
'dockerSidecarImage',
'dockerUser',
'dryRun',
'encryptedWarning',
'exposeAllEnv',
'executionTimeout',
'githubTokenWarn',
Expand Down
9 changes: 8 additions & 1 deletion lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,17 @@ const options: RenovateOptions[] = [
default: true,
globalOnly: true,
},
{
name: 'encryptedWarning',
description: 'Warning text to use if encrypted config is found.',
type: 'string',
globalOnly: true,
advancedUse: true,
},
{
name: 'inheritConfig',
description:
'If `true`, Renovate will inherit configuration from the `inheritConfigFileName` file in `inheritConfigRepoName',
'If `true`, Renovate will inherit configuration from the `inheritConfigFileName` file in `inheritConfigRepoName`.',
type: 'boolean',
default: false,
globalOnly: true,
Expand Down
1 change: 1 addition & 0 deletions lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export interface RepoGlobalConfig {
dockerSidecarImage?: string;
dockerUser?: string;
dryRun?: DryRunConfig;
encryptedWarning?: string;
endpoint?: string;
executionTimeout?: number;
exposeAllEnv?: boolean;
Expand Down

0 comments on commit 1965526

Please sign in to comment.