Skip to content

Commit 030e881

Browse files
authored
Merge pull request #607 from crazy-max/allow-comments
preserve comments in list input values with commentNoInfix
2 parents 7b19fec + 4b529ac commit 030e881

File tree

4 files changed

+68
-7
lines changed

4 files changed

+68
-7
lines changed

__tests__/context.test.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,67 @@ describe('getInputs', () => {
7979
tags: [],
8080
}
8181
],
82+
[
83+
3,
84+
new Map<string, string>([
85+
['labels', 'mylabel=foo#bar\n#comment\nanother=bar'],
86+
]),
87+
{
88+
context: context.ContextSource.workflow,
89+
bakeTarget: 'docker-metadata-action',
90+
flavor: [],
91+
githubToken: '',
92+
images: [],
93+
labels: ['mylabel=foo#bar', 'another=bar'],
94+
annotations: [],
95+
sepLabels: '\n',
96+
sepTags: '\n',
97+
sepAnnotations: '\n',
98+
tags: [],
99+
}
100+
],
101+
[
102+
4,
103+
new Map<string, string>([
104+
['annotations', 'org.opencontainers.image.url=https://example.com/path#readme\n#comment\norg.opencontainers.image.source=https://github.com/docker/metadata-action'],
105+
]),
106+
{
107+
context: context.ContextSource.workflow,
108+
bakeTarget: 'docker-metadata-action',
109+
flavor: [],
110+
githubToken: '',
111+
images: [],
112+
labels: [],
113+
annotations: [
114+
'org.opencontainers.image.url=https://example.com/path#readme',
115+
'org.opencontainers.image.source=https://github.com/docker/metadata-action'
116+
],
117+
sepLabels: '\n',
118+
sepTags: '\n',
119+
sepAnnotations: '\n',
120+
tags: [],
121+
}
122+
],
123+
[
124+
5,
125+
new Map<string, string>([
126+
['tags', 'type=raw,value=foo#bar\n#comment'],
127+
['flavor', 'prefix=v#1\n#comment'],
128+
]),
129+
{
130+
context: context.ContextSource.workflow,
131+
bakeTarget: 'docker-metadata-action',
132+
flavor: ['prefix=v#1'],
133+
githubToken: '',
134+
images: [],
135+
labels: [],
136+
annotations: [],
137+
sepLabels: '\n',
138+
sepTags: '\n',
139+
sepAnnotations: '\n',
140+
tags: ['type=raw,value=foo#bar'],
141+
}
142+
],
82143
];
83144
test.each(cases)('[%d] given %o as inputs, returns %o', async (num: number, inputs: Map<string, string>, expected: context.Inputs) => {
84145
inputs.forEach((value: string, name: string) => {

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export interface Inputs {
2828
export function getInputs(): Inputs {
2929
return {
3030
context: (core.getInput('context') || ContextSource.workflow) as ContextSource,
31-
images: Util.getInputList('images', {ignoreComma: true, comment: '#'}),
32-
tags: Util.getInputList('tags', {ignoreComma: true, comment: '#'}),
33-
flavor: Util.getInputList('flavor', {ignoreComma: true, comment: '#'}),
34-
labels: Util.getInputList('labels', {ignoreComma: true, comment: '#'}),
35-
annotations: Util.getInputList('annotations', {ignoreComma: true, comment: '#'}),
31+
images: Util.getInputList('images', {ignoreComma: true, comment: '#', commentNoInfix: true}),
32+
tags: Util.getInputList('tags', {ignoreComma: true, comment: '#', commentNoInfix: true}),
33+
flavor: Util.getInputList('flavor', {ignoreComma: true, comment: '#', commentNoInfix: true}),
34+
labels: Util.getInputList('labels', {ignoreComma: true, comment: '#', commentNoInfix: true}),
35+
annotations: Util.getInputList('annotations', {ignoreComma: true, comment: '#', commentNoInfix: true}),
3636
sepTags: core.getInput('sep-tags', {trimWhitespace: false}) || `\n`,
3737
sepLabels: core.getInput('sep-labels', {trimWhitespace: false}) || `\n`,
3838
sepAnnotations: core.getInput('sep-annotations', {trimWhitespace: false}) || `\n`,

0 commit comments

Comments
 (0)