diff --git a/__tests__/context.test.ts b/__tests__/context.test.ts index d9abe5d..b4cc036 100644 --- a/__tests__/context.test.ts +++ b/__tests__/context.test.ts @@ -79,6 +79,67 @@ describe('getInputs', () => { tags: [], } ], + [ + 3, + new Map([ + ['labels', 'mylabel=foo#bar\n#comment\nanother=bar'], + ]), + { + context: context.ContextSource.workflow, + bakeTarget: 'docker-metadata-action', + flavor: [], + githubToken: '', + images: [], + labels: ['mylabel=foo#bar', 'another=bar'], + annotations: [], + sepLabels: '\n', + sepTags: '\n', + sepAnnotations: '\n', + tags: [], + } + ], + [ + 4, + new Map([ + ['annotations', 'org.opencontainers.image.url=https://example.com/path#readme\n#comment\norg.opencontainers.image.source=https://github.com/docker/metadata-action'], + ]), + { + context: context.ContextSource.workflow, + bakeTarget: 'docker-metadata-action', + flavor: [], + githubToken: '', + images: [], + labels: [], + annotations: [ + 'org.opencontainers.image.url=https://example.com/path#readme', + 'org.opencontainers.image.source=https://github.com/docker/metadata-action' + ], + sepLabels: '\n', + sepTags: '\n', + sepAnnotations: '\n', + tags: [], + } + ], + [ + 5, + new Map([ + ['tags', 'type=raw,value=foo#bar\n#comment'], + ['flavor', 'prefix=v#1\n#comment'], + ]), + { + context: context.ContextSource.workflow, + bakeTarget: 'docker-metadata-action', + flavor: ['prefix=v#1'], + githubToken: '', + images: [], + labels: [], + annotations: [], + sepLabels: '\n', + sepTags: '\n', + sepAnnotations: '\n', + tags: ['type=raw,value=foo#bar'], + } + ], ]; test.each(cases)('[%d] given %o as inputs, returns %o', async (num: number, inputs: Map, expected: context.Inputs) => { inputs.forEach((value: string, name: string) => { diff --git a/src/context.ts b/src/context.ts index e5bd733..029db2e 100644 --- a/src/context.ts +++ b/src/context.ts @@ -28,11 +28,11 @@ export interface Inputs { export function getInputs(): Inputs { return { context: (core.getInput('context') || ContextSource.workflow) as ContextSource, - images: Util.getInputList('images', {ignoreComma: true, comment: '#'}), - tags: Util.getInputList('tags', {ignoreComma: true, comment: '#'}), - flavor: Util.getInputList('flavor', {ignoreComma: true, comment: '#'}), - labels: Util.getInputList('labels', {ignoreComma: true, comment: '#'}), - annotations: Util.getInputList('annotations', {ignoreComma: true, comment: '#'}), + images: Util.getInputList('images', {ignoreComma: true, comment: '#', commentNoInfix: true}), + tags: Util.getInputList('tags', {ignoreComma: true, comment: '#', commentNoInfix: true}), + flavor: Util.getInputList('flavor', {ignoreComma: true, comment: '#', commentNoInfix: true}), + labels: Util.getInputList('labels', {ignoreComma: true, comment: '#', commentNoInfix: true}), + annotations: Util.getInputList('annotations', {ignoreComma: true, comment: '#', commentNoInfix: true}), sepTags: core.getInput('sep-tags', {trimWhitespace: false}) || `\n`, sepLabels: core.getInput('sep-labels', {trimWhitespace: false}) || `\n`, sepAnnotations: core.getInput('sep-annotations', {trimWhitespace: false}) || `\n`,