Skip to content

Commit 68ce0ed

Browse files
fix(config/inherited): apply secrets (#33779)
1 parent e08de87 commit 68ce0ed

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/workers/repository/init/inherited.spec.ts

+25
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('workers/repository/init/inherited', () => {
2525
inheritConfigFileName: 'config.json',
2626
inheritConfigStrict: false,
2727
};
28+
hostRules.clear();
2829
});
2930

3031
it('should return the same config if repository or inheritConfig is not defined', async () => {
@@ -112,6 +113,30 @@ describe('workers/repository/init/inherited', () => {
112113
expect(res.hostRules).toBeUndefined();
113114
});
114115

116+
it('should apply secrets to inherited config', async () => {
117+
platform.getRawFile.mockResolvedValue(
118+
`{
119+
"hostRules": [
120+
{
121+
"matchHost": "some-host-url",
122+
"token": "{{ secrets.SECRET_TOKEN }}"
123+
}
124+
]
125+
}`,
126+
);
127+
const res = await mergeInheritedConfig({
128+
...config,
129+
secrets: { SECRET_TOKEN: 'some-secret-token' },
130+
});
131+
expect(hostRules.getAll()).toMatchObject([
132+
{
133+
matchHost: 'some-host-url',
134+
token: 'some-secret-token',
135+
},
136+
]);
137+
expect(res.hostRules).toBeUndefined();
138+
});
139+
115140
it('should resolve presets found in inherited config', async () => {
116141
platform.getRawFile.mockResolvedValue(
117142
'{"onboarding":false,"labels":["test"],"extends":[":automergeAll"]}',

lib/workers/repository/init/inherited.ts

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { dequal } from 'dequal';
33
import { mergeChildConfig, removeGlobalConfig } from '../../../config';
44
import { parseFileConfig } from '../../../config/parse';
55
import { resolveConfigPresets } from '../../../config/presets';
6+
import { applySecretsToConfig } from '../../../config/secrets';
67
import type { RenovateConfig } from '../../../config/types';
78
import { validateConfig } from '../../../config/validation';
89
import {
@@ -105,6 +106,7 @@ export async function mergeInheritedConfig(
105106
}
106107

107108
if (is.nullOrUndefined(filteredConfig.extends)) {
109+
filteredConfig = applySecretsToConfig(filteredConfig, config.secrets ?? {});
108110
setInheritedHostRules(filteredConfig);
109111
return mergeChildConfig(config, filteredConfig);
110112
}
@@ -141,6 +143,7 @@ export async function mergeInheritedConfig(
141143
);
142144
}
143145

146+
filteredConfig = applySecretsToConfig(filteredConfig, config.secrets ?? {});
144147
setInheritedHostRules(filteredConfig);
145148
return mergeChildConfig(config, filteredConfig);
146149
}

0 commit comments

Comments
 (0)