preserve trailing whitespace in secrets input

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2026-05-22 17:41:46 +02:00
parent f9f3042f7e
commit 2d1196fa34
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
2 changed files with 20 additions and 1 deletions

View File

@ -95,6 +95,25 @@ describe('getInputs', () => {
expect(gitContextSpy).toHaveBeenCalledTimes(1); expect(gitContextSpy).toHaveBeenCalledTimes(1);
gitContextSpy.mockRestore(); gitContextSpy.mockRestore();
}); });
test('requests untrimmed secrets input explicitly', async () => {
const gitContext = 'https://github.com/docker/build-push-action.git#refs/heads/master';
const gitContextSpy = vi.spyOn(Build.prototype, 'gitContext').mockResolvedValue(gitContext);
const getInputList = vi.fn().mockReturnValue([]);
vi.resetModules();
vi.doMock('@docker/actions-toolkit/lib/util.js', () => ({
Util: {
getInputList
}
}));
setRequiredBooleanInputs();
setInput('secrets', `"PRIVATE_SSH_KEY=test\n\n"`);
const context = await import('../src/context.js');
await context.getInputs();
expect(getInputList).toHaveBeenCalledWith('secrets', {ignoreComma: true, trimWhitespace: false});
vi.doUnmock('@docker/actions-toolkit/lib/util.js');
gitContextSpy.mockRestore();
});
}); });
describe('getArgs', () => { describe('getArgs', () => {

View File

@ -76,7 +76,7 @@ export async function getInputs(): Promise<Inputs> {
pull: core.getBooleanInput('pull'), pull: core.getBooleanInput('pull'),
push: core.getBooleanInput('push'), push: core.getBooleanInput('push'),
sbom: core.getInput('sbom'), sbom: core.getInput('sbom'),
secrets: Util.getInputList('secrets', {ignoreComma: true}), secrets: Util.getInputList('secrets', {ignoreComma: true, trimWhitespace: false}),
'secret-envs': Util.getInputList('secret-envs'), 'secret-envs': Util.getInputList('secret-envs'),
'secret-files': Util.getInputList('secret-files', {ignoreComma: true}), 'secret-files': Util.getInputList('secret-files', {ignoreComma: true}),
'shm-size': core.getInput('shm-size'), 'shm-size': core.getInput('shm-size'),