mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-24 17:21:03 -05:00
Use csv-parse lib to parse outputs
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
695ef9e5a5
commit
bf051e6237
7 changed files with 1350 additions and 17 deletions
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
|
@ -261,6 +261,7 @@ jobs:
|
|||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
# TODO: Remove image=moby/buildkit:buildx-stable-1 when moby/buildkit#1727 fixed
|
||||
driver-opts: |
|
||||
network=host
|
||||
image=moby/buildkit:buildx-stable-1
|
||||
|
@ -348,6 +349,7 @@ jobs:
|
|||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
# TODO: Remove image=moby/buildkit:buildx-stable-1 when moby/buildkit#1727 fixed
|
||||
driver-opts: |
|
||||
network=host
|
||||
image=moby/buildkit:buildx-stable-1
|
||||
|
@ -412,6 +414,7 @@ jobs:
|
|||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
# TODO: Remove image=moby/buildkit:buildx-stable-1 when moby/buildkit#1727 fixed
|
||||
driver-opts: |
|
||||
network=host
|
||||
image=moby/buildkit:buildx-stable-1
|
||||
|
|
|
@ -30,6 +30,66 @@ describe('getImageID', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('isLocalOrTarExporter', () => {
|
||||
// prettier-ignore
|
||||
test.each([
|
||||
[
|
||||
[
|
||||
'type=registry,ref=user/app',
|
||||
],
|
||||
false
|
||||
],
|
||||
[
|
||||
[
|
||||
'type=docker',
|
||||
],
|
||||
false
|
||||
],
|
||||
[
|
||||
[
|
||||
'type=local,dest=./release-out'
|
||||
],
|
||||
true
|
||||
],
|
||||
[
|
||||
[
|
||||
'type=tar,dest=/tmp/image.tar'
|
||||
],
|
||||
true
|
||||
],
|
||||
[
|
||||
[
|
||||
'type=docker',
|
||||
'type=tar,dest=/tmp/image.tar'
|
||||
],
|
||||
true
|
||||
],
|
||||
[
|
||||
[
|
||||
'"type=tar","dest=/tmp/image.tar"'
|
||||
],
|
||||
true
|
||||
],
|
||||
[
|
||||
[
|
||||
'" type= local" , dest=./release-out'
|
||||
],
|
||||
true
|
||||
],
|
||||
[
|
||||
[
|
||||
'.'
|
||||
],
|
||||
false
|
||||
],
|
||||
])(
|
||||
'given %p returns %p',
|
||||
async (outputs: Array<string>, expected: boolean) => {
|
||||
expect(buildx.isLocalOrTarExporter(outputs)).toEqual(expected);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('getVersion', () => {
|
||||
it('valid', async () => {
|
||||
await exec.exec('docker', ['buildx', 'version']);
|
||||
|
|
|
@ -39,10 +39,8 @@ describe('getArgs', () => {
|
|||
[
|
||||
'buildx',
|
||||
'build',
|
||||
'--iidfile',
|
||||
'/tmp/.docker-build-push-jest/iidfile',
|
||||
'--file',
|
||||
'Dockerfile',
|
||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||
'--file', 'Dockerfile',
|
||||
'https://github.com/docker/build-push-action.git#test-jest'
|
||||
]
|
||||
],
|
||||
|
@ -81,10 +79,8 @@ describe('getArgs', () => {
|
|||
[
|
||||
'buildx',
|
||||
'build',
|
||||
'--iidfile',
|
||||
'/tmp/.docker-build-push-jest/iidfile',
|
||||
'--secret',
|
||||
'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||
'--file', 'Dockerfile',
|
||||
'.'
|
||||
]
|
||||
|
@ -92,15 +88,15 @@ describe('getArgs', () => {
|
|||
[
|
||||
'0.4.2',
|
||||
new Map<string, string>([
|
||||
['github-token', 'abcdefghijklmno0123456789']
|
||||
['github-token', 'abcdefghijklmno0123456789'],
|
||||
['outputs', '.']
|
||||
]),
|
||||
[
|
||||
'buildx',
|
||||
'build',
|
||||
'--iidfile',
|
||||
'/tmp/.docker-build-push-jest/iidfile',
|
||||
'--secret',
|
||||
'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||
'--output', '.',
|
||||
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
|
||||
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
|
||||
'--file', 'Dockerfile',
|
||||
'https://github.com/docker/build-push-action.git#test-jest'
|
||||
]
|
||||
|
|
1258
dist/index.js
generated
vendored
1258
dist/index.js
generated
vendored
File diff suppressed because it is too large
Load diff
|
@ -31,10 +31,12 @@
|
|||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/github": "^4.0.0",
|
||||
"csv-parse": "^4.12.0",
|
||||
"semver": "^7.3.2",
|
||||
"tmp": "^0.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/csv-parse": "^1.2.2",
|
||||
"@types/jest": "^26.0.3",
|
||||
"@types/node": "^14.0.14",
|
||||
"@types/tmp": "^0.2.0",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import csvparse from 'csv-parse/lib/sync';
|
||||
import * as semver from 'semver';
|
||||
import * as context from './context';
|
||||
import * as exec from './exec';
|
||||
|
@ -26,8 +27,13 @@ export async function getSecret(kvp: string): Promise<string> {
|
|||
}
|
||||
|
||||
export function isLocalOrTarExporter(outputs: string[]): Boolean {
|
||||
for (let output of outputs) {
|
||||
for (let [key, value] of output.split(/\s*,\s*/).map(chunk => chunk.split('='))) {
|
||||
for (let output of csvparse(outputs.join(`\n`), {
|
||||
delimiter: ',',
|
||||
trim: true,
|
||||
columns: false,
|
||||
relax_column_count: true
|
||||
})) {
|
||||
for (let [key, value] of output.map(chunk => chunk.split('=').map(item => item.trim()))) {
|
||||
if (key == 'type' && (value == 'local' || value == 'tar')) {
|
||||
return true;
|
||||
}
|
||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -636,6 +636,13 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
|
||||
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
|
||||
|
||||
"@types/csv-parse@^1.2.2":
|
||||
version "1.2.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/csv-parse/-/csv-parse-1.2.2.tgz#713486235759d615dc8e6a6a979170ada76701d5"
|
||||
integrity sha512-k33tLtRKTQxf7hQfMlkWoS2TQYsnpk1ibZN+rzbuCkeBs8m23nHTeDTF1wb/e7/MSLdtgCzqu3oM1I101kd6yw==
|
||||
dependencies:
|
||||
csv-parse "*"
|
||||
|
||||
"@types/graceful-fs@^4.1.2":
|
||||
version "4.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.3.tgz#039af35fe26bec35003e8d86d2ee9c586354348f"
|
||||
|
@ -1229,6 +1236,11 @@ cssstyle@^2.2.0:
|
|||
dependencies:
|
||||
cssom "~0.3.6"
|
||||
|
||||
csv-parse@*, csv-parse@^4.12.0:
|
||||
version "4.12.0"
|
||||
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.12.0.tgz#fd42d6291bbaadd51d3009f6cadbb3e53b4ce026"
|
||||
integrity sha512-wPQl3H79vWLPI8cgKFcQXl0NBgYYEqVnT1i6/So7OjMpsI540oD7p93r3w6fDSyPvwkTepG05F69/7AViX2lXg==
|
||||
|
||||
dashdash@^1.12.0:
|
||||
version "1.14.1"
|
||||
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
|
||||
|
|
Loading…
Reference in a new issue