push: support pushing directly from a bundle file.
This is done by providing a new `--bundle` option.
@@ -29,6 +29,7 @@ import (
type pushOptions struct {
registry registryOptions
tag string
+ bundle string
platforms []string
}
@@ -45,6 +46,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.StringVar(&opts.bundle, "bundle", "", "Push a specific bundle")
flags.StringSliceVar(&opts.platforms, "platform", nil, "For multi-arch service images, only push the specified platforms")
opts.registry.addFlags(flags)
return cmd
@@ -52,16 +54,38 @@ func pushCmd(dockerCli command.Cli) *cobra.Command {
func runPush(dockerCli command.Cli, name string, opts pushOptions) error {
defer muteDockerCli(dockerCli)()
+
+ var (
+ bndl *bundle.Bundle
+ meta metadata.AppMetadata
+ )
+ if opts.bundle == "" {
app, err := packager.Extract(name)
if err != nil {
return err
}
defer app.Cleanup()
- bndl, err := makeBundleFromApp(dockerCli, app, nil)
+ if bndl, err = makeBundleFromApp(dockerCli, app, nil); err != nil {
+ return err
+ }
+ meta = app.Metadata()
+ } else {
+ if name != "" {
+ fmt.Fprintf(os.Stderr, "WARNING: ignoring dockerapp at %q, pushing app directly from %q\n", name, opts.bundle)
+ }
+ r, err := os.Open(opts.bundle)
if err != nil {
return err
}
- retag, err := shouldRetagInvocationImage(app.Metadata(), bndl, opts.tag)
+ if b, err := bundle.ParseReader(r); err == nil {
+ bndl = &b // TODO: PR to change return type of ParseReader
+ } else {
+ return err
+ }
+ meta = metadata.FromBundle(bndl)
+ }
+
+ retag, err := shouldRetagInvocationImage(meta, bndl, opts.tag)
if err != nil {
return err
}
