Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass undefined to global secret replace #13908

Merged
merged 3 commits into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions lib/config/secrets.spec.ts
Expand Up @@ -133,5 +133,35 @@ describe('config/secrets', () => {
});
expect(Object.keys(res)).toContain('secrets');
});
it('{} as secrets will result in an error', () => {
const config = {
secrets: { SECRET_MANAGER: 'npm' },
allowedManagers: ['{{ secrets.SECRET_MANAGER }}'],
};
expect(() => applySecretsToConfig(config, {}, false)).toThrow(
CONFIG_VALIDATION
);
});
it('undefined as secrets will result replace the secret', () => {
const config = {
secrets: { SECRET_MANAGER: 'npm' },
allowedManagers: ['{{ secrets.SECRET_MANAGER }}'],
};
const res = applySecretsToConfig(config, undefined, false);
expect(res).toStrictEqual({
secrets: { SECRET_MANAGER: 'npm' },
allowedManagers: ['npm'],
});
expect(Object.keys(res)).toContain('secrets');
});
it('null as secrets will result in an error', () => {
const config = {
secrets: { SECRET_MANAGER: 'npm' },
allowedManagers: ['{{ secrets.SECRET_MANAGER }}'],
};
expect(() => applySecretsToConfig(config, null, false)).toThrow(
CONFIG_VALIDATION
);
});
});
});
4 changes: 3 additions & 1 deletion lib/workers/repository/index.ts
Expand Up @@ -24,7 +24,9 @@ export async function renovateRepository(
canRetry = true
): Promise<ProcessResult> {
splitInit();
let config = GlobalConfig.set(applySecretsToConfig(repoConfig, {}, false));
let config = GlobalConfig.set(
applySecretsToConfig(repoConfig, undefined, false)
);
await removeDanglingContainers();
setMeta({ repository: config.repository });
logger.info({ renovateVersion: pkg.version }, 'Repository started');
Expand Down