mirror of
https://github.com/docker/metadata-action.git
synced 2024-12-22 18:37:42 +01:00
Merge pull request #172 from crazy-max/comments
handle comments for multi-line inputs
This commit is contained in:
commit
47c365107c
@ -359,7 +359,7 @@ tags: |
|
||||
|
||||
Will be used on [schedule event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule).
|
||||
|
||||
`pattern` is a specially crafted attribute to support [Handlebars template](https://handlebarsjs.com/guide/) with
|
||||
`pattern` is a specially crafted attribute to support [Handlebars' template](https://handlebarsjs.com/guide/) with
|
||||
the following expressions:
|
||||
* `date 'format'` ; render date by its [moment format](https://momentjs.com/docs/#/displaying/format/)
|
||||
|
||||
@ -478,7 +478,7 @@ tags: |
|
||||
```
|
||||
|
||||
Can create a regular expression for matching Git tag with a pattern and capturing group. Will be used on a
|
||||
[push tag event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push) but you can also use
|
||||
[push tag event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push) but, you can also use
|
||||
a custom value through `value` attribute.
|
||||
|
||||
| Git tag | Pattern | Group | Output |
|
||||
@ -615,7 +615,7 @@ tags: |
|
||||
|
||||
### Global expressions
|
||||
|
||||
The following [Handlebars template](https://handlebarsjs.com/guide/) expressions for `prefix`, `suffix` and `value`
|
||||
The following [Handlebars' template](https://handlebarsjs.com/guide/) expressions for `prefix`, `suffix` and `value`
|
||||
attributes are available:
|
||||
|
||||
| Expression | Output |
|
||||
@ -679,7 +679,7 @@ workflow using the [`fromJSON` function](https://docs.github.com/en/actions/lear
|
||||
|
||||
### Overwrite labels
|
||||
|
||||
If some of the [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md)
|
||||
If some [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md)
|
||||
labels generated are not suitable, you can overwrite them like this:
|
||||
|
||||
```yaml
|
||||
|
@ -15,55 +15,61 @@ jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
||||
describe('getInputList', () => {
|
||||
it('single line correctly', async () => {
|
||||
await setInput('foo', 'bar');
|
||||
const res = await context.getInputList('foo');
|
||||
const res = context.getInputList('foo');
|
||||
expect(res).toEqual(['bar']);
|
||||
});
|
||||
|
||||
it('multiline correctly', async () => {
|
||||
setInput('foo', 'bar\nbaz');
|
||||
const res = await context.getInputList('foo');
|
||||
const res = context.getInputList('foo');
|
||||
expect(res).toEqual(['bar', 'baz']);
|
||||
});
|
||||
|
||||
it('empty lines correctly', async () => {
|
||||
setInput('foo', 'bar\n\nbaz');
|
||||
const res = await context.getInputList('foo');
|
||||
const res = context.getInputList('foo');
|
||||
expect(res).toEqual(['bar', 'baz']);
|
||||
});
|
||||
|
||||
it('comment correctly', async () => {
|
||||
setInput('foo', 'bar\n#com\n"#taken"\nhello#comment\nbaz');
|
||||
const res = context.getInputList('foo');
|
||||
expect(res).toEqual(['bar', '#taken', 'hello', 'baz']);
|
||||
});
|
||||
|
||||
it('comma correctly', async () => {
|
||||
setInput('foo', 'bar,baz');
|
||||
const res = await context.getInputList('foo');
|
||||
const res = context.getInputList('foo');
|
||||
expect(res).toEqual(['bar', 'baz']);
|
||||
});
|
||||
|
||||
it('empty result correctly', async () => {
|
||||
setInput('foo', 'bar,baz,');
|
||||
const res = await context.getInputList('foo');
|
||||
const res = context.getInputList('foo');
|
||||
expect(res).toEqual(['bar', 'baz']);
|
||||
});
|
||||
|
||||
it('different new lines correctly', async () => {
|
||||
setInput('foo', 'bar\r\nbaz');
|
||||
const res = await context.getInputList('foo');
|
||||
const res = context.getInputList('foo');
|
||||
expect(res).toEqual(['bar', 'baz']);
|
||||
});
|
||||
|
||||
it('different new lines and comma correctly', async () => {
|
||||
setInput('foo', 'bar\r\nbaz,bat');
|
||||
const res = await context.getInputList('foo');
|
||||
const res = context.getInputList('foo');
|
||||
expect(res).toEqual(['bar', 'baz', 'bat']);
|
||||
});
|
||||
|
||||
it('multiline and ignoring comma correctly', async () => {
|
||||
setInput('cache-from', 'user/app:cache\ntype=local,src=path/to/dir');
|
||||
const res = await context.getInputList('cache-from', true);
|
||||
const res = context.getInputList('cache-from', true);
|
||||
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
||||
});
|
||||
|
||||
it('different new lines and ignoring comma correctly', async () => {
|
||||
setInput('cache-from', 'user/app:cache\r\ntype=local,src=path/to/dir');
|
||||
const res = await context.getInputList('cache-from', true);
|
||||
const res = context.getInputList('cache-from', true);
|
||||
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
||||
});
|
||||
|
||||
@ -76,7 +82,7 @@ bbbbbbb
|
||||
ccccccccc"
|
||||
FOO=bar`
|
||||
);
|
||||
const res = await context.getInputList('secrets', true);
|
||||
const res = context.getInputList('secrets', true);
|
||||
expect(res).toEqual([
|
||||
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
||||
`MYSECRET=aaaaaaaa
|
||||
@ -99,7 +105,7 @@ FOO=bar
|
||||
bbbb
|
||||
ccc"`
|
||||
);
|
||||
const res = await context.getInputList('secrets', true);
|
||||
const res = context.getInputList('secrets', true);
|
||||
expect(res).toEqual([
|
||||
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
||||
`MYSECRET=aaaaaaaa
|
||||
@ -122,7 +128,7 @@ bbbbbbb
|
||||
ccccccccc
|
||||
FOO=bar`
|
||||
);
|
||||
const res = await context.getInputList('secrets', true);
|
||||
const res = context.getInputList('secrets', true);
|
||||
expect(res).toEqual(['GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', 'MYSECRET=aaaaaaaa', 'bbbbbbb', 'ccccccccc', 'FOO=bar']);
|
||||
});
|
||||
|
||||
@ -135,7 +141,7 @@ bbbb""bbb
|
||||
ccccccccc"
|
||||
FOO=bar`
|
||||
);
|
||||
const res = await context.getInputList('secrets', true);
|
||||
const res = context.getInputList('secrets', true);
|
||||
expect(res).toEqual([
|
||||
'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789',
|
||||
`MYSECRET=aaaaaaaa
|
||||
|
1
dist/index.js
generated
vendored
1
dist/index.js
generated
vendored
@ -75,6 +75,7 @@ function getInputList(name, ignoreComma) {
|
||||
for (let output of sync_1.default(items, {
|
||||
columns: false,
|
||||
relax: true,
|
||||
comment: '#',
|
||||
relaxColumnCount: true,
|
||||
skipLinesWithEmptyValues: true
|
||||
})) {
|
||||
|
@ -49,6 +49,7 @@ export function getInputList(name: string, ignoreComma?: boolean): string[] {
|
||||
for (let output of csvparse(items, {
|
||||
columns: false,
|
||||
relax: true,
|
||||
comment: '#',
|
||||
relaxColumnCount: true,
|
||||
skipLinesWithEmptyValues: true
|
||||
}) as Array<string[]>) {
|
||||
|
Loading…
Reference in New Issue
Block a user