You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for BASHBREW_BUILDKIT_SBOM_GENERATOR and provenance
Since Docker's image store can't represent these, we round trip them through our self-managed (or external) containerd image store, which also makes pushing more efficient.
// if this repo isn't one of the original top-level arguments and our error is just that it's not a supported tag, walk no further ("FROM mcr.microsoft.com/...", etc)
// if the appropriate "bashbrew/cache:xxx" image exists in the containerd image store, we should prefer that (the nature of the cache hash should make this assumption safe)
59
+
desc, err:=containerdImageLookup(cacheTag)
60
+
iferr==nil {
61
+
ifdebugFlag {
62
+
fmt.Printf("Found %s (via %q) in containerd image store\n", desc.Digest, cacheTag)
returnfmt.Errorf("have %q but missing %q", sbomGeneratorEnv, buildxBuilderEnv)
321
+
}
322
+
}
308
323
ifplatform!="" {
309
324
args=append(args, "--platform", platform)
310
325
}
311
326
for_, tag:=rangetags {
312
327
args=append(args, "--tag", tag)
313
328
}
314
-
args=append(args, "--file", file, "-")
329
+
iffile!="" {
330
+
args=append(args, "--file", file)
331
+
}
332
+
args=append(args, "-")
333
+
334
+
ifbuildxBuilder {
335
+
args=append(args, "--output", "type=oci")
336
+
// TODO ,annotation.xyz.tianon.foo=bar,annotation-manifest-descriptor.xyz.tianon.foo=bar (for OCI source annotations, which this function doesn't currently have access to)
337
+
}
315
338
316
339
cmd:=exec.Command("docker", args...)
317
340
cmd.Stdin=context
341
+
342
+
run:=func() error {
343
+
returncmd.Run()
344
+
}
345
+
ifbuildxBuilder {
346
+
run=func() error {
347
+
pipe, err:=cmd.StdoutPipe()
348
+
iferr!=nil {
349
+
returnerr
350
+
}
351
+
deferpipe.Close()
352
+
353
+
err=cmd.Start()
354
+
iferr!=nil {
355
+
returnerr
356
+
}
357
+
defercmd.Process.Kill()
358
+
359
+
_, err=containerdImageLoad(pipe)
360
+
iferr!=nil {
361
+
returnerr
362
+
}
363
+
pipe.Close()
364
+
365
+
err=cmd.Wait()
366
+
iferr!=nil {
367
+
returnerr
368
+
}
369
+
370
+
desc, err:=containerdImageLookup(tags[0])
371
+
iferr!=nil {
372
+
returnerr
373
+
}
374
+
375
+
fmt.Printf("Importing %s into Docker\n", desc.Digest)
376
+
err=containerdDockerLoad(*desc, tags)
377
+
iferr!=nil {
378
+
returnerr
379
+
}
380
+
381
+
returnnil
382
+
}
383
+
}
384
+
385
+
// intentionally not touching os.Stdout because "buildx build" does *not* put any build output to stdout and in some cases (see above) we use stdout to capture an OCI tarball and pipe it into containerd
0 commit comments