Merge pull request #560 from crazy-max/builder-inspect-file
Some checks failed
publish / publish (push) Has been cancelled

builder: support files in inspect command
This commit is contained in:
CrazyMax
2025-01-23 10:53:25 +01:00
committed by GitHub
4 changed files with 42 additions and 1 deletions

View File

@@ -37,3 +37,15 @@ GC Policy rule#2:
GC Policy rule#3:
All: true
Keep Bytes: 94.06GiB
File#buildkitd.toml:
> debug = true
> insecure-entitlements = ["network.host", "security.insecure"]
> trace = true
>
> [log]
> format = "text"
>
File#foo.txt:
> foo = bar
> baz = qux
>

View File

@@ -449,7 +449,19 @@ describe('parseInspect', () => {
"all": true,
"keepBytes": "94.06GiB",
}
]
],
"files": {
"buildkitd.toml": `debug = true
insecure-entitlements = ["network.host", "security.insecure"]
trace = true
[log]
format = "text"
`,
"foo.txt": `foo = bar
baz = qux
`,
}
}
]
}

View File

@@ -89,6 +89,7 @@ export class Builder {
let parsingType: string | undefined;
let currentNode: NodeInfo = {};
let currentGCPolicy: GCPolicy | undefined;
let currentFile: string | undefined;
for (const line of data.trim().split(`\n`)) {
const [key, ...rest] = line.split(':');
const lkey = key.toLowerCase();
@@ -178,6 +179,12 @@ export class Builder {
currentGCPolicy = undefined;
}
break;
case lkey.startsWith('file#'):
parsingType = 'file';
currentFile = key.split('#')[1];
currentNode.files = currentNode.files || {};
currentNode.files[currentFile] = '';
break;
default: {
switch (parsingType || '') {
case 'features': {
@@ -215,6 +222,15 @@ export class Builder {
}
break;
}
case 'file': {
if (currentFile && currentNode.files) {
if (currentNode.files[currentFile].length > 0) {
currentNode.files[currentFile] += '\n';
}
currentNode.files[currentFile] += line.replace(/^\s>\s?/, '');
}
break;
}
}
}
}

View File

@@ -35,6 +35,7 @@ export interface NodeInfo extends Node {
features?: Record<string, boolean>;
labels?: Record<string, string>;
gcPolicy?: Array<GCPolicy>;
files?: Record<string, string>;
}
export interface GCPolicy {