mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
instead of setting them each time on every leaf command. This has several benefits * global flags are available for every command (root, intermediate, and leaves) * help messages are as expected for every command. No more misleading ones for invalid commands. * simplifies the code and prevents the chance of forgetting to add the global flags for future commands * makes the plugin behave more like `kubectl` in that the K8s context is optional for all commands Signed-off-by: David Xia <[email protected]>
28 lines
636 B
Go
28 lines
636 B
Go
package scale
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
|
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
|
)
|
|
|
|
func NewScaleCommand(cmdFactory cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "scale",
|
|
Short: "Scale a Ray resource",
|
|
SilenceUsage: true,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if len(args) > 0 {
|
|
fmt.Println(fmt.Errorf("unknown command(s) %q", strings.Join(args, " ")))
|
|
}
|
|
cmd.HelpFunc()(cmd, args)
|
|
},
|
|
}
|
|
|
|
cmd.AddCommand(NewScaleClusterCommand(cmdFactory, streams))
|
|
return cmd
|
|
}
|