Skip to content

Commit 84839a8

Browse files
[Feat][kubectl-plugin] Add Long, Example, shell completion for kubectl ray log (#2405)
Closes: #2404 Signed-off-by: Chi-Sheng Liu <[email protected]>
1 parent df5577f commit 84839a8

File tree

1 file changed

+27
-4
lines changed
  • kubectl-plugin/pkg/cmd/log

1 file changed

+27
-4
lines changed

kubectl-plugin/pkg/cmd/log/log.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import (
2222
"k8s.io/client-go/rest"
2323
"k8s.io/client-go/tools/remotecommand"
2424
cmdutil "k8s.io/kubectl/pkg/cmd/util"
25+
"k8s.io/kubectl/pkg/util/templates"
26+
27+
"github.com/ray-project/kuberay/kubectl-plugin/pkg/util/completion"
2528
)
2629

2730
const filePathInPod = "/tmp/ray/session_latest/logs/"
@@ -35,6 +38,23 @@ type ClusterLogOptions struct {
3538
args []string
3639
}
3740

41+
var (
42+
logLong = templates.LongDesc(`
43+
Download logs from a RayCluster and save them to a directory.
44+
`)
45+
46+
logExample = templates.Examples(`
47+
# Download logs from a RayCluster and save them to a directory with the RayCluster's name
48+
kubectl ray log my-raycluster
49+
50+
# Download logs from a RayCluster and save them to a directory named /path/to/dir
51+
kubectl ray log my-raycluster --out-dir /path/to/dir
52+
53+
# Download logs from a RayCluster, but only for the head node
54+
kubectl ray log my-raycluster --node-type head
55+
`)
56+
)
57+
3858
func NewClusterLogOptions(streams genericclioptions.IOStreams) *ClusterLogOptions {
3959
return &ClusterLogOptions{
4060
configFlags: genericclioptions.NewConfigFlags(true),
@@ -49,10 +69,13 @@ func NewClusterLogCommand(streams genericclioptions.IOStreams) *cobra.Command {
4969
cmdFactory := cmdutil.NewFactory(options.configFlags)
5070

5171
cmd := &cobra.Command{
52-
Use: "log (RAY_CLUSTER_NAME) [--out-dir DIR_PATH] [--node-type all|head|worker]",
53-
Short: "Get ray cluster log",
54-
Aliases: []string{"logs"},
55-
SilenceUsage: true,
72+
Use: "log (RAYCLUSTER) [--out-dir DIR_PATH] [--node-type all|head|worker]",
73+
Short: "Get ray cluster log",
74+
Long: logLong,
75+
Example: logExample,
76+
Aliases: []string{"logs"},
77+
SilenceUsage: true,
78+
ValidArgsFunction: completion.RayClusterCompletionFunc(cmdFactory),
5679
RunE: func(cmd *cobra.Command, args []string) error {
5780
if err := options.Complete(args); err != nil {
5881
return err

0 commit comments

Comments
 (0)