update run command to run a stub service container on the connected node

This commit is contained in:
Pavel Sviderski
2024-11-01 15:05:07 +10:00
parent 5cb765d286
commit a54666a7ac
4 changed files with 77 additions and 23 deletions
+14 -18
View File
@@ -1,19 +1,16 @@
package main
import (
"fmt"
"github.com/spf13/cobra"
"uncloud/internal/cli"
)
type runOptions struct {
name string
publish []string
cluster string
}
func NewRunCommand() *cobra.Command {
opts := runOptions{}
var (
cluster string
opts cli.ServiceOptions
)
cmd := &cobra.Command{
Use: "run IMAGE",
Short: "Run a service in a cluster.",
@@ -21,21 +18,20 @@ func NewRunCommand() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
uncli := cmd.Context().Value("cli").(*cli.CLI)
image := args[0]
//return uncli.RunService(cmd.Context(), ...)
return fmt.Errorf("not implemented: run image %q %s", image, uncli)
opts.Image = args[0]
return uncli.RunService(cmd.Context(), cluster, &opts)
},
}
cmd.Flags().StringVarP(&opts.name, "name", "n", "",
cmd.Flags().StringVarP(&opts.Name, "name", "n", "",
"Assign a name to the service. A random name is generated if not specified.")
cmd.Flags().StringVarP(
&opts.cluster, "cluster", "c", "",
"Name of the cluster to run the service in. (default is the current cluster)",
)
cmd.Flags().StringSliceVarP(&opts.publish, "publish", "p", nil,
cmd.Flags().StringSliceVarP(&opts.Publish, "publish", "p", nil,
"Publish a service port to make it accessible outside the cluster. Can be specified multiple times. "+
"Format: [load_balancer_port:]container_port[/protocol]")
cmd.Flags().StringVarP(
&cluster, "cluster", "c", "",
"Name of the cluster to run the service in. (default is the current cluster)",
)
return cmd
}