feat(build): --push and --push-registry flags to push build images to cluster or registries

This commit is contained in:
Pasha Sviderski
2025-11-03 15:38:59 +10:00
parent 6da8e98c62
commit c3ecd378f8
4 changed files with 106 additions and 22 deletions
+8 -6
View File
@@ -14,8 +14,8 @@ import (
type pushOptions struct {
image string
machines []string
context string
platform string
context string
}
func NewPushCommand() *cobra.Command {
@@ -50,9 +50,8 @@ The image is uploaded to the machine which CLI is connected to (default) or the
}
cmd.Flags().StringSliceVarP(&opts.machines, "machine", "m", nil,
"Machine names to push the image to. Can be specified multiple times or as a comma-separated "+
"list of machine names.\n"+
"Use 'all' to push to all machines. (default is connected machine)")
"Machine names or IDs to push the image to. Can be specified multiple times or as a comma-separated list. "+
"(default is all machines)")
cmd.Flags().StringVar(
&opts.platform, "platform", "",
"Push a specific platform of a multi-platform image (e.g., linux/amd64, linux/arm64).\n"+
@@ -76,11 +75,14 @@ func push(ctx context.Context, uncli *cli.CLI, opts pushOptions) error {
machines := cli.ExpandCommaSeparatedValues(opts.machines)
pushOpts := client.PushImageOptions{}
// Special handling for "all" keyword to push to all machines.
// Special handling for an explicit "all" keyword to push to all machines.
if len(machines) == 1 && machines[0] == "all" {
pushOpts.AllMachines = true
} else {
} else if len(machines) > 0 {
pushOpts.Machines = machines
} else {
// Default is to push to all machines in the cluster.
pushOpts.AllMachines = true
}
if opts.platform != "" {