Add platforms filter on push
When referencing multi-arch images in a docker-app, this allows to
selectively push only the platforms the user wants to support.
@@ -29,6 +29,7 @@ import (
type pushOptions struct {
registry registryOptions
tag string
+ platforms []string
}
func pushCmd(dockerCli command.Cli) *cobra.Command {
@@ -43,6 +44,7 @@ func pushCmd(dockerCli command.Cli) *cobra.Command {
}
flags := cmd.Flags()
flags.StringVarP(&opts.tag, "tag", "t", "", "Target registry reference (default: <name>:<version> from metadata)")
+ flags.StringSliceVar(&opts.platforms, "platforms", nil, "For multi-arch service images, only push the sepcified platforms")
opts.registry.addFlags(flags)
return cmd
}
@@ -94,8 +96,14 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
if term.IsTerminal(os.Stdout.Fd()) {
display = &interactiveDisplay{out: os.Stdout}
}
+ fixupOptions := []remotes.FixupOption{
+ remotes.WithEventCallback(display.onEvent),
+ }
+ if len(opts.platforms) > 0 {
+ fixupOptions = append(fixupOptions, remotes.WithComponentImagePlatforms(opts.platforms))
+ }
// bundle fixup
- err = remotes.FixupBundle(context.Background(), bndl, retag.cnabRef, resolverConfig, remotes.WithEventCallback(display.onEvent))
+ err = remotes.FixupBundle(context.Background(), bndl, retag.cnabRef, resolverConfig, fixupOptions...)
if err != nil {
return err
