mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-22 18:15:40 +01:00
Ignore comma sep for CSV inputs type
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
c124ff0226
commit
8954ded19b
18
README.md
18
README.md
@ -324,11 +324,11 @@ Following inputs can be used as `step.with` keys
|
|||||||
| `platforms` | List | List of [target platforms](https://github.com/docker/buildx#---platformvaluevalue) for build |
|
| `platforms` | List | List of [target platforms](https://github.com/docker/buildx#---platformvaluevalue) for build |
|
||||||
| `load` | Bool | [Load](https://github.com/docker/buildx#--load) is a shorthand for `--output=type=docker` (default `false`) |
|
| `load` | Bool | [Load](https://github.com/docker/buildx#--load) is a shorthand for `--output=type=docker` (default `false`) |
|
||||||
| `push` | Bool | [Push](https://github.com/docker/buildx#--push) is a shorthand for `--output=type=registry` (default `false`) |
|
| `push` | Bool | [Push](https://github.com/docker/buildx#--push) is a shorthand for `--output=type=registry` (default `false`) |
|
||||||
| `outputs` | List | List of [output destinations](https://github.com/docker/buildx#-o---outputpath-typetypekeyvalue) (format: `type=local,dest=path`) |
|
| `outputs` | CSV | List of [output destinations](https://github.com/docker/buildx#-o---outputpath-typetypekeyvalue) (format: `type=local,dest=path`) |
|
||||||
| `cache-from` | List | List of [external cache sources](https://github.com/docker/buildx#--cache-fromnametypetypekeyvalue) (eg. `user/app:cache`, `type=local,src=path/to/dir`) |
|
| `cache-from` | CSV | List of [external cache sources](https://github.com/docker/buildx#--cache-fromnametypetypekeyvalue) (eg. `user/app:cache`, `type=local,src=path/to/dir`) |
|
||||||
| `cache-to` | List | List of [cache export destinations](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) (eg. `user/app:cache`, `type=local,dest=path/to/dir`) |
|
| `cache-to` | CSV | List of [cache export destinations](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) (eg. `user/app:cache`, `type=local,dest=path/to/dir`) |
|
||||||
|
|
||||||
> List type can be a comma or newline-delimited string
|
> `List` type can be a comma or newline-delimited string
|
||||||
> ```yaml
|
> ```yaml
|
||||||
> tags: name/app:latest,name/app:1.0.0
|
> tags: name/app:latest,name/app:1.0.0
|
||||||
> ```
|
> ```
|
||||||
@ -338,6 +338,16 @@ Following inputs can be used as `step.with` keys
|
|||||||
> name/app:1.0.0
|
> name/app:1.0.0
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
|
> `CSV` type must be a newline-delimited string
|
||||||
|
> ```yaml
|
||||||
|
> cache-from: user/app:cache
|
||||||
|
> ```
|
||||||
|
> ```yaml
|
||||||
|
> cache-from: |
|
||||||
|
> user/app:cache
|
||||||
|
> type=local,src=path/to/dir
|
||||||
|
> ```
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
Following outputs are available
|
Following outputs are available
|
||||||
|
@ -35,6 +35,20 @@ describe('getInputList', () => {
|
|||||||
console.log(res);
|
console.log(res);
|
||||||
expect(res).toEqual(['bar', 'baz', 'bat']);
|
expect(res).toEqual(['bar', 'baz', 'bat']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handles multiple lines 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);
|
||||||
|
console.log(res);
|
||||||
|
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles 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);
|
||||||
|
console.log(res);
|
||||||
|
expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('asyncForEach', () => {
|
describe('asyncForEach', () => {
|
||||||
|
12
dist/index.js
generated
vendored
12
dist/index.js
generated
vendored
@ -3566,9 +3566,9 @@ function getInputs() {
|
|||||||
platforms: yield getInputList('platforms'),
|
platforms: yield getInputList('platforms'),
|
||||||
load: /true/i.test(core.getInput('load')),
|
load: /true/i.test(core.getInput('load')),
|
||||||
push: /true/i.test(core.getInput('push')),
|
push: /true/i.test(core.getInput('push')),
|
||||||
outputs: yield getInputList('outputs'),
|
outputs: yield getInputList('outputs', true),
|
||||||
cacheFrom: yield getInputList('cache-from'),
|
cacheFrom: yield getInputList('cache-from', true),
|
||||||
cacheTo: yield getInputList('cache-to')
|
cacheTo: yield getInputList('cache-to', true)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3640,13 +3640,15 @@ function getCommonArgs(inputs) {
|
|||||||
return args;
|
return args;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getInputList(name) {
|
function getInputList(name, ignoreComma) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const items = core.getInput(name);
|
const items = core.getInput(name);
|
||||||
if (items == '') {
|
if (items == '') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return items.split(/\r?\n/).reduce((acc, line) => acc.concat(line.split(',')).map(pat => pat.trim()), []);
|
return items
|
||||||
|
.split(/\r?\n/)
|
||||||
|
.reduce((acc, line) => acc.concat(!ignoreComma ? line.split(',') : line).map(pat => pat.trim()), []);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getInputList = getInputList;
|
exports.getInputList = getInputList;
|
||||||
|
@ -41,9 +41,9 @@ export async function getInputs(): Promise<Inputs> {
|
|||||||
platforms: await getInputList('platforms'),
|
platforms: await getInputList('platforms'),
|
||||||
load: /true/i.test(core.getInput('load')),
|
load: /true/i.test(core.getInput('load')),
|
||||||
push: /true/i.test(core.getInput('push')),
|
push: /true/i.test(core.getInput('push')),
|
||||||
outputs: await getInputList('outputs'),
|
outputs: await getInputList('outputs', true),
|
||||||
cacheFrom: await getInputList('cache-from'),
|
cacheFrom: await getInputList('cache-from', true),
|
||||||
cacheTo: await getInputList('cache-to')
|
cacheTo: await getInputList('cache-to', true)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,12 +110,14 @@ async function getCommonArgs(inputs: Inputs): Promise<Array<string>> {
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getInputList(name: string): Promise<string[]> {
|
export async function getInputList(name: string, ignoreComma?: boolean): Promise<string[]> {
|
||||||
const items = core.getInput(name);
|
const items = core.getInput(name);
|
||||||
if (items == '') {
|
if (items == '') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return items.split(/\r?\n/).reduce<string[]>((acc, line) => acc.concat(line.split(',')).map(pat => pat.trim()), []);
|
return items
|
||||||
|
.split(/\r?\n/)
|
||||||
|
.reduce<string[]>((acc, line) => acc.concat(!ignoreComma ? line.split(',') : line).map(pat => pat.trim()), []);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const asyncForEach = async (array, callback) => {
|
export const asyncForEach = async (array, callback) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user