Skip to content

Commit

Permalink
builder: support features in inspect command
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Mar 12, 2024
1 parent 225d61b commit 9436c6c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions __tests__/buildx/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,12 @@ describe('parseInspect', () => {
"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",
"features": {
"Cache export": true,
"Docker exporter": true,
"Multi-platform build": true,
"OCI exporter": true,
},
"labels": {
"org.mobyproject.buildkit.worker.executor": "oci",
"org.mobyproject.buildkit.worker.hostname": "docker-desktop",
Expand Down
5 changes: 5 additions & 0 deletions __tests__/fixtures/inspect11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ 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
Features:
Cache export: true
Docker exporter: true
Multi-platform build: true
OCI exporter: true
Labels:
org.mobyproject.buildkit.worker.executor: oci
org.mobyproject.buildkit.worker.hostname: docker-desktop
Expand Down
9 changes: 9 additions & 0 deletions src/buildx/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ export class Builder {
currentNode.platforms = platforms.join(',');
break;
}
case lkey == 'features':
parsingType = 'features';
currentNode.features = {};
break;
case lkey == 'labels':
parsingType = 'label';
currentNode.labels = {};
Expand All @@ -162,6 +166,11 @@ export class Builder {
break;
default: {
switch (parsingType || '') {
case 'features': {
currentNode.features = currentNode.features || {};
currentNode.features[key.trim()] = Boolean(value);
break;
}
case 'label': {
currentNode.labels = currentNode.labels || {};
currentNode.labels[key.trim()] = value;
Expand Down
1 change: 1 addition & 0 deletions src/types/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface Node {
export interface NodeInfo extends Node {
status?: string;
buildkit?: string;
features?: Record<string, boolean>;
labels?: Record<string, string>;
gcPolicy?: Array<GCPolicy>;
}
Expand Down

0 comments on commit 9436c6c

Please sign in to comment.