Skip to content

Commit 3c328a5

Browse files
authored
Merge pull request #560 from crazy-max/builder-inspect-file
builder: support files in inspect command
2 parents 2c62255 + f3bf577 commit 3c328a5

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

__tests__/.fixtures/inspect11.txt

+12
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@ GC Policy rule#2:
3737
GC Policy rule#3:
3838
All: true
3939
Keep Bytes: 94.06GiB
40+
File#buildkitd.toml:
41+
> debug = true
42+
> insecure-entitlements = ["network.host", "security.insecure"]
43+
> trace = true
44+
>
45+
> [log]
46+
> format = "text"
47+
>
48+
File#foo.txt:
49+
> foo = bar
50+
> baz = qux
51+
>

__tests__/buildx/builder.test.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,19 @@ describe('parseInspect', () => {
449449
"all": true,
450450
"keepBytes": "94.06GiB",
451451
}
452-
]
452+
],
453+
"files": {
454+
"buildkitd.toml": `debug = true
455+
insecure-entitlements = ["network.host", "security.insecure"]
456+
trace = true
457+
458+
[log]
459+
format = "text"
460+
`,
461+
"foo.txt": `foo = bar
462+
baz = qux
463+
`,
464+
}
453465
}
454466
]
455467
}

src/buildx/builder.ts

+16
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export class Builder {
8989
let parsingType: string | undefined;
9090
let currentNode: NodeInfo = {};
9191
let currentGCPolicy: GCPolicy | undefined;
92+
let currentFile: string | undefined;
9293
for (const line of data.trim().split(`\n`)) {
9394
const [key, ...rest] = line.split(':');
9495
const lkey = key.toLowerCase();
@@ -178,6 +179,12 @@ export class Builder {
178179
currentGCPolicy = undefined;
179180
}
180181
break;
182+
case lkey.startsWith('file#'):
183+
parsingType = 'file';
184+
currentFile = key.split('#')[1];
185+
currentNode.files = currentNode.files || {};
186+
currentNode.files[currentFile] = '';
187+
break;
181188
default: {
182189
switch (parsingType || '') {
183190
case 'features': {
@@ -215,6 +222,15 @@ export class Builder {
215222
}
216223
break;
217224
}
225+
case 'file': {
226+
if (currentFile && currentNode.files) {
227+
if (currentNode.files[currentFile].length > 0) {
228+
currentNode.files[currentFile] += '\n';
229+
}
230+
currentNode.files[currentFile] += line.replace(/^\s>\s?/, '');
231+
}
232+
break;
233+
}
218234
}
219235
}
220236
}

src/types/buildx/builder.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface NodeInfo extends Node {
3535
features?: Record<string, boolean>;
3636
labels?: Record<string, string>;
3737
gcPolicy?: Array<GCPolicy>;
38+
files?: Record<string, string>;
3839
}
3940

4041
export interface GCPolicy {

0 commit comments

Comments
 (0)