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
imagetools: add platforms filter to imagetools create
Allows specifying platforms that should be included
in the new image, making it possible to reduce platforms
of existing multi-arch image. Previously the individual
image manifests needed to be used as sources, but that
dropped their related attestation manifests.
Signed-off-by: Tonis Tiigi <[email protected]>
returnnil, ocispecs.Descriptor{}, nil, errors.Wrapf(err, "failed to parse manifest")
249
+
}
250
+
ifdesc.Platform==nil {
251
+
returnnil, ocispecs.Descriptor{}, nil, errors.Errorf("cannot filter platforms from a manifest without platform information")
252
+
}
253
+
if!matcher.Match(*desc.Platform) {
254
+
returnnil, ocispecs.Descriptor{}, nil, errors.Errorf("input platform %s does not match any of the provided platforms", platforms.Format(*desc.Platform))
255
+
}
256
+
returndt, desc, nil, nil
257
+
}
258
+
259
+
varidx ocispecs.Index
260
+
iferr:=json.Unmarshal(dt, &idx); err!=nil {
261
+
returnnil, ocispecs.Descriptor{}, nil, errors.Wrapf(err, "failed to parse index")
flags.StringVar(&options.progress, "progress", "auto", `Set type of progress output ("auto", "plain", "tty", "rawjson"). Use plain to show container output`)
292
428
flags.StringArrayVarP(&options.annotations, "annotation", "", []string{}, "Add annotation to the image")
293
429
flags.BoolVar(&options.preferIndex, "prefer-index", true, "When only a single source is specified, prefer outputting an image index or manifest list instead of performing a carbon copy")
430
+
flags.StringArrayVarP(&options.platforms, "platform", "p", []string{}, "Filter specified platforms of target image")
Copy file name to clipboardExpand all lines: docs/reference/buildx_imagetools_create.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ Create a new image based on source images
17
17
|`-D`, `--debug`|`bool`|| Enable debug logging |
18
18
|[`--dry-run`](#dry-run)|`bool`|| Show final image instead of pushing |
19
19
|[`-f`](#file), [`--file`](#file)|`stringArray`|| Read source descriptor from file |
20
+
|`-p`, `--platform`|`stringArray`|| Filter specified platforms of target image |
20
21
|`--prefer-index`|`bool`|`true`| When only a single source is specified, prefer outputting an image index or manifest list instead of performing a carbon copy |
21
22
|`--progress`|`string`|`auto`| Set type of progress output (`auto`, `plain`, `tty`, `rawjson`). Use plain to show container output |
22
23
|[`-t`](#tag), [`--tag`](#tag)|`stringArray`|| Set reference for new image |
0 commit comments