feat(push): stub for 'image push' command and Dialer interface for cluster connectors

This commit is contained in:
Pasha Sviderski
2025-09-23 16:54:47 +10:00
parent 1a1afece7d
commit 9f6880b701
7 changed files with 87 additions and 1 deletions
+47
View File
@@ -0,0 +1,47 @@
package image
import (
"fmt"
"github.com/psviderski/uncloud/internal/cli"
"github.com/spf13/cobra"
)
type pushOptions struct {
machines []string
}
func NewPushCommand() *cobra.Command {
opts := pushOptions{}
cmd := &cobra.Command{
Use: "push IMAGE",
Short: "Upload a local Docker image to the cluster.",
Long: `Upload a local Docker image to the cluster transferring only the missing layers.
The image is uploaded to the machine which CLI is connected to (default) or the specified machine(s).`,
Example: ` # Push image to the currently connected machine.
uc image push myapp:latest
# Push image to specific machine.
uc image push myapp:latest -m machine1
# Push image to multiple machines.
uc image push myapp:latest -m machine1,machine2,machine3`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
image := args[0]
machines := cli.ExpandCommaSeparatedValues(opts.machines)
// TODO: Implement image push logic
fmt.Printf("Would push image %q to machines: %v\n", image, machines)
return fmt.Errorf("image push not yet implemented")
},
}
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. (default is connected machine)")
return cmd
}
+18
View File
@@ -0,0 +1,18 @@
package image
import (
"github.com/spf13/cobra"
)
func NewRootCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "image",
Short: "Manage Docker images in a cluster.",
}
cmd.AddCommand(
NewPushCommand(),
)
return cmd
}