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

Commit 9446f68

Browse files
authored
Merge pull request #504 from simonferquel/push-platform-filters
Push: platform filters
2 parents 543a5a2 + 732f892 commit 9446f68

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

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 {
@@ -44,6 +45,7 @@ func pushCmd(dockerCli command.Cli) *cobra.Command {
4445
}
4546
flags := cmd.Flags()
4647
flags.StringVarP(&opts.tag, "tag", "t", "", "Target registry reference (default: <name>:<version> from metadata)")
48+
flags.StringSliceVar(&opts.platforms, "platform", nil, "For multi-arch service images, only push the specified platforms")
4749
opts.registry.addFlags(flags)
4850
return cmd
4951
}
@@ -95,8 +97,14 @@ func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
9597
if term.IsTerminal(os.Stdout.Fd()) {
9698
display = &interactiveDisplay{out: os.Stdout}
9799
}
100+
fixupOptions := []remotes.FixupOption{
101+
remotes.WithEventCallback(display.onEvent),
102+
}
103+
if len(opts.platforms) > 0 {
104+
fixupOptions = append(fixupOptions, remotes.WithComponentImagePlatforms(opts.platforms))
105+
}
98106
// bundle fixup
99-
err = remotes.FixupBundle(context.Background(), bndl, retag.cnabRef, resolverConfig, remotes.WithEventCallback(display.onEvent))
107+
err = remotes.FixupBundle(context.Background(), bndl, retag.cnabRef, resolverConfig, fixupOptions...)
100108

101109
if err != nil {
102110
return err

0 commit comments

Comments
 (0)