mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
builder: update inspect command parsing
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
a98aa046a8
commit
225d61b701
@ -393,7 +393,65 @@ describe('parseInspect', () => {
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
],
|
||||
[
|
||||
'inspect11.txt',
|
||||
{
|
||||
"name": "builder",
|
||||
"driver": "docker-container",
|
||||
"lastActivity": new Date("2024-03-01T14:25:03.000Z"),
|
||||
"nodes": [
|
||||
{
|
||||
"buildkit": "37657a1",
|
||||
"buildkitd-flags": "--debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host --allow-insecure-entitlement=network.host",
|
||||
"driver-opts": [
|
||||
"env.JAEGER_TRACE=localhost:6831",
|
||||
"image=moby/buildkit:master",
|
||||
"network=host",
|
||||
"env.BUILDKIT_STEP_LOG_MAX_SIZE=10485760",
|
||||
"env.BUILDKIT_STEP_LOG_MAX_SPEED=10485760",
|
||||
],
|
||||
"endpoint": "unix:///var/run/docker.sock",
|
||||
"name": "builder0",
|
||||
"platforms": "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6",
|
||||
"status": "running",
|
||||
"labels": {
|
||||
"org.mobyproject.buildkit.worker.executor": "oci",
|
||||
"org.mobyproject.buildkit.worker.hostname": "docker-desktop",
|
||||
"org.mobyproject.buildkit.worker.network": "host",
|
||||
"org.mobyproject.buildkit.worker.oci.process-mode": "sandbox",
|
||||
"org.mobyproject.buildkit.worker.selinux.enabled": "false",
|
||||
"org.mobyproject.buildkit.worker.snapshotter": "overlayfs",
|
||||
},
|
||||
"gcPolicy": [
|
||||
{
|
||||
"all": false,
|
||||
"filter": [
|
||||
"type==source.local",
|
||||
"type==exec.cachemount",
|
||||
"type==source.git.checkout"
|
||||
],
|
||||
"keepDuration": "48h0m0s",
|
||||
"keepBytes": "488.3MiB",
|
||||
},
|
||||
{
|
||||
"all": false,
|
||||
"keepDuration": "1440h0m0s",
|
||||
"keepBytes": "94.06GiB",
|
||||
},
|
||||
{
|
||||
"all": false,
|
||||
"keepBytes": "94.06GiB",
|
||||
},
|
||||
{
|
||||
"all": true,
|
||||
"keepBytes": "94.06GiB",
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
])('given %p', async (inspectFile, expected) => {
|
||||
expect(await Builder.parseInspect(fs.readFileSync(path.join(fixturesDir, inspectFile)).toString())).toEqual(expected);
|
||||
});
|
||||
|
34
__tests__/fixtures/inspect11.txt
Normal file
34
__tests__/fixtures/inspect11.txt
Normal file
@ -0,0 +1,34 @@
|
||||
Name: builder
|
||||
Driver: docker-container
|
||||
Last Activity: 2024-03-01 14:25:03 +0000 UTC
|
||||
|
||||
Nodes:
|
||||
Name: builder0
|
||||
Endpoint: unix:///var/run/docker.sock
|
||||
Driver Options: env.JAEGER_TRACE="localhost:6831" image="moby/buildkit:master" network="host" env.BUILDKIT_STEP_LOG_MAX_SIZE="10485760" env.BUILDKIT_STEP_LOG_MAX_SPEED="10485760"
|
||||
Status: running
|
||||
BuildKit daemon flags: --debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host --allow-insecure-entitlement=network.host
|
||||
BuildKit version: 37657a1
|
||||
Platforms: linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6
|
||||
Labels:
|
||||
org.mobyproject.buildkit.worker.executor: oci
|
||||
org.mobyproject.buildkit.worker.hostname: docker-desktop
|
||||
org.mobyproject.buildkit.worker.network: host
|
||||
org.mobyproject.buildkit.worker.oci.process-mode: sandbox
|
||||
org.mobyproject.buildkit.worker.selinux.enabled: false
|
||||
org.mobyproject.buildkit.worker.snapshotter: overlayfs
|
||||
GC Policy rule#0:
|
||||
All: false
|
||||
Filters: type==source.local,type==exec.cachemount,type==source.git.checkout
|
||||
Keep Duration: 48h0m0s
|
||||
Keep Bytes: 488.3MiB
|
||||
GC Policy rule#1:
|
||||
All: false
|
||||
Keep Duration: 1440h0m0s
|
||||
Keep Bytes: 94.06GiB
|
||||
GC Policy rule#2:
|
||||
All: false
|
||||
Keep Bytes: 94.06GiB
|
||||
GC Policy rule#3:
|
||||
All: true
|
||||
Keep Bytes: 94.06GiB
|
@ -83,7 +83,7 @@ export class Builder {
|
||||
continue;
|
||||
}
|
||||
switch (true) {
|
||||
case lkey == 'name': {
|
||||
case lkey == 'name':
|
||||
parsingType = undefined;
|
||||
if (builder.name == undefined) {
|
||||
builder.name = value;
|
||||
@ -98,42 +98,36 @@ export class Builder {
|
||||
currentNode = {name: value};
|
||||
}
|
||||
break;
|
||||
}
|
||||
case lkey == 'driver': {
|
||||
case lkey == 'driver':
|
||||
parsingType = undefined;
|
||||
builder.driver = value;
|
||||
break;
|
||||
}
|
||||
case lkey == 'last activity': {
|
||||
case lkey == 'last activity':
|
||||
parsingType = undefined;
|
||||
builder.lastActivity = new Date(value);
|
||||
break;
|
||||
}
|
||||
case lkey == 'endpoint': {
|
||||
case lkey == 'endpoint':
|
||||
parsingType = undefined;
|
||||
currentNode.endpoint = value;
|
||||
break;
|
||||
}
|
||||
case lkey == 'driver options': {
|
||||
case lkey == 'driver options':
|
||||
parsingType = undefined;
|
||||
currentNode['driver-opts'] = (value.match(/([a-zA-Z0-9_.]+)="([^"]*)"/g) || []).map(v => v.replace(/^(.*)="(.*)"$/g, '$1=$2'));
|
||||
break;
|
||||
}
|
||||
case lkey == 'status': {
|
||||
case lkey == 'status':
|
||||
parsingType = undefined;
|
||||
currentNode.status = value;
|
||||
break;
|
||||
}
|
||||
case lkey == 'flags': {
|
||||
case lkey == 'buildkit daemon flags':
|
||||
case lkey == 'flags': // buildx < v0.13
|
||||
parsingType = undefined;
|
||||
currentNode['buildkitd-flags'] = value;
|
||||
break;
|
||||
}
|
||||
case lkey == 'buildkit': {
|
||||
case lkey == 'buildkit version':
|
||||
case lkey == 'buildkit': // buildx < v0.13
|
||||
parsingType = undefined;
|
||||
currentNode.buildkit = value;
|
||||
break;
|
||||
}
|
||||
case lkey == 'platforms': {
|
||||
parsingType = undefined;
|
||||
if (!value) {
|
||||
@ -155,19 +149,17 @@ export class Builder {
|
||||
currentNode.platforms = platforms.join(',');
|
||||
break;
|
||||
}
|
||||
case lkey == 'labels': {
|
||||
case lkey == 'labels':
|
||||
parsingType = 'label';
|
||||
currentNode.labels = {};
|
||||
break;
|
||||
}
|
||||
case lkey.startsWith('gc policy rule#'): {
|
||||
case lkey.startsWith('gc policy rule#'):
|
||||
parsingType = 'gcpolicy';
|
||||
if (currentNode.gcPolicy && currentGCPolicy) {
|
||||
currentNode.gcPolicy.push(currentGCPolicy);
|
||||
currentGCPolicy = undefined;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
switch (parsingType || '') {
|
||||
case 'label': {
|
||||
|
Loading…
Reference in New Issue
Block a user