sketch run command

This commit is contained in:
Pavel Sviderski
2024-10-31 20:07:45 +10:00
parent 8a3f0032ae
commit 5bf3cba2d6
2 changed files with 43 additions and 1 deletions
+2 -1
View File
@@ -36,11 +36,12 @@ func main() {
}
// TODO: allow to override using UNCLOUD_CONFIG env var.
cmd.PersistentFlags().StringVar(&configPath, "uncloud-config", "~/.config/uncloud/config.toml",
"path to the Uncloud configuration file")
"path to the Uncloud configuration file.")
_ = cmd.MarkPersistentFlagFilename("uncloud-config", "toml")
cmd.AddCommand(
machine.NewRootCommand(),
NewRunCommand(),
)
cobra.CheckErr(cmd.Execute())
}
+41
View File
@@ -0,0 +1,41 @@
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{}
cmd := &cobra.Command{
Use: "run IMAGE",
Short: "Run a service in a cluster.",
Args: cobra.ExactArgs(1),
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)
},
}
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,
"Publish a service port to make it accessible outside the cluster. Can be specified multiple times. "+
"Format: [load_balancer_port:]container_port[/protocol]")
return cmd
}