From 84ace26ae4c50e2fed26730d0211e181604cb838 Mon Sep 17 00:00:00 2001 From: CMGS Date: Tue, 8 Sep 2026 00:00:47 +0900 Subject: [PATCH] review: modern Go in the pod filter and the exec arg stop strings.CutSuffix replaces the HasSuffix-and-slice pair that stripped a percent sign, and the exec command's StopOnNthArg takes new(1) instead of a package-level variable that existed only to be addressed. --- cmd/pod/resource.go | 4 ++-- cmd/workload/cmd.go | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/pod/resource.go b/cmd/pod/resource.go index 3355e3e..743c39a 100644 --- a/cmd/pod/resource.go +++ b/cmd/pod/resource.go @@ -39,8 +39,8 @@ func (o *resourcePodOptions) filter(ctx context.Context, ch <-chan *corepb.NodeR value = filter["value"] percent bool ) - if strings.HasSuffix(value, "%") { - value = value[:len(value)-1] + if v, ok := strings.CutSuffix(value, "%"); ok { + value = v percent = true } diff --git a/cmd/workload/cmd.go b/cmd/workload/cmd.go index 0bcf801..9f73f49 100644 --- a/cmd/workload/cmd.go +++ b/cmd/workload/cmd.go @@ -32,8 +32,6 @@ const ( flagVolumesLimit = "volumes-limit" ) -var stopOnFirstArg = 1 - // Command returns the workload command tree. func Command() *cli.Command { return &cli.Command{ @@ -316,7 +314,7 @@ func Command() *cli.Command { Name: "exec", Usage: "run a command in a running workload", ArgsUsage: "workloadID -- cmd1 cmd2 cmd3", - StopOnNthArg: &stopOnFirstArg, + StopOnNthArg: new(1), Action: utils.ExitCoder(cmdWorkloadExec), Flags: []cli.Flag{ &cli.BoolFlag{