From 2fb9d2b4bd745b0a21c29cb5c567aaf4393846e7 Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Mon, 13 Jan 2025 17:58:28 +0800 Subject: [PATCH] address comments Signed-off-by: lhy1024 --- tools/pd-ctl/pdctl/command/config_command.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tools/pd-ctl/pdctl/command/config_command.go b/tools/pd-ctl/pdctl/command/config_command.go index aed4f1a43f2..f0912c07c53 100644 --- a/tools/pd-ctl/pdctl/command/config_command.go +++ b/tools/pd-ctl/pdctl/command/config_command.go @@ -372,9 +372,8 @@ func postConfigDataWithPath(cmd *cobra.Command, key, value, path string) error { val, err := strconv.ParseFloat(value, 64) if err != nil { val = value - } - if key == "max-replicas" { - checkMaxReplicas(cmd, val) + } else if key == "max-replicas" { + checkMaxReplicas(cmd, val.(float64)) } data[key] = val reqData, err := json.Marshal(data) @@ -389,12 +388,7 @@ func postConfigDataWithPath(cmd *cobra.Command, key, value, path string) error { return nil } -func checkMaxReplicas(cmd *cobra.Command, value any) { - newReplica, ok := value.(float64) - if !ok { - // If the type is not float64, it will be handled elsewhere - return - } +func checkMaxReplicas(cmd *cobra.Command, newReplica float64) { header := buildHeader(cmd) r, err := doRequest(cmd, replicatePrefix, http.MethodGet, header) if err != nil {