Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 146b8b4

Browse files
committed
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. Signed-off-by: Simon Ferquel <[email protected]>
1 parent b5935a5 commit 146b8b4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

internal/commands/push.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ import (
2727
)
2828

2929
type pushOptions struct {
30-
registry registryOptions
31-
tag string
30+
registry registryOptions
31+
tag string
32+
platforms []string
3233
}
3334

3435
func pushCmd(dockerCli command.Cli) *cobra.Command {
@@ -43,6 +44,7 @@ func pushCmd(dockerCli command.Cli) *cobra.Command {
4344
}
4445
flags := cmd.Flags()
4546
flags.StringVarP(&opts.tag, "tag", "t", "", "Target registry reference (default: <name>:<version> from metadata)")
47+
flags.StringSliceVar(&opts.platforms, "platforms", nil, "For multi-arch service images, only push the sepcified platforms")
4648
opts.registry.addFlags(flags)
4749
return cmd
4850
}
@@ -94,8 +96,14 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
9496
if term.IsTerminal(os.Stdout.Fd()) {
9597
display = &interactiveDisplay{out: os.Stdout}
9698
}
99+
fixupOptions := []remotes.FixupOption{
100+
remotes.WithEventCallback(display.onEvent),
101+
}
102+
if len(opts.platforms) > 0 {
103+
fixupOptions = append(fixupOptions, remotes.WithComponentImagePlatforms(opts.platforms))
104+
}
97105
// bundle fixup
98-
err = remotes.FixupBundle(context.Background(), bndl, retag.cnabRef, resolverConfig, remotes.WithEventCallback(display.onEvent))
106+
err = remotes.FixupBundle(context.Background(), bndl, retag.cnabRef, resolverConfig, fixupOptions...)
99107

100108
if err != nil {
101109
return err

0 commit comments

Comments
 (0)