mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
buildx(build): resolveWarnings from metadata
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
5205f4197c
commit
630b180101
@ -84,6 +84,16 @@ describe('resolveProvenance', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveWarnings', () => {
|
||||
it('matches', async () => {
|
||||
const build = new Build();
|
||||
fs.writeFileSync(build.getMetadataFilePath(), JSON.stringify(metadata));
|
||||
const warnings = build.resolveWarnings();
|
||||
expect(warnings).toBeDefined();
|
||||
expect(warnings?.length).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveDigest', () => {
|
||||
it('matches', async () => {
|
||||
const build = new Build();
|
||||
|
@ -40,6 +40,189 @@
|
||||
}
|
||||
},
|
||||
"buildx.build.ref": "default/default/n6ibcp9b2pw108rrz7ywdznvo",
|
||||
"buildx.build.warnings": [
|
||||
{
|
||||
"vertex": "sha256:7b477ac5dd3a4c4d2523f7f7f20406b626395de082f44fd5ff996323ec8257d0",
|
||||
"level": 1,
|
||||
"short": "Q29uc2lzdGVudEluc3RydWN0aW9uQ2FzaW5nOiBDb21tYW5kICdmck9NJyBzaG91bGQgYmUgY29uc2lzdGVudGx5IGNhc2VkIChsaW5lIDIp",
|
||||
"detail": [
|
||||
"SW5zdHJ1Y3Rpb25zIHNob3VsZCBiZSBpbiBjb25zaXN0ZW50IGNhc2luZyAoYWxsIGxvd2VyIG9yIGFsbCB1cHBlcik="
|
||||
],
|
||||
"url": "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
|
||||
"sourceInfo": {
|
||||
"filename": "Dockerfile",
|
||||
"data": "IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGUtdXBzdHJlYW06bWFzdGVyCmZyT00gYnVzeWJveCBhcyBiYXNlCmNPcHkgRG9ja2VyZmlsZSAuCgpmcm9tIHNjcmF0Y2gKQ09QeSAtLWZyb209YmFzZSBcCiAgL0RvY2tlcmZpbGUgXAogIC8K",
|
||||
"definition": {
|
||||
"def": [
|
||||
"GsUBChJsb2NhbDovL2RvY2tlcmZpbGUSFAoMbG9jYWwuZGlmZmVyEgRub25lEkoKEWxvY2FsLmZvbGxvd3BhdGhzEjVbIkRvY2tlcmZpbGUiLCJEb2NrZXJmaWxlLmRvY2tlcmlnbm9yZSIsImRvY2tlcmZpbGUiXRIqCg1sb2NhbC5zZXNzaW9uEhkwN3A3MzJ6aGR4NXV1NnVsZDNzOGpteWo2EiEKE2xvY2FsLnNoYXJlZGtleWhpbnQSCmRvY2tlcmZpbGVaAA==",
|
||||
"CkkKR3NoYTI1Njo3YjQ3N2FjNWRkM2E0YzRkMjUyM2Y3ZjdmMjA0MDZiNjI2Mzk1ZGUwODJmNDRmZDVmZjk5NjMyM2VjODI1N2Qw"
|
||||
],
|
||||
"metadata": {
|
||||
"sha256:7b477ac5dd3a4c4d2523f7f7f20406b626395de082f44fd5ff996323ec8257d0": {
|
||||
"description": {
|
||||
"llb.customname": "[internal] load build definition from Dockerfile"
|
||||
},
|
||||
"caps": {
|
||||
"source.local": true,
|
||||
"source.local.followpaths": true,
|
||||
"source.local.sessionid": true,
|
||||
"source.local.sharedkeyhint": true
|
||||
}
|
||||
},
|
||||
"sha256:a06279dbe062a3b181c9b918abfaf37ca8106f1f9745b9d42356b3195b205cd1": {
|
||||
"caps": {
|
||||
"constraints": true,
|
||||
"meta.description": true,
|
||||
"platform": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"Source": {
|
||||
"locations": {
|
||||
"sha256:7b477ac5dd3a4c4d2523f7f7f20406b626395de082f44fd5ff996323ec8257d0": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"language": "Dockerfile"
|
||||
},
|
||||
"range": [
|
||||
{
|
||||
"start": {
|
||||
"line": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"vertex": "sha256:7b477ac5dd3a4c4d2523f7f7f20406b626395de082f44fd5ff996323ec8257d0",
|
||||
"level": 1,
|
||||
"short": "Q29uc2lzdGVudEluc3RydWN0aW9uQ2FzaW5nOiBDb21tYW5kICdjT3B5JyBzaG91bGQgYmUgY29uc2lzdGVudGx5IGNhc2VkIChsaW5lIDMp",
|
||||
"detail": [
|
||||
"SW5zdHJ1Y3Rpb25zIHNob3VsZCBiZSBpbiBjb25zaXN0ZW50IGNhc2luZyAoYWxsIGxvd2VyIG9yIGFsbCB1cHBlcik="
|
||||
],
|
||||
"url": "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
|
||||
"sourceInfo": {
|
||||
"filename": "Dockerfile",
|
||||
"data": "IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGUtdXBzdHJlYW06bWFzdGVyCmZyT00gYnVzeWJveCBhcyBiYXNlCmNPcHkgRG9ja2VyZmlsZSAuCgpmcm9tIHNjcmF0Y2gKQ09QeSAtLWZyb209YmFzZSBcCiAgL0RvY2tlcmZpbGUgXAogIC8K",
|
||||
"definition": {
|
||||
"def": [
|
||||
"GsUBChJsb2NhbDovL2RvY2tlcmZpbGUSFAoMbG9jYWwuZGlmZmVyEgRub25lEkoKEWxvY2FsLmZvbGxvd3BhdGhzEjVbIkRvY2tlcmZpbGUiLCJEb2NrZXJmaWxlLmRvY2tlcmlnbm9yZSIsImRvY2tlcmZpbGUiXRIqCg1sb2NhbC5zZXNzaW9uEhkwN3A3MzJ6aGR4NXV1NnVsZDNzOGpteWo2EiEKE2xvY2FsLnNoYXJlZGtleWhpbnQSCmRvY2tlcmZpbGVaAA==",
|
||||
"CkkKR3NoYTI1Njo3YjQ3N2FjNWRkM2E0YzRkMjUyM2Y3ZjdmMjA0MDZiNjI2Mzk1ZGUwODJmNDRmZDVmZjk5NjMyM2VjODI1N2Qw"
|
||||
],
|
||||
"metadata": {
|
||||
"sha256:7b477ac5dd3a4c4d2523f7f7f20406b626395de082f44fd5ff996323ec8257d0": {
|
||||
"description": {
|
||||
"llb.customname": "[internal] load build definition from Dockerfile"
|
||||
},
|
||||
"caps": {
|
||||
"source.local": true,
|
||||
"source.local.followpaths": true,
|
||||
"source.local.sessionid": true,
|
||||
"source.local.sharedkeyhint": true
|
||||
}
|
||||
},
|
||||
"sha256:a06279dbe062a3b181c9b918abfaf37ca8106f1f9745b9d42356b3195b205cd1": {
|
||||
"caps": {
|
||||
"constraints": true,
|
||||
"meta.description": true,
|
||||
"platform": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"Source": {
|
||||
"locations": {
|
||||
"sha256:7b477ac5dd3a4c4d2523f7f7f20406b626395de082f44fd5ff996323ec8257d0": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"language": "Dockerfile"
|
||||
},
|
||||
"range": [
|
||||
{
|
||||
"start": {
|
||||
"line": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 3
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"vertex": "sha256:7b477ac5dd3a4c4d2523f7f7f20406b626395de082f44fd5ff996323ec8257d0",
|
||||
"level": 1,
|
||||
"short": "Q29uc2lzdGVudEluc3RydWN0aW9uQ2FzaW5nOiBDb21tYW5kICdDT1B5JyBzaG91bGQgYmUgY29uc2lzdGVudGx5IGNhc2VkIChsaW5lIDYp",
|
||||
"detail": [
|
||||
"SW5zdHJ1Y3Rpb25zIHNob3VsZCBiZSBpbiBjb25zaXN0ZW50IGNhc2luZyAoYWxsIGxvd2VyIG9yIGFsbCB1cHBlcik="
|
||||
],
|
||||
"url": "https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/",
|
||||
"sourceInfo": {
|
||||
"filename": "Dockerfile",
|
||||
"data": "IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGUtdXBzdHJlYW06bWFzdGVyCmZyT00gYnVzeWJveCBhcyBiYXNlCmNPcHkgRG9ja2VyZmlsZSAuCgpmcm9tIHNjcmF0Y2gKQ09QeSAtLWZyb209YmFzZSBcCiAgL0RvY2tlcmZpbGUgXAogIC8K",
|
||||
"definition": {
|
||||
"def": [
|
||||
"GsUBChJsb2NhbDovL2RvY2tlcmZpbGUSFAoMbG9jYWwuZGlmZmVyEgRub25lEkoKEWxvY2FsLmZvbGxvd3BhdGhzEjVbIkRvY2tlcmZpbGUiLCJEb2NrZXJmaWxlLmRvY2tlcmlnbm9yZSIsImRvY2tlcmZpbGUiXRIqCg1sb2NhbC5zZXNzaW9uEhkwN3A3MzJ6aGR4NXV1NnVsZDNzOGpteWo2EiEKE2xvY2FsLnNoYXJlZGtleWhpbnQSCmRvY2tlcmZpbGVaAA==",
|
||||
"CkkKR3NoYTI1Njo3YjQ3N2FjNWRkM2E0YzRkMjUyM2Y3ZjdmMjA0MDZiNjI2Mzk1ZGUwODJmNDRmZDVmZjk5NjMyM2VjODI1N2Qw"
|
||||
],
|
||||
"metadata": {
|
||||
"sha256:7b477ac5dd3a4c4d2523f7f7f20406b626395de082f44fd5ff996323ec8257d0": {
|
||||
"description": {
|
||||
"llb.customname": "[internal] load build definition from Dockerfile"
|
||||
},
|
||||
"caps": {
|
||||
"source.local": true,
|
||||
"source.local.followpaths": true,
|
||||
"source.local.sessionid": true,
|
||||
"source.local.sharedkeyhint": true
|
||||
}
|
||||
},
|
||||
"sha256:a06279dbe062a3b181c9b918abfaf37ca8106f1f9745b9d42356b3195b205cd1": {
|
||||
"caps": {
|
||||
"constraints": true,
|
||||
"meta.description": true,
|
||||
"platform": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"Source": {
|
||||
"locations": {
|
||||
"sha256:7b477ac5dd3a4c4d2523f7f7f20406b626395de082f44fd5ff996323ec8257d0": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"language": "Dockerfile"
|
||||
},
|
||||
"range": [
|
||||
{
|
||||
"start": {
|
||||
"line": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 6
|
||||
}
|
||||
},
|
||||
{
|
||||
"start": {
|
||||
"line": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 7
|
||||
}
|
||||
},
|
||||
{
|
||||
"start": {
|
||||
"line": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 8
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"containerimage.config.digest": "sha256:059b68a595b22564a1cbc167f369349fdc2ecc1f7bc092c2235cbf601a795fd",
|
||||
"containerimage.digest": "sha256:b09b9482c72371486bb2c1d2c2a2633ed1d0b8389e12c8d52b9e052725c0c83c"
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import {GitHub} from '../github';
|
||||
import {Util} from '../util';
|
||||
|
||||
import {BuildMetadata} from '../types/buildx/build';
|
||||
import {VertexWarning} from '../types/buildkit/client';
|
||||
import {ProvenancePredicate} from '../types/intoto/slsa_provenance/v0.2/provenance';
|
||||
|
||||
export interface BuildOpts {
|
||||
@ -96,6 +97,19 @@ export class Build {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public resolveWarnings(metadata?: BuildMetadata): Array<VertexWarning> | undefined {
|
||||
if (!metadata) {
|
||||
metadata = this.resolveMetadata();
|
||||
if (!metadata) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
if ('buildx.build.warnings' in metadata) {
|
||||
return metadata['buildx.build.warnings'] as Array<VertexWarning>;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public resolveDigest(metadata?: BuildMetadata): string | undefined {
|
||||
if (!metadata) {
|
||||
metadata = this.resolveMetadata();
|
||||
|
Loading…
Reference in New Issue
Block a user