mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
chore: group deploy and service management commands in uc --help
This commit is contained in:
@@ -49,6 +49,7 @@ to cluster machines or --push-registry to upload them to external registries.`,
|
||||
|
||||
return runBuild(cmd.Context(), uncli, opts)
|
||||
},
|
||||
GroupID: "service",
|
||||
}
|
||||
|
||||
cmd.Flags().StringArrayVar(&opts.BuildArgs, "build-arg", nil,
|
||||
|
||||
@@ -42,6 +42,7 @@ func NewDeployCommand() *cobra.Command {
|
||||
|
||||
return runDeploy(cmd.Context(), uncli, opts)
|
||||
},
|
||||
GroupID: "service",
|
||||
}
|
||||
|
||||
cmd.Flags().StringArrayVar(&opts.BuildServicesOptions.BuildArgs, "build-arg", nil,
|
||||
|
||||
+14
-7
@@ -107,6 +107,11 @@ func main() {
|
||||
}
|
||||
})
|
||||
|
||||
cmd.AddGroup(&cobra.Group{
|
||||
ID: "service",
|
||||
Title: "Deploy and manage services:",
|
||||
})
|
||||
|
||||
cmd.AddCommand(
|
||||
NewBuildCommand(),
|
||||
NewDeployCommand(),
|
||||
@@ -119,13 +124,15 @@ func main() {
|
||||
image.NewRootCommand(),
|
||||
machine.NewRootCommand(),
|
||||
service.NewRootCommand(),
|
||||
service.NewExecCommand(),
|
||||
service.NewInspectCommand(),
|
||||
service.NewListCommand(),
|
||||
service.NewLogsCommand(),
|
||||
service.NewRmCommand(),
|
||||
service.NewRunCommand(),
|
||||
service.NewScaleCommand(),
|
||||
service.NewExecCommand("service"),
|
||||
service.NewInspectCommand("service"),
|
||||
service.NewListCommand("service"),
|
||||
service.NewLogsCommand("service"),
|
||||
service.NewRmCommand("service"),
|
||||
service.NewRunCommand("service"),
|
||||
service.NewScaleCommand("service"),
|
||||
service.NewStartCommand("service"),
|
||||
service.NewStopCommand("service"),
|
||||
volume.NewRootCommand(),
|
||||
)
|
||||
cobra.CheckErr(cmd.Execute())
|
||||
|
||||
+2
-1
@@ -38,7 +38,7 @@ func NewPsCommand() *cobra.Command {
|
||||
opts := psOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "ps",
|
||||
Short: "List all service containers in the cluster",
|
||||
Short: "List all service containers.",
|
||||
Long: `List all service containers across all machines in the cluster.
|
||||
|
||||
This command provides a comprehensive overview of all running containers that are part of a service,
|
||||
@@ -50,6 +50,7 @@ making it easy to see the distribution and status of containers across the clust
|
||||
}
|
||||
return runPs(cmd, opts)
|
||||
},
|
||||
GroupID: "service",
|
||||
}
|
||||
cmd.Flags().StringVarP(&opts.sortBy, "sort", "s", sortByService,
|
||||
"Sort containers by 'service', 'machine' or 'health'")
|
||||
|
||||
@@ -20,12 +20,12 @@ type execCliOptions struct {
|
||||
|
||||
var DEFAULT_COMMAND = []string{"sh", "-c", "command -v bash >/dev/null 2>&1 && exec bash || exec sh"}
|
||||
|
||||
func NewExecCommand() *cobra.Command {
|
||||
func NewExecCommand(groupID string) *cobra.Command {
|
||||
opts := execCliOptions{}
|
||||
|
||||
execCmd := &cobra.Command{
|
||||
Use: "exec [OPTIONS] SERVICE [COMMAND ARGS...]",
|
||||
Short: "Execute a command in a running service container",
|
||||
Short: "Execute a command in a running service container.",
|
||||
Long: `Execute a command (interactive shell by default) in a running container within a service.
|
||||
If the service has multiple replicas and no container ID is specified, the command will be executed in a random container.
|
||||
`,
|
||||
@@ -54,6 +54,7 @@ If the service has multiple replicas and no container ID is specified, the comma
|
||||
}
|
||||
return runExec(cmd.Context(), uncli, serviceName, command, opts)
|
||||
},
|
||||
GroupID: groupID,
|
||||
}
|
||||
|
||||
execCmd.Flags().BoolVarP(&opts.detach, "detach", "d", false, "Detached mode: run command in the background")
|
||||
|
||||
@@ -17,7 +17,7 @@ type inspectOptions struct {
|
||||
service string
|
||||
}
|
||||
|
||||
func NewInspectCommand() *cobra.Command {
|
||||
func NewInspectCommand(groupID string) *cobra.Command {
|
||||
opts := inspectOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "inspect SERVICE",
|
||||
@@ -28,6 +28,7 @@ func NewInspectCommand() *cobra.Command {
|
||||
opts.service = args[0]
|
||||
return inspect(cmd.Context(), uncli, opts)
|
||||
},
|
||||
GroupID: groupID,
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ type logsOptions struct {
|
||||
machines []string
|
||||
}
|
||||
|
||||
func NewLogsCommand() *cobra.Command {
|
||||
func NewLogsCommand(groupID string) *cobra.Command {
|
||||
var options logsOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -68,6 +68,7 @@ If no services are specified, streams logs from all services defined in the Comp
|
||||
uncli := cmd.Context().Value("cli").(*cli.CLI)
|
||||
return runLogs(cmd.Context(), uncli, args, options)
|
||||
},
|
||||
GroupID: groupID,
|
||||
}
|
||||
|
||||
cmd.Flags().StringSliceVar(&options.files, "file", nil,
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func NewListCommand() *cobra.Command {
|
||||
func NewListCommand(groupID string) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "ls",
|
||||
Aliases: []string{"list"},
|
||||
@@ -22,6 +22,7 @@ func NewListCommand() *cobra.Command {
|
||||
uncli := cmd.Context().Value("cli").(*cli.CLI)
|
||||
return list(cmd.Context(), uncli)
|
||||
},
|
||||
GroupID: groupID,
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type rmOptions struct {
|
||||
services []string
|
||||
}
|
||||
|
||||
func NewRmCommand() *cobra.Command {
|
||||
func NewRmCommand(groupID string) *cobra.Command {
|
||||
opts := rmOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "rm SERVICE [SERVICE...]",
|
||||
@@ -30,6 +30,7 @@ directives in image Dockerfiles) are automatically removed with their containers
|
||||
opts.services = args
|
||||
return rm(cmd.Context(), uncli, opts)
|
||||
},
|
||||
GroupID: groupID,
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@ func NewRootCommand() *cobra.Command {
|
||||
Short: "Manage services in the cluster.",
|
||||
}
|
||||
cmd.AddCommand(
|
||||
NewExecCommand(),
|
||||
NewInspectCommand(),
|
||||
NewListCommand(),
|
||||
NewLogsCommand(),
|
||||
NewRmCommand(),
|
||||
NewRunCommand(),
|
||||
NewScaleCommand(),
|
||||
NewStopCommand(),
|
||||
NewStartCommand(),
|
||||
NewExecCommand(""),
|
||||
NewInspectCommand(""),
|
||||
NewListCommand(""),
|
||||
NewLogsCommand(""),
|
||||
NewRmCommand(""),
|
||||
NewRunCommand(""),
|
||||
NewScaleCommand(""),
|
||||
NewStartCommand(""),
|
||||
NewStopCommand(""),
|
||||
)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ type runOptions struct {
|
||||
volumes []string
|
||||
}
|
||||
|
||||
func NewRunCommand() *cobra.Command {
|
||||
func NewRunCommand(groupID string) *cobra.Command {
|
||||
opts := runOptions{}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -54,6 +54,7 @@ func NewRunCommand() *cobra.Command {
|
||||
|
||||
return run(cmd.Context(), uncli, opts)
|
||||
},
|
||||
GroupID: groupID,
|
||||
}
|
||||
|
||||
cmd.Flags().StringVar(&opts.caddyfile, "caddyfile", "",
|
||||
|
||||
@@ -17,7 +17,7 @@ type scaleOptions struct {
|
||||
replicas uint
|
||||
}
|
||||
|
||||
func NewScaleCommand() *cobra.Command {
|
||||
func NewScaleCommand(groupID string) *cobra.Command {
|
||||
opts := scaleOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "scale SERVICE REPLICAS",
|
||||
@@ -36,6 +36,7 @@ func NewScaleCommand() *cobra.Command {
|
||||
|
||||
return scale(cmd.Context(), uncli, opts)
|
||||
},
|
||||
GroupID: groupID,
|
||||
}
|
||||
|
||||
return cmd
|
||||
|
||||
@@ -14,7 +14,7 @@ type startOptions struct {
|
||||
services []string
|
||||
}
|
||||
|
||||
func NewStartCommand() *cobra.Command {
|
||||
func NewStartCommand(groupID string) *cobra.Command {
|
||||
opts := startOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "start SERVICE [SERVICE...]",
|
||||
@@ -26,6 +26,7 @@ func NewStartCommand() *cobra.Command {
|
||||
opts.services = args
|
||||
return start(cmd.Context(), uncli, opts)
|
||||
},
|
||||
GroupID: groupID,
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ type stopOptions struct {
|
||||
timeout int
|
||||
}
|
||||
|
||||
func NewStopCommand() *cobra.Command {
|
||||
func NewStopCommand(groupID string) *cobra.Command {
|
||||
opts := stopOptions{}
|
||||
cmd := &cobra.Command{
|
||||
Use: "stop SERVICE [SERVICE...]",
|
||||
@@ -31,6 +31,7 @@ func NewStopCommand() *cobra.Command {
|
||||
opts.timeoutChanged = cmd.Flags().Changed("timeout")
|
||||
return stop(cmd.Context(), uncli, opts)
|
||||
},
|
||||
GroupID: groupID,
|
||||
}
|
||||
cmd.Flags().StringVarP(&opts.signal, "signal", "s", "", "Signal to send to the container")
|
||||
cmd.Flags().IntVarP(&opts.timeout, "timeout", "t", 0, "Seconds to wait before killing the container")
|
||||
|
||||
Reference in New Issue
Block a user